-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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 <rlau@redhat.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
- Loading branch information
1 parent
39c7a9e
commit e95163b
Showing
5 changed files
with
58 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,38 @@ | ||
'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, [ | ||
'--no-warnings', | ||
'--experimental-require-module', | ||
'-p', | ||
'process.features.require_module', | ||
], { | ||
trim: true, | ||
stdout: 'true', | ||
stderr: '', // Should not emit warnings. | ||
}); | ||
|
||
// It is not enabled by default. | ||
spawnSyncAndAssert(process.execPath, [ | ||
'-p', | ||
'process.features.require_module', | ||
], { | ||
trim: true, | ||
stdout: 'false', | ||
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