Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
bootstrap: run preload prior to --frozen-intrinsics
This is used to allow people to run polyfills.
  • Loading branch information
bmeck committed Aug 2, 2019
commit 741b49c80fb4e0327af1955565d92af0e9caa3d3
3 changes: 3 additions & 0 deletions doc/api/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,9 @@ Support is currently only provided for the root context and no guarantees are
currently provided that `global.Array` is indeed the default intrinsic
reference. Code may break under this flag.

`--require` runs prior to freezing intrinsics in order to allow polyfills to
Comment thread
sam-github marked this conversation as resolved.
be added.

### `--heapsnapshot-signal=signal`
<!-- YAML
added: v12.0.0
Expand Down
2 changes: 1 addition & 1 deletion lib/internal/bootstrap/pre_execution.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ function prepareMainThreadExecution(expandArgv1 = false) {
initializeClusterIPC();

initializeDeprecations();
initializeFrozenIntrinsics();
initializeCJSLoader();
initializeESMLoader();
loadPreloadModules();
initializeFrozenIntrinsics();
Comment thread
addaleax marked this conversation as resolved.
Outdated
}

function patchProcessObject(expandArgv1) {
Expand Down
10 changes: 10 additions & 0 deletions test/parallel/test-preload.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const fixtureA = fixtures.path('printA.js');
const fixtureB = fixtures.path('printB.js');
const fixtureC = fixtures.path('printC.js');
const fixtureD = fixtures.path('define-global.js');
const fixtureE = fixtures.path('intrinsic-mutation.js');
const fixtureThrows = fixtures.path('throws_error4.js');

// Test preloading a single module works
Expand Down Expand Up @@ -62,6 +63,15 @@ childProcess.exec(
}
);

// Test that preload can be used with --frozen-intrinsics
childProcess.exec(
`"${nodeBinary}" --frozen-intrinsics ${preloadOption([fixtureE])}-e "console.log('hello');"`,
function(err, stdout) {
assert.ifError(err);
assert.strictEqual(stdout, 'hello\n');
Comment thread
bmeck marked this conversation as resolved.
Outdated
}
);

// Test that preload can be used with stdin
const stdinProc = childProcess.spawn(
nodeBinary,
Expand Down