mirror of
https://github.com/zebrajr/node.git
synced 2025-12-07 12:20:50 +01:00
module: remove experimental modules warning
Backport-PR-URL: https://github.com/nodejs/node/pull/35757 PR-URL: https://github.com/nodejs/node/pull/31974 Reviewed-By: Myles Borins <myles.borins@gmail.com> Reviewed-By: Jan Krems <jan.krems@gmail.com> Reviewed-By: Geoffrey Booth <webmaster@geoffreybooth.com> Reviewed-By: Michaël Zasso <targos@protonmail.com>
This commit is contained in:
parent
985b96a7d5
commit
1ff956f49e
|
|
@ -3,7 +3,6 @@
|
||||||
const {
|
const {
|
||||||
ERR_VM_DYNAMIC_IMPORT_CALLBACK_MISSING,
|
ERR_VM_DYNAMIC_IMPORT_CALLBACK_MISSING,
|
||||||
} = require('internal/errors').codes;
|
} = require('internal/errors').codes;
|
||||||
const assert = require('internal/assert');
|
|
||||||
const { Loader } = require('internal/modules/esm/loader');
|
const { Loader } = require('internal/modules/esm/loader');
|
||||||
const {
|
const {
|
||||||
hasUncaughtExceptionCaptureCallback,
|
hasUncaughtExceptionCaptureCallback,
|
||||||
|
|
@ -26,13 +25,6 @@ exports.initializeImportMetaObject = function(wrap, meta) {
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.importModuleDynamicallyCallback = async function(wrap, specifier) {
|
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');
|
const { callbackMap } = internalBinding('module_wrap');
|
||||||
if (callbackMap.has(wrap)) {
|
if (callbackMap.has(wrap)) {
|
||||||
const { importModuleDynamically } = callbackMap.get(wrap);
|
const { importModuleDynamically } = callbackMap.get(wrap);
|
||||||
|
|
@ -47,15 +39,7 @@ exports.importModuleDynamicallyCallback = async function(wrap, specifier) {
|
||||||
let ESMLoader = new Loader();
|
let ESMLoader = new Loader();
|
||||||
exports.ESMLoader = ESMLoader;
|
exports.ESMLoader = ESMLoader;
|
||||||
|
|
||||||
let calledInitialize = false;
|
async function initializeLoader() {
|
||||||
async function initializeLoader(emitWarning) {
|
|
||||||
assert(calledInitialize === false);
|
|
||||||
if (emitWarning) {
|
|
||||||
process.emitWarning(
|
|
||||||
'The ESM module loader is experimental.',
|
|
||||||
'ExperimentalWarning', undefined);
|
|
||||||
}
|
|
||||||
calledInitialize = true;
|
|
||||||
if (!userLoader)
|
if (!userLoader)
|
||||||
return;
|
return;
|
||||||
let cwd;
|
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 {
|
try {
|
||||||
await initializeLoader(emitWarning);
|
await initializeLoader();
|
||||||
await callback(ESMLoader);
|
await callback(ESMLoader);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
if (hasUncaughtExceptionCaptureCallback()) {
|
if (hasUncaughtExceptionCaptureCallback()) {
|
||||||
|
|
|
||||||
|
|
@ -38,9 +38,6 @@ function expectFsNamespace(result) {
|
||||||
// For direct use of import expressions inside of CJS or ES modules, including
|
// For direct use of import expressions inside of CJS or ES modules, including
|
||||||
// via eval, all kinds of specifiers should work without issue.
|
// via eval, all kinds of specifiers should work without issue.
|
||||||
(function testScriptOrModuleImport() {
|
(function testScriptOrModuleImport() {
|
||||||
common.expectWarning('ExperimentalWarning',
|
|
||||||
'The ESM module loader is experimental.');
|
|
||||||
|
|
||||||
// Importing another file, both direct & via eval
|
// Importing another file, both direct & via eval
|
||||||
// expectOkNamespace(import(relativePath));
|
// expectOkNamespace(import(relativePath));
|
||||||
expectOkNamespace(eval(`import("${relativePath}")`));
|
expectOkNamespace(eval(`import("${relativePath}")`));
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ child.stderr.on('data', (data) => {
|
||||||
child.on('close', (code, signal) => {
|
child.on('close', (code, signal) => {
|
||||||
strictEqual(code, 0);
|
strictEqual(code, 0);
|
||||||
strictEqual(signal, null);
|
strictEqual(signal, null);
|
||||||
ok(stderr.toString().includes(
|
ok(!stderr.toString().includes(
|
||||||
'ExperimentalWarning: The ESM module loader is experimental'
|
'ExperimentalWarning: The ESM module loader is experimental'
|
||||||
));
|
));
|
||||||
ok(!stderr.toString().includes(
|
ok(!stderr.toString().includes(
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,3 @@
|
||||||
(node:*) ExperimentalWarning: The ESM module loader is experimental.
|
|
||||||
Error: test
|
Error: test
|
||||||
at one (*fixtures*async-error.js:4:9)
|
at one (*fixtures*async-error.js:4:9)
|
||||||
at two (*fixtures*async-error.js:17:9)
|
at two (*fixtures*async-error.js:17:9)
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,3 @@
|
||||||
(node:*) ExperimentalWarning: The ESM module loader is experimental.
|
|
||||||
file:///*/test/message/esm_display_syntax_error.mjs:2
|
file:///*/test/message/esm_display_syntax_error.mjs:2
|
||||||
await async () => 0;
|
await async () => 0;
|
||||||
^^^^^
|
^^^^^
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,3 @@
|
||||||
(node:*) ExperimentalWarning: The ESM module loader is experimental.
|
|
||||||
file:///*/test/message/esm_display_syntax_error_import.mjs:5
|
file:///*/test/message/esm_display_syntax_error_import.mjs:5
|
||||||
notfound
|
notfound
|
||||||
^^^^^^^^
|
^^^^^^^^
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,3 @@
|
||||||
(node:*) ExperimentalWarning: The ESM module loader is experimental.
|
|
||||||
file:///*/test/fixtures/es-module-loaders/syntax-error-import.mjs:1
|
file:///*/test/fixtures/es-module-loaders/syntax-error-import.mjs:1
|
||||||
import { foo, notfound } from './module-named-exports.mjs';
|
import { foo, notfound } from './module-named-exports.mjs';
|
||||||
^^^^^^^^
|
^^^^^^^^
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,3 @@
|
||||||
(node:*) ExperimentalWarning: The ESM module loader is experimental.
|
|
||||||
file:///*/test/fixtures/es-module-loaders/syntax-error.mjs:2
|
file:///*/test/fixtures/es-module-loaders/syntax-error.mjs:2
|
||||||
await async () => 0;
|
await async () => 0;
|
||||||
^^^^^
|
^^^^^
|
||||||
|
|
|
||||||
|
|
@ -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
|
(node:*) ExperimentalWarning: --experimental-loader is an experimental feature. This feature could change at any time
|
||||||
internal/process/esm_loader.js:*
|
internal/process/esm_loader.js:*
|
||||||
internalBinding('errors').triggerUncaughtException(
|
internalBinding('errors').triggerUncaughtException(
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,3 @@
|
||||||
(node:*) ExperimentalWarning: The ESM module loader is experimental.
|
|
||||||
internal/process/esm_loader.js:*
|
internal/process/esm_loader.js:*
|
||||||
internalBinding('errors').triggerUncaughtException(
|
internalBinding('errors').triggerUncaughtException(
|
||||||
^
|
^
|
||||||
|
|
|
||||||
|
|
@ -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
|
(node:*) ExperimentalWarning: --experimental-loader is an experimental feature. This feature could change at any time
|
||||||
internal/process/esm_loader.js:*
|
internal/process/esm_loader.js:*
|
||||||
internalBinding('errors').triggerUncaughtException(
|
internalBinding('errors').triggerUncaughtException(
|
||||||
|
|
|
||||||
|
|
@ -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
|
(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
|
file://*/test/fixtures/es-module-loaders/syntax-error.mjs:2
|
||||||
await async () => 0;
|
await async () => 0;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user