-
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
--require doesn't work with import #35103
Comments
@nodejs/modules |
this is definitely a duplicate but I'm not able to go diving for the original atm. |
Is it a duplicate in the sense that there's already a resolution/workaround for this? Or in that this is an existing bug that needs to be addressed? |
If you need a workaround, you can generally use a small wrapper CJS script that only contains I don't think anybody is working on support for |
Ya, we're using |
I think adding an |
cc @bmeck ^ |
It's probably a very bad idea, but using |
@jkrems I've never worked with the code for @targos I gave that a whirl and this was the error I ran into:
|
There was an effort to add |
Yep, I had trouble since everything in the bootstrap assumes it is a synchronous startup, adding asynchronous ticks made things get weird. I'd be wary of using |
IIRC
Yeah, loading arbitrary code in
The general starting point would be this guide: https://github.com/nodejs/node/blob/master/doc/guides/contributing/pull-requests.md. It starts with setting up a local checkout and covers how to test and commit changes. The One possible place to handle node/lib/internal/process/esm_loader.js Lines 40 to 63 in 05539c1
It may require changing the conditions under which we call initializeLoader .
One important trick to make the development go more quickly: |
@jkrems |
I don't think I'd have strong opinions. To me the order that makes sense is:
The biggest question for me is "should |
I'm guessing no, but is there another approach to loading data into a global settings object before the rest of the |
(oops, wrong issue) |
@jasnell This is still a desired feature, so what's the right way to handle that? Create another issue for it? |
Yeah, a separate issue or PR that implements something is ideal |
Fixes: #35103 PR-URL: #36806 Reviewed-By: Myles Borins <myles.borins@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Beth Griggs <bgriggs@redhat.com> Reviewed-By: Harshitha K P <harshitha014@gmail.com> Reviewed-By: Daijiro Wachi <daijiro.wachi@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
Fixes: #35103 PR-URL: #36806 Reviewed-By: Myles Borins <myles.borins@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Beth Griggs <bgriggs@redhat.com> Reviewed-By: Harshitha K P <harshitha014@gmail.com> Reviewed-By: Daijiro Wachi <daijiro.wachi@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
what would happen if -r would just mean |
I found a workaround for me, using ioctl to stuff the string to be executed in the TTY before running node:
I'm using Perl because that has ioctl readily availabile. It would be great if there was a |
What steps will reproduce the bug?
Run
node
with--require
and--experimental-specifier-resolution=node
An example can be found here when running
npm test
How often does it reproduce? Is there a required condition?
Always
What is the expected behavior?
There's a way to preload a file using
import
rather thanrequire
What do you see instead?
Additional information
It would be nice if there was a
--import
or if--require
worked withimport
sThe text was updated successfully, but these errors were encountered: