-
Notifications
You must be signed in to change notification settings - Fork 4.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
Lazy Import: Allow local paths as an option when importing #23751
Conversation
Size Change: 0 B Total Size: 1.21 MB ℹ️ View Unchanged
|
This would be really useful. Do you think it might be possible for the usage to be more like how one might expect to use In other words, instead of... lazyImport( 'fbjs@^1.0.0', {
localPath: './lib/shallowEqual',
} ); I would expect: lazyImport( 'fbjs/lib/shallowEqual@^1.0.0' ); It might be slightly more challenging to implement, since it means we probably can't take advantage of the existing usage of |
It turns out that the usage of
If we would decide to reimplement it ourselves we would lose some of those options or we would have to find a common approach on how to deal with local paths. Now the question is whether we want to introduce a special case: lazyImport( 'fbjs/lib/shallowEqual@^1.0.0' ); or we are fine with a more verbose API but also one that would work with all representations of |
8dbc73b
to
ebafd30
Compare
Error while building I think you need to add
|
I think you run into the same strange issue with one of the dependencies from the benchmark, it should work on every subsequent install. I was able to reproduce it every time but it always worked for @aduth 🤷♂️ Upon investigation, it was always only one of the packages used in the benchmark. See: #22684 (comment) |
ebafd30
to
d64c2a9
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.
Ok, it works on second run and looks good. 👍
Description
A try to unblock #23712 where we want to add support for external templates installed from npm in
@wordpress/create-block
.We miss a way to lazy import a local path from a package. It was only possible to import the script listed as
main
by the package.This PR adds a new option
localPath
that allows importing files other than those listed asmain
for the package.How has this been tested?
$ rm -rf node_modules $ npm install $ node packages/is-shallow-equal/benchmark/index.js`
Should run all the benchmarks on the
@wordpress/is-shallow-equal
package.Types of changes
New feature (non-breaking change which adds functionality).
Checklist: