WICG / import-maps

How to control the behavior of JavaScript imports
https://html.spec.whatwg.org/multipage/webappapis.html#import-maps
Other
2.7k stars 71 forks source link

Reference implementation of scopes #115

Closed guybedford closed 5 years ago

guybedford commented 5 years ago

This provides a simple implementation of scoped resolution with the various fallback tests.

The gist of the approach is:

Because of the way scopes are normalized during parsing, we end up needing to check for parentURL[normalizedScopeURL.length] === '/' || parntURL[normalizedScopeURL.length - 1] === '/' because scopes may or may not end in '/'. One optimization here might be to normalize scopes to always be with or without the trailing slash (possibly without?), but that seemed to affect quite a few of the parsing tests when I tried it. I could certainly implement that as well though.

Any other thoughts re edge cases very welcome, but I think most are already covered by the base import maps themselves.

domenic commented 5 years ago

I'm going to add to this PR to implement no-trailing-slash = exact matching, trailing-slash = prefix matching. For now that seems best to me. But let's keep #73 open and discuss more fully there; we can change after landing this.