-
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
repl: support --loader option in builtin REPL #33437
Conversation
With the example from the issue:
With a wrong path:
With error in the loader code:
|
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 am fine with adding this feature. It would be good in general to support esm better in the REPL.
Maybe this is too heavy for this pr, but refactoring |
Ping @targos |
Updated with a different approach. PTAL. |
|
||
exports.loadESM = async function loadESM(callback) { | ||
try { | ||
await initializeLoader(); |
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.
should probably gate this on ESMLoader
being undefined
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.
do you mean add something like assert(ESMLoader === undefined)
?
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.
yeah that works.
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 can't. There's a default loader defined above, and removing it breaks things.
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
8ae28ff
to
2935f72
Compare
Landed in 05539c1 |
@targos could you please backport this to |
Fixes: nodejs#33435 PR-URL: nodejs#33437 Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Fixes: #33435
I'll try to write a test if there are no objections to the change.
/cc @nodejs/modules-active-members