Skip to content

Commit b9f3bfe

Browse files
guybedfordcodebytere
authored andcommitted
module: disable conditional exports, self resolve warnings
PR-URL: #31845 Reviewed-By: Jan Krems <jan.krems@gmail.com> Reviewed-By: Geoffrey Booth <webmaster@geoffreybooth.com>
1 parent 04eda02 commit b9f3bfe

File tree

4 files changed

+36
-6
lines changed

4 files changed

+36
-6
lines changed

lib/internal/modules/cjs/loader.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ const {
4848
rekeySourceMap
4949
} = require('internal/source_map/source_map_cache');
5050
const { pathToFileURL, fileURLToPath, URL } = require('internal/url');
51-
const { deprecate, emitExperimentalWarning } = require('internal/util');
51+
const { deprecate } = require('internal/util');
5252
const vm = require('vm');
5353
const assert = require('internal/assert');
5454
const fs = require('fs');
@@ -610,7 +610,6 @@ function resolveExportsTarget(baseUrl, target, subpath, mappingKey) {
610610
case 'node':
611611
case 'require':
612612
try {
613-
emitExperimentalWarning('Conditional exports');
614613
return resolveExportsTarget(baseUrl, target[p], subpath,
615614
mappingKey);
616615
} catch (e) {
@@ -953,7 +952,6 @@ Module._resolveFilename = function(request, parent, isMain, options) {
953952
if (parent && parent.filename) {
954953
const filename = trySelf(parent.filename, isMain, request);
955954
if (filename) {
956-
emitExperimentalWarning('Package name self resolution');
957955
const cacheKey = request + '\x00' +
958956
(paths.length === 1 ? paths[0] : paths.join('\x00'));
959957
Module._pathCache[cacheKey] = filename;

src/module_wrap.cc

-3
Original file line numberDiff line numberDiff line change
@@ -1075,7 +1075,6 @@ Maybe<URL> ResolveExportsTarget(Environment* env,
10751075
return Nothing<URL>();
10761076
}
10771077
CHECK(!try_catch.HasCaught());
1078-
ProcessEmitExperimentalWarning(env, "Conditional exports");
10791078
return resolved;
10801079
}
10811080
} else if (key_str == "default") {
@@ -1096,7 +1095,6 @@ Maybe<URL> ResolveExportsTarget(Environment* env,
10961095
return Nothing<URL>();
10971096
}
10981097
CHECK(!try_catch.HasCaught());
1099-
ProcessEmitExperimentalWarning(env, "Conditional exports");
11001098
return resolved;
11011099
}
11021100
}
@@ -1312,7 +1310,6 @@ Maybe<URL> PackageResolve(Environment* env,
13121310
}
13131311
}
13141312
if (found_pjson && pcfg->name == pkg_name && !pcfg->exports.IsEmpty()) {
1315-
ProcessEmitExperimentalWarning(env, "Package name self resolution");
13161313
if (pkg_subpath == "./") {
13171314
return Just(URL("./", pjson_url));
13181315
} else if (!pkg_subpath.length()) {
+25
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+
});
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+
});

0 commit comments

Comments
 (0)