-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
module: experimental modules runMain separation
PR-URL: #21350 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Bradley Farias <bradley.meck@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
- Loading branch information
1 parent
9e31684
commit 5cd78ba
Showing
4 changed files
with
44 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,27 @@ | ||
// Flags: --experimental-modules | ||
'use strict'; | ||
require('../common'); | ||
|
||
const common = require('../common'); | ||
const fixtures = require('../common/fixtures'); | ||
const { spawn } = require('child_process'); | ||
const assert = require('assert'); | ||
exports.asdf = 'asdf'; | ||
assert.strictEqual(require.main.exports.asdf, 'asdf'); | ||
|
||
const entry = fixtures.path('/es-modules/cjs.js'); | ||
|
||
const child = spawn(process.execPath, ['--experimental-modules', entry]); | ||
let experimentalWarning = false; | ||
let validatedExecution = false; | ||
child.stderr.on('data', (data) => { | ||
if (!experimentalWarning) { | ||
experimentalWarning = true; | ||
return; | ||
} | ||
throw new Error(data.toString()); | ||
}); | ||
child.stdout.on('data', (data) => { | ||
assert.strictEqual(data.toString(), 'executed\n'); | ||
validatedExecution = true; | ||
}); | ||
child.on('close', common.mustCall((code, stdout) => { | ||
assert.strictEqual(validatedExecution, true); | ||
assert.strictEqual(code, 0); | ||
})); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
'use strict'; | ||
|
||
// test we can use commonjs require | ||
require('path'); | ||
console.log('executed'); |