Skip to content

Commit 85752cd

Browse files
guybedfordtargos
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 6e68d98 commit 85752cd

File tree

4 files changed

+36
-6
lines changed

4 files changed

+36
-6
lines changed

lib/internal/modules/cjs/loader.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ const {
4949
rekeySourceMap
5050
} = require('internal/source_map/source_map_cache');
5151
const { pathToFileURL, fileURLToPath, URL } = require('internal/url');
52-
const { deprecate, emitExperimentalWarning } = require('internal/util');
52+
const { deprecate } = require('internal/util');
5353
const vm = require('vm');
5454
const assert = require('internal/assert');
5555
const fs = require('fs');
@@ -579,7 +579,6 @@ function resolveExportsTarget(baseUrl, target, subpath, mappingKey) {
579579
case 'node':
580580
case 'require':
581581
try {
582-
emitExperimentalWarning('Conditional exports');
583582
return resolveExportsTarget(baseUrl, target[p], subpath,
584583
mappingKey);
585584
} catch (e) {
@@ -934,7 +933,6 @@ Module._resolveFilename = function(request, parent, isMain, options) {
934933
if (parent && parent.filename) {
935934
const filename = trySelf(parent.filename, request);
936935
if (filename) {
937-
emitExperimentalWarning('Package name self resolution');
938936
const cacheKey = request + '\x00' +
939937
(paths.length === 1 ? paths[0] : paths.join('\x00'));
940938
Module._pathCache[cacheKey] = filename;

src/module_wrap.cc

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1047,7 +1047,6 @@ Maybe<URL> ResolveExportsTarget(Environment* env,
10471047
return Nothing<URL>();
10481048
}
10491049
CHECK(!try_catch.HasCaught());
1050-
ProcessEmitExperimentalWarning(env, "Conditional exports");
10511050
return resolved;
10521051
}
10531052
} else if (key_str == "default") {
@@ -1068,7 +1067,6 @@ Maybe<URL> ResolveExportsTarget(Environment* env,
10681067
return Nothing<URL>();
10691068
}
10701069
CHECK(!try_catch.HasCaught());
1071-
ProcessEmitExperimentalWarning(env, "Conditional exports");
10721070
return resolved;
10731071
}
10741072
}
@@ -1284,7 +1282,6 @@ Maybe<URL> PackageResolve(Environment* env,
12841282
}
12851283
}
12861284
if (found_pjson && pcfg->name == pkg_name && !pcfg->exports.IsEmpty()) {
1287-
ProcessEmitExperimentalWarning(env, "Package name self resolution");
12881285
if (pkg_subpath == "./") {
12891286
return Just(URL("./", pjson_url));
12901287
} else if (!pkg_subpath.length()) {
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+
});

0 commit comments

Comments
 (0)