Closed dmail closed 4 years ago
@dmail yes these cases are supposed to resolve against the import map file path itself, so if that is not the case then this is a bug.
The resolveAndComposeImportMap function call here - https://github.com/guybedford/es-module-shims/blob/master/src/es-module-shims.js#L231 is supposed to carry through the import map URL as the base URL for resolutions when the map is resolved on load. As far as I can tell looking at the code that is what it is doing.
If you want to look into this further or post a PR please do.
I just released 0.6.0 with the fix.
Just tested with version 0.6.0 and it works like a charm. Thank you :)
Hi there,
Inside an importmap file I would expect relative urls found in
scopes
to be resolved against the importmap file url. According to my test, they are resolved against the importer file.Steps to reproduce
Create an empty directory
Create
dist/bare.js
fileCreate
dist/index.js
fileCreate
importmap.importmap
fileCreate
index.html
fileYour file structure looks like this
index.html
Actual
An error is displayed in the console saying
Expected
No error in the console
Notes
I expected
"./dist/bare.js"
to be resolved tohttp://127.0.0.1:8080/dist/bare.js
but it is resolved tohttp://127.0.0.1:8080/dist/dist/bare.js
(dist
appear twice).When I look at reference implementation of importmaps where importmap scopes are normalized I understand that relative url in scopes are resolved against the importmap file base url (which fallbacks to document url for inline importmap). See https://github.com/WICG/import-maps/blob/a3e697d7b29d929e099cc012768245f8fd07597d/reference-implementation/lib/parser.js#L99
Can you confirm it works as designed and that you are spec compliant ?