-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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: make dynamic import work in the REPL #29437
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.
LGTM % nits
lib/repl.js
Outdated
pwd = pathToFileURL(process.cwd()).href; | ||
} catch { | ||
} | ||
const asyncESM = require('internal/process/esm_loader'); |
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 that not be loaded at the top level?
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.
could be, but i don't think we eagerly load esm_loader at top in most places since it is experimental/flagged, we do so as late as possible like in
node/lib/internal/bootstrap/pre_execution.js
Line 388 in 85898e0
const esm = require('internal/process/esm_loader'); |
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.
moved up but remaining in defaultEval
; made it lazier.
lib/repl.js
Outdated
const { pathToFileURL } = require('url'); | ||
pwd = pathToFileURL(process.cwd()).href; | ||
} catch { | ||
} |
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.
Nit: please move it out of the loop, since it won't change inside of the loop.
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.
fixed
b8c663d
to
b798182
Compare
rebased, running CI then will merge if no objections |
Landed in cdebd32 |
PR-URL: #29437 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: David Carlier <devnexen@gmail.com>
PR-URL: #29437 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: David Carlier <devnexen@gmail.com>
This ensures that
import("fs")
will work in the REPL with--experimental-modules
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passes