-
Notifications
You must be signed in to change notification settings - Fork 29.6k
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
esm: add import.meta.require
#55730
base: main
Are you sure you want to change the base?
esm: add import.meta.require
#55730
Conversation
Review requested:
|
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.
Did the discussion settle on a decision around the perf implications?
a833dcc
to
8705725
Compare
Would be great to have some time at the collab-summit to discuss |
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.
Is there still demand for it? I'm not against it but I don't expect many people to need it when you can usually just import the common js modules.
8705725
to
4c0d438
Compare
The primary use cases I can see for this is importing JSON files, so you don't have to write all the |
4c0d438
to
78cc229
Compare
85e9542
to
0be122b
Compare
0be122b
to
62df36f
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.
🙌 LGTM (assuming it's needed and the potential perf concern is 👍)
This seems a little weakly motivated in the PR description - it would help a lot to get more background on the specific use cases this is seeking to solve. |
This needs to go through WinterCG before landing. |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #55730 +/- ##
=======================================
Coverage 88.40% 88.40%
=======================================
Files 654 654
Lines 187655 187667 +12
Branches 36111 36114 +3
=======================================
+ Hits 165889 165914 +25
- Misses 14996 15001 +5
+ Partials 6770 6752 -18
|
History:
Consider the following cjs snippet:
The equivalent in esm would be something like (more or less):
We could improve the dx with the new
import.meta.require
:Now that we have cjs/esm interoperability we can create
import.meta.require
to syncronously require modules in ESM.It's just an alias for: