This unflags --experimental-require-module so require(esm) can be used without the flag. For now, when require() actually encounters an ESM, it will still emit an experimental warning. To opt out of the feature, --no-experimental-require-module can be used. There are some tests specifically testing ERR_REQUIRE_ESM. Some of them are repurposed to test --no-experimental-require-module. Some of them are modified to just expect loading require(esm) to work, when it's appropriate. PR-URL: https://github.com/nodejs/node/pull/55085 Backport-PR-URL: https://github.com/nodejs/node/pull/55217 Refs: https://github.com/nodejs/node/issues/52697 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com> Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: LiviaMedeiros <livia@cirno.name> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Filip Skokan <panva.ip@gmail.com> Reviewed-By: Michael Dawson <midawson@redhat.com> Reviewed-By: Richard Lau <rlau@redhat.com>
37 lines
849 B
JavaScript
37 lines
849 B
JavaScript
'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.
|
|
});
|