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

module: disable conditional exports, self resolve warnings #31845

Closed
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 1 addition & 3 deletions lib/internal/modules/cjs/loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const {
rekeySourceMap
} = require('internal/source_map/source_map_cache');
const { pathToFileURL, fileURLToPath, URL } = require('internal/url');
const { deprecate, emitExperimentalWarning } = require('internal/util');
const { deprecate } = require('internal/util');
const vm = require('vm');
const assert = require('internal/assert');
const fs = require('fs');
Expand Down Expand Up @@ -614,7 +614,6 @@ function resolveExportsTarget(baseUrl, target, subpath, mappingKey) {
case 'node':
case 'require':
try {
emitExperimentalWarning('Conditional exports');
return resolveExportsTarget(baseUrl, target[p], subpath,
mappingKey);
} catch (e) {
Expand Down Expand Up @@ -1008,7 +1007,6 @@ Module._resolveFilename = function(request, parent, isMain, options) {
if (parent && parent.filename) {
const filename = trySelf(parent.filename, isMain, request);
if (filename) {
emitExperimentalWarning('Package name self resolution');
const cacheKey = request + '\x00' +
(paths.length === 1 ? paths[0] : paths.join('\x00'));
Module._pathCache[cacheKey] = filename;
Expand Down
2 changes: 1 addition & 1 deletion lib/internal/modules/esm/loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
const {
FunctionPrototypeBind,
ObjectSetPrototypeOf,
SafeMap,
SafeMap
guybedford marked this conversation as resolved.
Show resolved Hide resolved
} = primordials;

const {
Expand Down
10 changes: 1 addition & 9 deletions lib/internal/process/esm_loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,7 @@ 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;
}
calledInitialize = true;
const { callbackMap } = internalBinding('module_wrap');
if (callbackMap.has(wrap)) {
const { importModuleDynamically } = callbackMap.get(wrap);
Expand All @@ -48,9 +43,6 @@ let calledInitialize = false;
exports.initializeLoader = initializeLoader;
async function initializeLoader() {
assert(calledInitialize === false);
process.emitWarning(
'The ESM module loader is experimental.',
'ExperimentalWarning', undefined);
calledInitialize = true;
if (!userLoader)
return;
Expand Down
3 changes: 0 additions & 3 deletions src/module_wrap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1073,7 +1073,6 @@ Maybe<URL> ResolveExportsTarget(Environment* env,
return Nothing<URL>();
}
CHECK(!try_catch.HasCaught());
ProcessEmitExperimentalWarning(env, "Conditional exports");
return resolved;
}
} else if (key_str == "default") {
Expand All @@ -1094,7 +1093,6 @@ Maybe<URL> ResolveExportsTarget(Environment* env,
return Nothing<URL>();
}
CHECK(!try_catch.HasCaught());
ProcessEmitExperimentalWarning(env, "Conditional exports");
return resolved;
}
}
Expand Down Expand Up @@ -1310,7 +1308,6 @@ Maybe<URL> PackageResolve(Environment* env,
}
}
if (found_pjson && pcfg->name == pkg_name && !pcfg->exports.IsEmpty()) {
ProcessEmitExperimentalWarning(env, "Package name self resolution");
if (pkg_subpath == "./") {
return Just(URL("./", pjson_url));
} else if (!pkg_subpath.length()) {
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 @@ -42,9 +42,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
25 changes: 25 additions & 0 deletions test/es-module/test-esm-nowarn-exports.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import '../common/index.mjs';
import { path } from '../common/fixtures.mjs';
import { strictEqual, ok } from 'assert';
import { spawn } from 'child_process';

const child = spawn(process.execPath, [
'--experimental-import-meta-resolve',
path('/es-modules/import-resolve-exports.mjs')
]);

let stderr = '';
child.stderr.setEncoding('utf8');
child.stderr.on('data', (data) => {
stderr += data;
});
child.on('close', (code, signal) => {
strictEqual(code, 0);
strictEqual(signal, null);
ok(!stderr.toString().includes(
'ExperimentalWarning: The ESM module loader is experimental'
));
ok(!stderr.toString().includes(
'ExperimentalWarning: Conditional exports'
));
});
10 changes: 10 additions & 0 deletions test/fixtures/es-modules/import-resolve-exports.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { strictEqual } from 'assert';

(async () => {
const resolved = await import.meta.resolve('pkgexports-sugar');
strictEqual(typeof resolved, 'string');
})()
.catch((e) => {
console.error(e);
process.exit(1);
});
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/modules/esm/resolve.js:*
let url = moduleWrapResolve(specifier, parentURL);
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