Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[12.x backport] module: remove experimental modules warning #35749

Closed
Show file tree
Hide file tree
Changes from all commits
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
22 changes: 3 additions & 19 deletions lib/internal/process/esm_loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
const {
ERR_VM_DYNAMIC_IMPORT_CALLBACK_MISSING,
} = require('internal/errors').codes;
const assert = require('internal/assert');
const { Loader } = require('internal/modules/esm/loader');
const {
hasUncaughtExceptionCaptureCallback,
Expand All @@ -26,13 +25,6 @@ exports.initializeImportMetaObject = function(wrap, meta) {
};

exports.importModuleDynamicallyCallback = async function(wrap, specifier) {
assert(calledInitialize === true || !userLoader);
if (!calledInitialize) {
process.emitWarning(
'The ESM module loader is experimental.',
'ExperimentalWarning', undefined);
calledInitialize = true;
}
const { callbackMap } = internalBinding('module_wrap');
if (callbackMap.has(wrap)) {
const { importModuleDynamically } = callbackMap.get(wrap);
Expand All @@ -47,15 +39,7 @@ exports.importModuleDynamicallyCallback = async function(wrap, specifier) {
let ESMLoader = new Loader();
exports.ESMLoader = ESMLoader;

let calledInitialize = false;
async function initializeLoader(emitWarning) {
assert(calledInitialize === false);
if (emitWarning) {
process.emitWarning(
'The ESM module loader is experimental.',
'ExperimentalWarning', undefined);
}
calledInitialize = true;
async function initializeLoader() {
if (!userLoader)
return;
let cwd;
Expand All @@ -78,9 +62,9 @@ async function initializeLoader(emitWarning) {
})();
}

exports.loadESM = async function loadESM(callback, emitWarning = true) {
exports.loadESM = async function loadESM(callback) {
try {
await initializeLoader(emitWarning);
await initializeLoader();
await callback(ESMLoader);
} catch (err) {
if (hasUncaughtExceptionCaptureCallback()) {
Expand Down
3 changes: 0 additions & 3 deletions test/es-module/test-esm-dynamic-import.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,6 @@ function expectFsNamespace(result) {
// For direct use of import expressions inside of CJS or ES modules, including
// via eval, all kinds of specifiers should work without issue.
(function testScriptOrModuleImport() {
common.expectWarning('ExperimentalWarning',
'The ESM module loader is experimental.');

// Importing another file, both direct & via eval
// expectOkNamespace(import(relativePath));
expectOkNamespace(eval(`import("${relativePath}")`));
Expand Down
2 changes: 1 addition & 1 deletion test/es-module/test-esm-nowarn-exports.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ child.stderr.on('data', (data) => {
child.on('close', (code, signal) => {
strictEqual(code, 0);
strictEqual(signal, null);
ok(stderr.toString().includes(
ok(!stderr.toString().includes(
'ExperimentalWarning: The ESM module loader is experimental'
));
ok(!stderr.toString().includes(
Expand Down
1 change: 0 additions & 1 deletion test/message/async_error_sync_esm.out
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
(node:*) ExperimentalWarning: The ESM module loader is experimental.
Error: test
at one (*fixtures*async-error.js:4:9)
at two (*fixtures*async-error.js:17:9)
Expand Down
1 change: 0 additions & 1 deletion test/message/esm_display_syntax_error.out
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
(node:*) ExperimentalWarning: The ESM module loader is experimental.
file:///*/test/message/esm_display_syntax_error.mjs:2
await async () => 0;
^^^^^
Expand Down
1 change: 0 additions & 1 deletion test/message/esm_display_syntax_error_import.out
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
(node:*) ExperimentalWarning: The ESM module loader is experimental.
file:///*/test/message/esm_display_syntax_error_import.mjs:5
notfound
^^^^^^^^
Expand Down
1 change: 0 additions & 1 deletion test/message/esm_display_syntax_error_import_module.out
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
(node:*) ExperimentalWarning: The ESM module loader is experimental.
file:///*/test/fixtures/es-module-loaders/syntax-error-import.mjs:1
import { foo, notfound } from './module-named-exports.mjs';
^^^^^^^^
Expand Down
1 change: 0 additions & 1 deletion test/message/esm_display_syntax_error_module.out
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
(node:*) ExperimentalWarning: The ESM module loader is experimental.
file:///*/test/fixtures/es-module-loaders/syntax-error.mjs:2
await async () => 0;
^^^^^
Expand Down
1 change: 0 additions & 1 deletion test/message/esm_loader_not_found.out
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
(node:*) ExperimentalWarning: The ESM module loader is experimental.
(node:*) ExperimentalWarning: --experimental-loader is an experimental feature. This feature could change at any time
internal/process/esm_loader.js:*
internalBinding('errors').triggerUncaughtException(
Expand Down
1 change: 0 additions & 1 deletion test/message/esm_loader_not_found_cjs_hint_bare.out
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
(node:*) ExperimentalWarning: The ESM module loader is experimental.
internal/process/esm_loader.js:*
internalBinding('errors').triggerUncaughtException(
^
Expand Down
1 change: 0 additions & 1 deletion test/message/esm_loader_not_found_cjs_hint_relative.out
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
(node:*) ExperimentalWarning: The ESM module loader is experimental.
(node:*) ExperimentalWarning: --experimental-loader is an experimental feature. This feature could change at any time
internal/process/esm_loader.js:*
internalBinding('errors').triggerUncaughtException(
Expand Down
1 change: 0 additions & 1 deletion test/message/esm_loader_syntax_error.out
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
(node:*) ExperimentalWarning: The ESM module loader is experimental.
(node:*) ExperimentalWarning: --experimental-loader is an experimental feature. This feature could change at any time
file://*/test/fixtures/es-module-loaders/syntax-error.mjs:2
await async () => 0;
Expand Down