Skip to content

Commit 0ce99ad

Browse files
committed
module: disable conditional exports, self resolve warnings
1 parent 58de9b4 commit 0ce99ad

14 files changed

+38
-26
lines changed

lib/internal/modules/cjs/loader.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ const {
5151
rekeySourceMap
5252
} = require('internal/source_map/source_map_cache');
5353
const { pathToFileURL, fileURLToPath, URL } = require('internal/url');
54-
const { deprecate, emitExperimentalWarning } = require('internal/util');
54+
const { deprecate } = require('internal/util');
5555
const vm = require('vm');
5656
const assert = require('internal/assert');
5757
const fs = require('fs');
@@ -614,7 +614,6 @@ function resolveExportsTarget(baseUrl, target, subpath, mappingKey) {
614614
case 'node':
615615
case 'require':
616616
try {
617-
emitExperimentalWarning('Conditional exports');
618617
return resolveExportsTarget(baseUrl, target[p], subpath,
619618
mappingKey);
620619
} catch (e) {
@@ -1008,7 +1007,6 @@ Module._resolveFilename = function(request, parent, isMain, options) {
10081007
if (parent && parent.filename) {
10091008
const filename = trySelf(parent.filename, isMain, request);
10101009
if (filename) {
1011-
emitExperimentalWarning('Package name self resolution');
10121010
const cacheKey = request + '\x00' +
10131011
(paths.length === 1 ? paths[0] : paths.join('\x00'));
10141012
Module._pathCache[cacheKey] = filename;

lib/internal/modules/esm/loader.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
const {
44
FunctionPrototypeBind,
55
ObjectSetPrototypeOf,
6-
SafeMap,
6+
SafeMap
77
} = primordials;
88

99
const {

lib/internal/process/esm_loader.js

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,7 @@ exports.initializeImportMetaObject = function(wrap, meta) {
2424

2525
exports.importModuleDynamicallyCallback = async function(wrap, specifier) {
2626
assert(calledInitialize === true || !userLoader);
27-
if (!calledInitialize) {
28-
process.emitWarning(
29-
'The ESM module loader is experimental.',
30-
'ExperimentalWarning', undefined);
31-
calledInitialize = true;
32-
}
27+
calledInitialize = true;
3328
const { callbackMap } = internalBinding('module_wrap');
3429
if (callbackMap.has(wrap)) {
3530
const { importModuleDynamically } = callbackMap.get(wrap);
@@ -48,9 +43,6 @@ let calledInitialize = false;
4843
exports.initializeLoader = initializeLoader;
4944
async function initializeLoader() {
5045
assert(calledInitialize === false);
51-
process.emitWarning(
52-
'The ESM module loader is experimental.',
53-
'ExperimentalWarning', undefined);
5446
calledInitialize = true;
5547
if (!userLoader)
5648
return;

src/module_wrap.cc

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1073,7 +1073,6 @@ Maybe<URL> ResolveExportsTarget(Environment* env,
10731073
return Nothing<URL>();
10741074
}
10751075
CHECK(!try_catch.HasCaught());
1076-
ProcessEmitExperimentalWarning(env, "Conditional exports");
10771076
return resolved;
10781077
}
10791078
} else if (key_str == "default") {
@@ -1094,7 +1093,6 @@ Maybe<URL> ResolveExportsTarget(Environment* env,
10941093
return Nothing<URL>();
10951094
}
10961095
CHECK(!try_catch.HasCaught());
1097-
ProcessEmitExperimentalWarning(env, "Conditional exports");
10981096
return resolved;
10991097
}
11001098
}
@@ -1310,7 +1308,6 @@ Maybe<URL> PackageResolve(Environment* env,
13101308
}
13111309
}
13121310
if (found_pjson && pcfg->name == pkg_name && !pcfg->exports.IsEmpty()) {
1313-
ProcessEmitExperimentalWarning(env, "Package name self resolution");
13141311
if (pkg_subpath == "./") {
13151312
return Just(URL("./", pjson_url));
13161313
} else if (!pkg_subpath.length()) {

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,6 @@ function expectFsNamespace(result) {
4242
// For direct use of import expressions inside of CJS or ES modules, including
4343
// via eval, all kinds of specifiers should work without issue.
4444
(function testScriptOrModuleImport() {
45-
common.expectWarning('ExperimentalWarning',
46-
'The ESM module loader is experimental.');
47-
4845
// Importing another file, both direct & via eval
4946
// expectOkNamespace(import(relativePath));
5047
expectOkNamespace(eval(`import("${relativePath}")`));
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import '../common/index.mjs';
2+
import { path } from '../common/fixtures.mjs';
3+
import { strictEqual, ok } from 'assert';
4+
import { spawn } from 'child_process';
5+
6+
const child = spawn(process.execPath, [
7+
'--experimental-import-meta-resolve',
8+
path('/es-modules/import-resolve-exports.mjs')
9+
]);
10+
11+
let stderr = '';
12+
child.stderr.setEncoding('utf8');
13+
child.stderr.on('data', (data) => {
14+
stderr += data;
15+
});
16+
child.on('close', (code, signal) => {
17+
strictEqual(code, 0);
18+
strictEqual(signal, null);
19+
ok(!stderr.toString().includes(
20+
'ExperimentalWarning: The ESM module loader is experimental'
21+
));
22+
ok(!stderr.toString().includes(
23+
'ExperimentalWarning: Conditional exports'
24+
));
25+
});
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { strictEqual } from 'assert';
2+
3+
(async () => {
4+
const resolved = await import.meta.resolve('pkgexports-sugar');
5+
strictEqual(typeof resolved, 'string');
6+
})()
7+
.catch((e) => {
8+
console.error(e);
9+
process.exit(1);
10+
});

test/message/async_error_sync_esm.out

Lines changed: 0 additions & 1 deletion
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

Lines changed: 0 additions & 1 deletion
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

Lines changed: 0 additions & 1 deletion
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

Lines changed: 0 additions & 1 deletion
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

Lines changed: 0 additions & 1 deletion
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

Lines changed: 0 additions & 1 deletion
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/modules/esm/resolve.js:*
43
let url = moduleWrapResolve(specifier, parentURL);

test/message/esm_loader_syntax_error.out

Lines changed: 0 additions & 1 deletion
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)