-
Notifications
You must be signed in to change notification settings - Fork 5.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(compat): integrate import map and classic resolutions in ESM resolution #12549
feat(compat): integrate import map and classic resolutions in ESM resolution #12549
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
I'd like @kitsonk to have another look |
A few questions:
|
URL mappings in the import maps are applied first - if there is a match coming from import map that URL is used and resolution "short-circuits" without going through finalization stage (because import map might remap to http:, https: or blob: which are not allowed in Node resolution). I guess you're suggesting that import map resolution should be applied last in the finalization stage so that if Node resolution resolves "foo" to "./node_modules/foo/index.js", the file path should still be remapped. Is that correct?
That's correct, if we resolve "./relative/path/to/foo.js` and there's an entry in import map that remaps this specifier then both Node and "regular" resolution are skipped.
Correct, as mentioned in the previous PR our resolver implementation is split across Rust and TypeScript, where @guybedford I believe this is not the final form of the resolution algorithm and it will change still, do you consider this approach to be a wrong one? @kitsonk what do you think about it? |
Yeah, I think the code here reflects what we discussed. It feels like something we want to maybe flesh out more test/cases scenarios, but it is just code and we can iterate on it. |
Not sure if appropriate to add as it is early days on this but wanted to chime in. Following from this tweet how was one meant to run rollup? My first thoughts were along the lines of using the JavascriptAPI like so: // main.js
import * as rollup from "https://esm.sh/rollup";
console.log(rollup);
// ... And running |
@DefinitelyMaybe if you pull from esm.sh you don't need to run with |
oops. I'll give that a try. sounds like still doing an npm install to generate the node_modules folder was [the/one-of] intended direction? or would urls from skypack work too? also, sorry, by doc's before I meant the manual. I realize I should've also looked into the unstable api pages |
With this PR landed you can use both, but again, if you want to use URL from skypack/esm/etc, you don't need to use |
This commit integrates import map and "classic" resolutions in
the "--compat" mode when using ES modules; in effect
"http:", "https:" and "blob:" imports now work in compat mode.
The algorithm works as follows:
return the specifier
the specifier