Skip to content

Commit ecddf65

Browse files
guybedfordtargos
authored andcommittedApr 21, 2020
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> Backport-PR-URL: #32959 Reviewed-By: Michaël Zasso <targos@protonmail.com>
1 parent 0108148 commit ecddf65

File tree

4 files changed

+38
-6
lines changed

4 files changed

+38
-6
lines changed
 

‎lib/internal/modules/cjs/loader.js

+1-3
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

-3
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()) {
+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// Flags: --experimental-modules
2+
import '../common/index.mjs';
3+
import { path } from '../common/fixtures.mjs';
4+
import { strictEqual, ok } from 'assert';
5+
import { spawn } from 'child_process';
6+
7+
const child = spawn(process.execPath, [
8+
'--experimental-modules',
9+
'--experimental-import-meta-resolve',
10+
path('/es-modules/import-resolve-exports.mjs')
11+
]);
12+
13+
let stderr = '';
14+
child.stderr.setEncoding('utf8');
15+
child.stderr.on('data', (data) => {
16+
stderr += data;
17+
});
18+
child.on('close', (code, signal) => {
19+
strictEqual(code, 0);
20+
strictEqual(signal, null);
21+
ok(stderr.toString().includes(
22+
'ExperimentalWarning: The ESM module loader is experimental'
23+
));
24+
ok(!stderr.toString().includes(
25+
'ExperimentalWarning: Conditional exports'
26+
));
27+
});
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)
Please sign in to comment.