-
Notifications
You must be signed in to change notification settings - Fork 29.7k
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
module: do not set CJS variables for Worker eval #53050
module: do not set CJS variables for Worker eval #53050
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.
Probably a separate PR, but could detect-module be a way to resolve #30682?
I think the same bug applies to regular node --eval "let __filename,__dirname,require,module,exports;this.a" # Clean exit
node --experimental-detect-module --eval "let __filename,__dirname,require,module,exports;this.a"
file:///Users/geoffrey/Sites/node/[eval1]:1
let __filename,__dirname,require,module,exports;this.a
^
TypeError: Cannot read properties of undefined (reading 'a')
at file:///Users/geoffrey/Sites/node/[eval1]:1:54
at ModuleJob.run (node:internal/modules/esm/module_job:262:25)
at async ModuleLoader.eval (node:internal/modules/esm/loader:218:24)
at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:109:5)
Node.js v22.2.0 I feel like we should fix it for |
IMO that could work. As soon as detect-module will also be the default (i.e. unflagged) it should work seamlessly, excepr the performance warning that should be suppressed in case of eval. |
Co-authored-by: Geoffrey Booth <webadmin@geoffreybooth.com>
I mean, it's already the case, no? When you set |
Landed in 2079a7a |
PR-URL: #53050 Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com> Reviewed-By: James M Snell <jasnell@gmail.com>
PR-URL: nodejs#53050 Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com> Reviewed-By: James M Snell <jasnell@gmail.com>
PR-URL: nodejs#53050 Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com> Reviewed-By: James M Snell <jasnell@gmail.com>
There are no local CJS variables in the Worker eval context – it's all global variables, just like in the
--eval
context.