From 1ff956f49e05bbfd86c0d3746b043060f166423c Mon Sep 17 00:00:00 2001 From: Guy Bedford Date: Wed, 26 Feb 2020 22:32:08 +0200 Subject: [PATCH] module: remove experimental modules warning MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Backport-PR-URL: https://github.com/nodejs/node/pull/35757 PR-URL: https://github.com/nodejs/node/pull/31974 Reviewed-By: Myles Borins Reviewed-By: Jan Krems Reviewed-By: Geoffrey Booth Reviewed-By: Michaƫl Zasso --- lib/internal/process/esm_loader.js | 22 +++---------------- test/es-module/test-esm-dynamic-import.js | 3 --- test/es-module/test-esm-nowarn-exports.mjs | 2 +- test/message/async_error_sync_esm.out | 1 - test/message/esm_display_syntax_error.out | 1 - .../esm_display_syntax_error_import.out | 1 - ...esm_display_syntax_error_import_module.out | 1 - .../esm_display_syntax_error_module.out | 1 - test/message/esm_loader_not_found.out | 1 - .../esm_loader_not_found_cjs_hint_bare.out | 1 - ...esm_loader_not_found_cjs_hint_relative.out | 1 - test/message/esm_loader_syntax_error.out | 1 - 12 files changed, 4 insertions(+), 32 deletions(-) diff --git a/lib/internal/process/esm_loader.js b/lib/internal/process/esm_loader.js index 7788e7db7d0f91..15e3a2cafda9b6 100644 --- a/lib/internal/process/esm_loader.js +++ b/lib/internal/process/esm_loader.js @@ -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, @@ -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); @@ -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; @@ -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()) { diff --git a/test/es-module/test-esm-dynamic-import.js b/test/es-module/test-esm-dynamic-import.js index 4e87866b2bad3b..0cb56dff2c04c5 100644 --- a/test/es-module/test-esm-dynamic-import.js +++ b/test/es-module/test-esm-dynamic-import.js @@ -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}")`)); diff --git a/test/es-module/test-esm-nowarn-exports.mjs b/test/es-module/test-esm-nowarn-exports.mjs index 13bfaf9b4f3527..5e0927f4674f84 100644 --- a/test/es-module/test-esm-nowarn-exports.mjs +++ b/test/es-module/test-esm-nowarn-exports.mjs @@ -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( diff --git a/test/message/async_error_sync_esm.out b/test/message/async_error_sync_esm.out index 6577fff6944723..6054fc7cc22de0 100644 --- a/test/message/async_error_sync_esm.out +++ b/test/message/async_error_sync_esm.out @@ -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) diff --git a/test/message/esm_display_syntax_error.out b/test/message/esm_display_syntax_error.out index 778d901129fa95..b7d2008540adf3 100644 --- a/test/message/esm_display_syntax_error.out +++ b/test/message/esm_display_syntax_error.out @@ -1,4 +1,3 @@ -(node:*) ExperimentalWarning: The ESM module loader is experimental. file:///*/test/message/esm_display_syntax_error.mjs:2 await async () => 0; ^^^^^ diff --git a/test/message/esm_display_syntax_error_import.out b/test/message/esm_display_syntax_error_import.out index 8ca1165766bf77..fe174d54a5c49f 100644 --- a/test/message/esm_display_syntax_error_import.out +++ b/test/message/esm_display_syntax_error_import.out @@ -1,4 +1,3 @@ -(node:*) ExperimentalWarning: The ESM module loader is experimental. file:///*/test/message/esm_display_syntax_error_import.mjs:5 notfound ^^^^^^^^ diff --git a/test/message/esm_display_syntax_error_import_module.out b/test/message/esm_display_syntax_error_import_module.out index 56035bc0340cc8..d220627bd02654 100644 --- a/test/message/esm_display_syntax_error_import_module.out +++ b/test/message/esm_display_syntax_error_import_module.out @@ -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'; ^^^^^^^^ diff --git a/test/message/esm_display_syntax_error_module.out b/test/message/esm_display_syntax_error_module.out index a1498f72c94d57..708257fcaf5792 100644 --- a/test/message/esm_display_syntax_error_module.out +++ b/test/message/esm_display_syntax_error_module.out @@ -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; ^^^^^ diff --git a/test/message/esm_loader_not_found.out b/test/message/esm_loader_not_found.out index 4fe916b315f9d8..97400699e644b7 100644 --- a/test/message/esm_loader_not_found.out +++ b/test/message/esm_loader_not_found.out @@ -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( diff --git a/test/message/esm_loader_not_found_cjs_hint_bare.out b/test/message/esm_loader_not_found_cjs_hint_bare.out index edf71b42719979..c3f758577eb4d6 100644 --- a/test/message/esm_loader_not_found_cjs_hint_bare.out +++ b/test/message/esm_loader_not_found_cjs_hint_bare.out @@ -1,4 +1,3 @@ -(node:*) ExperimentalWarning: The ESM module loader is experimental. internal/process/esm_loader.js:* internalBinding('errors').triggerUncaughtException( ^ diff --git a/test/message/esm_loader_not_found_cjs_hint_relative.out b/test/message/esm_loader_not_found_cjs_hint_relative.out index 63a3a4aff92def..eeb4480ee19144 100644 --- a/test/message/esm_loader_not_found_cjs_hint_relative.out +++ b/test/message/esm_loader_not_found_cjs_hint_relative.out @@ -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( diff --git a/test/message/esm_loader_syntax_error.out b/test/message/esm_loader_syntax_error.out index 9767a9c86c6bc2..7dd1c01fbcc1bf 100644 --- a/test/message/esm_loader_syntax_error.out +++ b/test/message/esm_loader_syntax_error.out @@ -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;