amp-toolbox icon indicating copy to clipboard operation
amp-toolbox copied to clipboard

[linter] Misleading runtime preload recommendation when using ESM

Open schlessera opened this issue 4 years ago • 1 comments

The linter currently doesn't use a separate recommendation for ESM preloads:

https://github.com/ampproject/amp-toolbox/blob/153d76b722906aec1cb4a6c65d88f0c4d418630d/packages/linter/src/rules/RuntimeIsPreloaded.ts#L13

This is misleading, and might even lead to frustration if users blindly apply the recommendation and it doesn't solve the issue.

The linter should properly differentiate between:

  1. .js with rel=preload
  2. .mjs with rel=preload
  3. .mjs with rel=modulepreload

The recommendation should then be generated accordingly so that applying the recommendation verbatim will actually fix the shown issue.

schlessera avatar Jul 14 '21 16:07 schlessera

The linter should recognize both 2. and 3. but only recommend one of the two, obviously. I think to remember that there was currently a transitional period that favored one over the other, so I'm unsure what the final verdict is.

schlessera avatar Jul 14 '21 16:07 schlessera