-
Notifications
You must be signed in to change notification settings - Fork 915
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
Let package export maps take priority over normal resolution #1781
Conversation
This pull request is being automatically deployed with Vercel (learn more). 🔍 Inspect: https://vercel.com/pikapkg/snowpack/rdhl23f04 |
fb7400f
to
6a644a1
Compare
"preact" | ||
"preact", | ||
"preact/hooks", | ||
"@clevercloud/components/assets/backup.svg" |
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.
This adds a local test for the new behavior (the others are just snapshot updates)
5167e63
to
3cbc6df
Compare
const linkElement = getByText(/learn react/i); | ||
expect(document.body.contains(linkElement)); | ||
}); | ||
}); |
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.
We didn’t need these tests
* one | ||
* two | ||
* three | ||
*/ |
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.
I think this test wasn’t working, and now it is?
@@ -542,7 +378,7 @@ function asyncEachOfLimit(generator, limit, iteratee, callback) { | |||
} | |||
var eachOfLimit = (limit) => { | |||
return (obj, iteratee, callback) => { | |||
callback = once$1(callback); | |||
callback = once(callback); |
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.
dependency update change
3cbc6df
to
3e6fce0
Compare
3e6fce0
to
92e385b
Compare
92e385b
to
e6f94a3
Compare
@@ -274,6 +274,7 @@ export async function scanImportsFromFiles( | |||
loadedFiles: SnowpackSourceFile[], | |||
config: SnowpackConfig, | |||
): Promise<InstallTarget[]> { | |||
await initESModuleLexer; |
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.
@FredKSchott this was added because parseFileForInstallTargets()
below calls parse()
, and that may have been called before await init
. This might not change anything, but this should help
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.
yup, safe to remove the original await initESModuleLexer;
now that this is here.
I mean, the whole idea of "this only works if you call this other thing implicitly" is kind of gross, but I like this better than converting the entire function stack to async, at least for now
Tests passed! Merging before I break anything else 🤪 |
Changes
Consider the following export map:
If you imported
foo/assets/backup.svg
, that should resolve tofoo/dist/assets/backup.svg
as indicated by the export map. However current behavior was thatesinstall
would assume thatfoo/assets/backup.svg
was the full path and it would fail to locate the asset.This PR still lets esinstall try and resolve full paths, but now we check the package exports first for a match. If that exists, and we find a match, use that. If not, the behavior continues as usual. Overall this is a minor change in behavior, and shouldn’t disrupt any packages (the only possible breaking change would be if a package had both a valid package export AND a file at that path, but that would be “wrong” anyway and should be fixed by this, as that’s not expected behavior).
Testing
Docs