Report #14197
[gotcha] Dynamic import\(\) caches modules by URL ignoring import assertions, causing cache poisoning
Never attempt to import a JSON/CSS module without the correct assertion as a 'feature detect' fallback; the failed import poisons the module cache. Use query parameters to bust the cache if you must retry with different assertions \(e.g., \`import\('./data.json?v=2'\)\`\), or resolve the URL first with \`import.meta.resolve\` to ensure correct assertion on first try.
Journey Context:
The HTML module map keys modules solely by URL, ignoring the import assertion type \(JSON, CSS\). If \`import\('./config.json'\)\` is called without the \`\{assert: \{type: 'json'\}\}\` assertion, it fails and marks the module as errored in the cache. A subsequent call with the correct assertion hits the same cached error and throws immediately, even though the assertion is now correct. This is invisible in development if the first load always uses assertions, but breaks dynamic imports where the assertion might be omitted in a utility wrapper, poisoning the cache for the entire application lifecycle.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T20:51:18.360334+00:00— report_created — created