Skip to content

Commit 1ff956f

Browse files
guybedfordMylesBorins
authored andcommitted
module: remove experimental modules warning
Backport-PR-URL: #35757 PR-URL: #31974 Reviewed-By: Myles Borins <[email protected]> Reviewed-By: Jan Krems <[email protected]> Reviewed-By: Geoffrey Booth <[email protected]> Reviewed-By: Michaël Zasso <[email protected]>
1 parent 985b96a commit 1ff956f

12 files changed

+4
-32
lines changed

lib/internal/process/esm_loader.js

+3-19
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
const {
44
ERR_VM_DYNAMIC_IMPORT_CALLBACK_MISSING,
55
} = require('internal/errors').codes;
6-
const assert = require('internal/assert');
76
const { Loader } = require('internal/modules/esm/loader');
87
const {
98
hasUncaughtExceptionCaptureCallback,
@@ -26,13 +25,6 @@ exports.initializeImportMetaObject = function(wrap, meta) {
2625
};
2726

2827
exports.importModuleDynamicallyCallback = async function(wrap, specifier) {
29-
assert(calledInitialize === true || !userLoader);
30-
if (!calledInitialize) {
31-
process.emitWarning(
32-
'The ESM module loader is experimental.',
33-
'ExperimentalWarning', undefined);
34-
calledInitialize = true;
35-
}
3628
const { callbackMap } = internalBinding('module_wrap');
3729
if (callbackMap.has(wrap)) {
3830
const { importModuleDynamically } = callbackMap.get(wrap);
@@ -47,15 +39,7 @@ exports.importModuleDynamicallyCallback = async function(wrap, specifier) {
4739
let ESMLoader = new Loader();
4840
exports.ESMLoader = ESMLoader;
4941

50-
let calledInitialize = false;
51-
async function initializeLoader(emitWarning) {
52-
assert(calledInitialize === false);
53-
if (emitWarning) {
54-
process.emitWarning(
55-
'The ESM module loader is experimental.',
56-
'ExperimentalWarning', undefined);
57-
}
58-
calledInitialize = true;
42+
async function initializeLoader() {
5943
if (!userLoader)
6044
return;
6145
let cwd;
@@ -78,9 +62,9 @@ async function initializeLoader(emitWarning) {
7862
})();
7963
}
8064

81-
exports.loadESM = async function loadESM(callback, emitWarning = true) {
65+
exports.loadESM = async function loadESM(callback) {
8266
try {
83-
await initializeLoader(emitWarning);
67+
await initializeLoader();
8468
await callback(ESMLoader);
8569
} catch (err) {
8670
if (hasUncaughtExceptionCaptureCallback()) {

test/es-module/test-esm-dynamic-import.js

-3
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,6 @@ function expectFsNamespace(result) {
3838
// For direct use of import expressions inside of CJS or ES modules, including
3939
// via eval, all kinds of specifiers should work without issue.
4040
(function testScriptOrModuleImport() {
41-
common.expectWarning('ExperimentalWarning',
42-
'The ESM module loader is experimental.');
43-
4441
// Importing another file, both direct & via eval
4542
// expectOkNamespace(import(relativePath));
4643
expectOkNamespace(eval(`import("${relativePath}")`));

test/es-module/test-esm-nowarn-exports.mjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ child.stderr.on('data', (data) => {
1616
child.on('close', (code, signal) => {
1717
strictEqual(code, 0);
1818
strictEqual(signal, null);
19-
ok(stderr.toString().includes(
19+
ok(!stderr.toString().includes(
2020
'ExperimentalWarning: The ESM module loader is experimental'
2121
));
2222
ok(!stderr.toString().includes(

test/message/async_error_sync_esm.out

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
(node:*) ExperimentalWarning: The ESM module loader is experimental.
21
Error: test
32
at one (*fixtures*async-error.js:4:9)
43
at two (*fixtures*async-error.js:17:9)

test/message/esm_display_syntax_error.out

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
(node:*) ExperimentalWarning: The ESM module loader is experimental.
21
file:///*/test/message/esm_display_syntax_error.mjs:2
32
await async () => 0;
43
^^^^^

test/message/esm_display_syntax_error_import.out

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
(node:*) ExperimentalWarning: The ESM module loader is experimental.
21
file:///*/test/message/esm_display_syntax_error_import.mjs:5
32
notfound
43
^^^^^^^^

test/message/esm_display_syntax_error_import_module.out

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
(node:*) ExperimentalWarning: The ESM module loader is experimental.
21
file:///*/test/fixtures/es-module-loaders/syntax-error-import.mjs:1
32
import { foo, notfound } from './module-named-exports.mjs';
43
^^^^^^^^

test/message/esm_display_syntax_error_module.out

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
(node:*) ExperimentalWarning: The ESM module loader is experimental.
21
file:///*/test/fixtures/es-module-loaders/syntax-error.mjs:2
32
await async () => 0;
43
^^^^^

test/message/esm_loader_not_found.out

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
(node:*) ExperimentalWarning: The ESM module loader is experimental.
21
(node:*) ExperimentalWarning: --experimental-loader is an experimental feature. This feature could change at any time
32
internal/process/esm_loader.js:*
43
internalBinding('errors').triggerUncaughtException(

test/message/esm_loader_not_found_cjs_hint_bare.out

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
(node:*) ExperimentalWarning: The ESM module loader is experimental.
21
internal/process/esm_loader.js:*
32
internalBinding('errors').triggerUncaughtException(
43
^

test/message/esm_loader_not_found_cjs_hint_relative.out

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
(node:*) ExperimentalWarning: The ESM module loader is experimental.
21
(node:*) ExperimentalWarning: --experimental-loader is an experimental feature. This feature could change at any time
32
internal/process/esm_loader.js:*
43
internalBinding('errors').triggerUncaughtException(

test/message/esm_loader_syntax_error.out

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
(node:*) ExperimentalWarning: The ESM module loader is experimental.
21
(node:*) ExperimentalWarning: --experimental-loader is an experimental feature. This feature could change at any time
32
file://*/test/fixtures/es-module-loaders/syntax-error.mjs:2
43
await async () => 0;

0 commit comments

Comments
 (0)