When a public product demo loads the wrong module version, record the importing module’s URL and the import map that applies to it. A page named new-demo does not establish that every import uses the new dependency. Scope matching and prefix mapping can produce a valid, but unintended, version.
The artifact below is a complete harmless browser fixture:one document, two entry modules and three dependency modules. It keeps two supported demo versions on the same page and checks their actual output markers. It does not install a package or execute a product workflow.
The CLI executable resolution audit asks which filesystem program a tutorial invokes. This review asks which browser module a public document imports under its map. Similar version labels do not make the mechanisms interchangeable.
Keep import-map scope within the documented boundary
The current MDN import-map reference describes imports and scopes, including prefix mappings that require trailing slashes in both the key and mapped path. It also says import maps must be processed before module scripts using their mappings.
An import map applies to module specifiers in import statements and dynamic import for document modules. It does not remap a script element’s src attribute, and it does not govern modules loaded into workers or worklets. Keep those contexts outside this fixture’s claim.
The source importing module matters for scoped selection. Do not use the public HTML page’s pathname as a substitute for the actual module URL when deciding which scope applies. A page under one directory can load its entry module from another directory.
Use the complete document and dependency files
Serve this document at an authorized local origin. All paths below belong to that same fixture origin;there are no external libraries or remote requests.
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Fictional public module fixture</title>
<script type="importmap">{
"imports": {
"labels": "/modules/v1/labels.js",
"tools/": "/modules/shared/"
},
"scopes": {
"/demos/new/": {
"labels": "/modules/v2/labels.js"
}
}
}</script>
<script type="module" src="/demos/old/main.js"></script>
<script type="module" src="/demos/new/main.js"></script>
</head>
<body><p>Public explanation: compare the two supported demo versions.</p></body>
</html>
Serve /demos/old/main.js with:
import { label } from 'labels';
import { unit } from 'tools/unit.js';
document.documentElement.dataset.oldDemo = label + ':' + unit;
Serve /demos/new/main.js with:
import { label } from 'labels';
import { unit } from 'tools/unit.js';
document.documentElement.dataset.newDemo = label + ':' + unit;
The three complete dependency files are:
// /modules/v1/labels.js
export const label = 'v1';
// /modules/v2/labels.js
export const label = 'v2';
// /modules/shared/unit.js
export const unit = 'ms';
The comments identify three separate resources, not one file containing conflicting declarations. Serve each resource as appropriate JavaScript. The public explanatory paragraph remains present even if a diagnostic module fails.
Keep the populated resolution oracle
The approved module-selection table is independent of the emitted map:
| Importer | Specifier | Expected resource |
|---|---|---|
| /demos/old/main.js | labels | /modules/v1/labels.js |
| /demos/new/main.js | labels | /modules/v2/labels.js |
| /demos/old/main.js | tools/unit.js | /modules/shared/unit.js |
| /demos/new/main.js | tools/unit.js | /modules/shared/unit.js |
The expected final markers are oldDemo=v1:ms and newDemo=v2:ms. These strings are synthetic proof of dependency selection, not actual product version compatibility evidence. A successful HTTP response for every file is insufficient if both entry modules receive the same unintended label.
Run the wrong-scope negative
Change the scoped key from /demos/new/ to /pages/new/ while leaving both entry module URLs unchanged. The new entry no longer matches the intended scope and falls back to the global labels mapping. Its output becomes v1:ms under this controlled design, which must fail the expected new-demo marker.
Moving the HTML document under /pages/new/ would not repair that particular importer mismatch. The test’s relevant importer remains /demos/new/main.js. Preserve its actual URL in the receipt rather than diagnosing scope from a screenshot or page title.
Restore the baseline before the next mutation. A failed scoped mapping can look like a stale content release, but the artifact should first establish the actual resolution rule instead of renaming files until a preferred label appears.
Test prefix and default failures separately
Remove the trailing slash from the mapped tools/ target. The documented prefix contract is now invalid;the expected unit import should not be accepted as though the map remained correct. Inspect browser warnings and the missing module marker, not just whether the page shell loaded.
Then restore that mapping and point the global labels key at the v2 file. The old demo must fail its v1 expectation even though the new demo still works. This control catches a test suite that checks only the newest public path while breaking a supported older example.
Keep module caching and context state controlled between runs. A previously evaluated module can remain in a document’s module graph. Use fresh page contexts for these mutations rather than assuming an edited map rewrites every module already loaded.
Keep routing and metadata checks separate
The fixture’s entry script src values are ordinary resource URLs. Import-map success does not establish that direct visits to a public demo page return the intended document or that its canonical is correct. Use the rendered-page evidence method for that wider public content check.
The versioned documentation policy decides which supported version readers should discover. Do not change that policy merely to hide a module-resolution defect or make an old example silently execute the newest behavior.
If a real demo needs another origin, CORS and other resource policies add separate requirements. The same-origin fixture deliberately isolates mapping semantics. Preserve that scope instead of treating a local resolution pass as universal deployment compatibility.
Release the dependency selection contract
The receipt should contain the exact map, document and importer URLs, all five module resources, expected resolution rows, browser markers and negative outcomes. Record the actual browser version and observed network requests for the controlled test.
Approve when both supported entry modules select their intended dependencies and the shared prefix resolves consistently. A missing or unintended fallback should remain a concrete finding with an owner, not a reason to copy a different map without understanding its scope.
The result is a reproducible public-demo dependency contract. It does not establish product correctness, search indexing or that an import map applies outside the document-module context its source documentation describes.
