Skip to content

Commit ea46905

Browse files
committed
module: runtime deprecate subpath folder mappings
1 parent eaf0f0f commit ea46905

File tree

4 files changed

+15
-27
lines changed

4 files changed

+15
-27
lines changed

doc/api/deprecations.md

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2694,24 +2694,22 @@ Use `fs.rm(path, { recursive: true, force: true })`,
26942694
### DEP0148: Folder mappings in `"exports"` (trailing `"/"`)
26952695
<!-- YAML
26962696
changes:
2697+
- version: REPLACEME
2698+
pr-url: https://github.com/nodejs/node/pull/37215
2699+
description: Runtime deprecation.
26972700
- version: v15.1.0
26982701
pr-url: https://github.com/nodejs/node/pull/35747
2699-
description: Runtime deprecation.
2702+
description: Runtime deprecation for self-referencing imports.
27002703
- version: v14.13.0
27012704
pr-url: https://github.com/nodejs/node/pull/34718
27022705
description: Documentation-only deprecation.
27032706
-->
27042707

2705-
Type: Runtime (supports [`--pending-deprecation`][])
2708+
Type: Runtime
27062709

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

27162714
### DEP0149: `http.IncomingMessage#connection`
27172715
<!-- YAML

doc/api/packages.md

Lines changed: 5 additions & 2 deletions
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

Lines changed: 1 addition & 15 deletions
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

Lines changed: 2 additions & 1 deletion
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)