-
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.
process: add process.features.require_module
For detecting whether `require(esm)` is supported without triggering the experimental warning. PR-URL: #55241 Reviewed-By: Richard Lau <[email protected]> Reviewed-By: Matteo Collina <[email protected]>
- Loading branch information
1 parent
bfd9261
commit f098dba
Showing
5 changed files
with
56 additions
and
0 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
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,37 @@ | ||
'use strict'; | ||
|
||
// This tests that process.features.require_module can be used to feature-detect | ||
// require(esm) without triggering a warning. | ||
|
||
require('../common'); | ||
const { spawnSyncAndAssert } = require('../common/child_process'); | ||
|
||
spawnSyncAndAssert(process.execPath, [ | ||
'--experimental-require-module', | ||
'-p', | ||
'process.features.require_module', | ||
], { | ||
trim: true, | ||
stdout: 'true', | ||
stderr: '', // Should not emit warnings. | ||
}); | ||
|
||
// It is now enabled by default. | ||
spawnSyncAndAssert(process.execPath, [ | ||
'-p', | ||
'process.features.require_module', | ||
], { | ||
trim: true, | ||
stdout: 'true', | ||
stderr: '', // Should not emit warnings. | ||
}); | ||
|
||
spawnSyncAndAssert(process.execPath, [ | ||
'--no-experimental-require-module', | ||
'-p', | ||
'process.features.require_module', | ||
], { | ||
trim: true, | ||
stdout: 'false', | ||
stderr: '', // Should not emit warnings. | ||
}); |
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