GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — worker: handle `--input-type` more consistently · nodejs/node@f39ff4d

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • lib/internal/main
    • worker_thread.js
  • test/parallel
    • test-worker-cli-options.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎lib/internal/main/worker_thread.js‎

Copy file name to clipboardExpand all lines: lib/internal/main/worker_thread.js
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ let debug = require('internal/util/debuglog').debuglog('worker', (fn) => {
5353
});
5454

5555
const assert = require('internal/assert');
56+
const { getOptionValue } = require('internal/options');
5657
const { exitCodes: { kGenericUserError } } = internalBinding('errors');
5758

5859
prepareWorkerThreadExecution();
@@ -153,7 +154,7 @@ port.on('message', (message) => {
153154
break;
154155
}
155156

156-
case 'classic': {
157+
case 'classic': if (getOptionValue('--input-type') !== 'module') {
157158
const { evalScript } = require('internal/process/execution');
158159
const name = '[worker eval]';
159160
// This is necessary for CJS module compilation.
@@ -169,6 +170,7 @@ port.on('message', (message) => {
169170
break;
170171
}
171172

173+
// eslint-disable-next-line no-fallthrough
172174
case 'module': {
173175
const { evalModuleEntryPoint } = require('internal/process/execution');
174176
PromisePrototypeThen(evalModuleEntryPoint(filename), undefined, (e) => {
Collapse file

‎test/parallel/test-worker-cli-options.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-worker-cli-options.js
+9-1Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Flags: --expose-internals --expose-gc
22
'use strict';
3-
require('../common');
3+
const common = require('../common');
44
const { Worker } = require('worker_threads');
55
const assert = require('assert');
66

@@ -29,3 +29,11 @@ new Worker(CODE, { eval: true, env: process.env, execArgv: ['--expose-internals'
2929
assert.throws(() => {
3030
new Worker(CODE, { eval: true, execArgv: ['--expose-gc'] });
3131
}, /ERR_WORKER_INVALID_EXEC_ARGV/);
32+
33+
// Test ESM eval
34+
new Worker('export {}', { eval: true, execArgv: ['--input-type=module'] });
35+
new Worker('export {}', { eval: true, execArgv: ['--input-type=commonjs'] })
36+
.once('error', common.expectsError({ name: 'SyntaxError' }));
37+
new Worker('export {}', { eval: true, execArgv: ['--experimental-detect-module'] });
38+
new Worker('export {}', { eval: true, execArgv: ['--no-experimental-detect-module'] })
39+
.once('error', common.expectsError({ name: 'SyntaxError' }));

0 commit comments

Comments
0 (0)
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.