Repository navigation
Undocumented inability to put REPL in ES module context #32935
Description
Activity
cc @devsnek, what's the latest on that "REPL" parse goal?
if you mean the tc39 proposal, it's not doing anything right now. if you mean the v8 debug feature, I think they're in user feedback mode atm, not actively making anything.
So I think where we left off with this was that when/if the REPL parse goal shipped, our REPL would use that. But if that's not advancing, should we discuss alternatives?
One option that comes to mind is to just extend
--input-typeto apply to the REPL. But I don't know how that would work in practice; I would think that staticimportandexportstatements would throw, for example. And sinceimport()is already supported in Script/CommonJS, such a REPL mode wouldn't be that different than what we have now.I tried typing
import.metainto the Chrome console and I got the sameUncaught SyntaxError: Cannot use 'import.meta' outside a moduleerror, so I guess that's not supported there either.In the short term I can try to look into enabling import declarations and import.meta in V8 replMode. I don't think --input-type should have any effect on the repl, it doesn't really make sense to call it a script or a module or anything like that. We will have to overhaul our repl in node to take advantage of replMode though (cc @BridgeAR)
Reacted by Ruben BridgewaterReacted by Derek LewisSo V8 replMode is basically the “REPL parse goal” I remember you describing, where it tries to support everything at once?
importstatements, redeclaringconst, etc.?@GeoffreyBooth i don't know the exact plans of the v8 team, i posted in v8:6903 so we'll see what happens.
- addedesmIssues and PRs related to the ECMAScript Modules implementation.Issues and PRs related to the ECMAScript Modules implementation.replIssues and PRs related to the REPL subsystem.Issues and PRs related to the REPL subsystem.v8 engineIssues and PRs related to the V8 dependency.Issues and PRs related to the V8 dependency.experimentalIssues and PRs related to experimental features.Issues and PRs related to experimental features.feature requestIssues requesting new Node.js features.Issues requesting new Node.js features.
on Apr 20, 2020 The
replModeallows to reassignletstatements gracefully. We'll have to implement some parts in vm first to access that part though (at least that's how it seemed when I last checked).It is likely that the
replModewill receive further changes later on but that's all that is included so far.Top level await will be available as soon as V8 supports that (acorn must also support it but that should not take too long afterwards). It's independent from the
replMode.DerekNonGeneric commented
on Jun 12, 2020 ContributorAuthorMore actionsShould we document this inability in the meantime? Hope to tackle this issue unless it's tracking something else.
There has been no activity on this feature request for 5 months and it is unlikely to be implemented. It will be closed 6 months after the last non-automated comment.
For more information on how the project manages feature requests, please consult the feature request management document.
- addedstaleIssues and PRs marked stale due to inactivity and scheduled for automatic closure.Issues and PRs marked stale due to inactivity and scheduled for automatic closure.
on Mar 8, 2022 There has been no activity on this feature request and it is being closed. If you feel closing this issue is not the right thing to do, please leave a comment.
For more information on how the project manages feature requests, please consult the feature request management document.
There does not appear to be a way to put the REPL in ES module context.
The closest you'll get to it seems to be by running:
node --experimental-repl-awaitawait import('./foo.mjs')Give it a try and you'll see that evaluating
import.metathrows this error:I'd like this issue to discuss whether or not this limitation is presently documented somewhere or should be illuminated in https://nodejs.org/api/esm.html or elsewhere.
Note: this issue isn't about executing code with
--evalusing the--input-type=moduleflag.