-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Support using packages in imports resolved by the glob resolver #8097
Support using packages in imports resolved by the glob resolver #8097
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.
Looks good thanks!
|
||
module.exports = async function () { | ||
await promise.all([scoped, unscoped]); | ||
return scoped.a + scoped.b + unscoped.x + unscoped.y; |
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 it should be Promise.all
? And each key on the returned object from import()
is a function that also resolves to a promise, so this should be await scoped.a() + await scoped.b() ...
name: 'index.js', | ||
assets: ['*.js', '*.js', 'a.js', 'b.js', 'x.js', 'y.js', 'index.js'], | ||
}, | ||
]); |
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.
Probably should run
the resulting bundle here as in the other tests to ensure it actually works
// if the specifier does not start with /, ~, or . then it's not a path but package-ish - we resolve | ||
// the package first, and then append the rest of the path | ||
if (!/^[/~.]/.test(specifier)) { | ||
specifier = path.normalize(specifier); |
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 globs are supposed to always use /
as a separator, even on Windows. See https://github.com/micromatch/micromatch#backslashes. So this might not be needed.
925fec2
to
a6502dc
Compare
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.
Thanks, this looks great!
↪️ Pull Request
Implements the ability for the glob resolver to resolve globs in packages, fixes #7945.
💻 Examples
With this change the glob resolver will work with a glob like
import('@scope/pkg/i18n/*.js')
, by first resolving@scope/pkg
to a path, and then appending/i18n/*.js
.🚨 Test instructions
An integration test has been added for both a regular
require
as well as an asyncimport
. Please provide feedback if the tests added are not comprehensive enough.✔️ PR Todo
unitintegration tests for this change