Skip to content

Commit 3cc9aec

Browse files
committed
module: runtime deprecate subpath folder mappings
PR-URL: #37215 Reviewed-By: Guy Bedford <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Myles Borins <[email protected]>
1 parent d4693ff commit 3cc9aec

File tree

4 files changed

+15
-27
lines changed

4 files changed

+15
-27
lines changed

doc/api/deprecations.md

+7-9
Original file line numberDiff line numberDiff line change
@@ -2697,24 +2697,22 @@ Use `fs.rm(path, { recursive: true, force: true })`,
26972697
### DEP0148: Folder mappings in `"exports"` (trailing `"/"`)
26982698
<!-- YAML
26992699
changes:
2700+
- version: REPLACEME
2701+
pr-url: https://github.com./nodejs/node/pull/37215
2702+
description: Runtime deprecation.
27002703
- version: v15.1.0
27012704
pr-url: https://github.com./nodejs/node/pull/35747
2702-
description: Runtime deprecation.
2705+
description: Runtime deprecation for self-referencing imports.
27032706
- version: v14.13.0
27042707
pr-url: https://github.com./nodejs/node/pull/34718
27052708
description: Documentation-only deprecation.
27062709
-->
27072710

2708-
Type: Runtime (supports [`--pending-deprecation`][])
2711+
Type: Runtime
27092712

2710-
Prior to [subpath patterns][] support, it was possible to define
2713+
Using a trailing `"/"` to define
27112714
[subpath folder mappings][] in the [subpath exports][] or
2712-
[subpath imports][] fields using a trailing `"/"`.
2713-
2714-
Without `--pending-deprecation`, runtime warnings occur only for exports
2715-
resolutions not in `node_modules`. This means there will not be deprecation
2716-
warnings for `"exports"` in dependencies. With `--pending-deprecation`, a
2717-
runtime warning results no matter where the `"exports"` usage occurs.
2715+
[subpath imports][] fields is deprecated. Use [subpath patterns][] instead.
27182716

27192717
### DEP0149: `http.IncomingMessage#connection`
27202718
<!-- YAML

doc/api/packages.md

+5-2
Original file line numberDiff line numberDiff line change
@@ -386,9 +386,12 @@ targets, this expansion is dependent on only the files of the package itself.
386386
### Subpath folder mappings
387387
<!-- YAML
388388
changes:
389-
- version: v15.1.0
390-
pr-url: https://github.com./nodejs/node/pull/35746
389+
- version: REPLACEME
390+
pr-url: https://github.com./nodejs/node/pull/37215
391391
description: Runtime deprecation.
392+
- version: v15.1.0
393+
pr-url: https://github.com./nodejs/node/pull/35747
394+
description: Runtime deprecation for self-referencing imports.
392395
- version:
393396
- v14.13.0
394397
- v12.20.0

lib/internal/modules/esm/resolve.js

+1-15
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ const {
1616
String,
1717
StringPrototypeEndsWith,
1818
StringPrototypeIndexOf,
19-
StringPrototypeLastIndexOf,
2019
StringPrototypeReplace,
2120
StringPrototypeSlice,
2221
StringPrototypeSplit,
@@ -60,23 +59,10 @@ const userConditions = getOptionValue('--conditions');
6059
const DEFAULT_CONDITIONS = ObjectFreeze(['node', 'import', ...userConditions]);
6160
const DEFAULT_CONDITIONS_SET = new SafeSet(DEFAULT_CONDITIONS);
6261

63-
const pendingDeprecation = getOptionValue('--pending-deprecation');
6462
const emittedPackageWarnings = new SafeSet();
6563
function emitFolderMapDeprecation(match, pjsonUrl, isExports, base) {
6664
const pjsonPath = fileURLToPath(pjsonUrl);
67-
if (!pendingDeprecation) {
68-
const nodeModulesIndex =
69-
StringPrototypeLastIndexOf(pjsonPath, sep + 'node_modules' + sep);
70-
if (nodeModulesIndex !== -1) {
71-
const afterNodeModulesPath =
72-
StringPrototypeSlice(pjsonPath, nodeModulesIndex + 14, -13);
73-
try {
74-
const { packageSubpath } = parsePackageName(afterNodeModulesPath);
75-
if (packageSubpath === '.')
76-
return;
77-
} catch {}
78-
}
79-
}
65+
8066
if (emittedPackageWarnings.has(pjsonPath + '|' + match))
8167
return;
8268
emittedPackageWarnings.add(pjsonPath + '|' + match);

test/es-module/test-esm-local-deprecations.mjs

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ const deprecatedFoldersIgnore =
1111

1212
const expectedWarnings = [
1313
'"./" in the "exports" field',
14-
'"#self/" in the "imports" field'
14+
'"#self/" in the "imports" field',
15+
'"./folder/" in the "exports" field',
1516
];
1617

1718
process.addListener('warning', (warning) => {

0 commit comments

Comments
 (0)