module: runtime deprecate subpath folder mappings

PR-URL: https://github.com/nodejs/node/pull/37215
Reviewed-By: Guy Bedford <guybedford@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Myles Borins <myles.borins@gmail.com>
This commit is contained in:
Antoine du Hamel 2021-02-03 18:55:15 +01:00
parent d4693ff430
commit 3cc9aec988
4 changed files with 15 additions and 27 deletions

View File

@ -2697,24 +2697,22 @@ Use `fs.rm(path, { recursive: true, force: true })`,
### DEP0148: Folder mappings in `"exports"` (trailing `"/"`)
<!-- YAML
changes:
- version: REPLACEME
pr-url: https://github.com/nodejs/node/pull/37215
description: Runtime deprecation.
- version: v15.1.0
pr-url: https://github.com/nodejs/node/pull/35747
description: Runtime deprecation.
description: Runtime deprecation for self-referencing imports.
- version: v14.13.0
pr-url: https://github.com/nodejs/node/pull/34718
description: Documentation-only deprecation.
-->
Type: Runtime (supports [`--pending-deprecation`][])
Type: Runtime
Prior to [subpath patterns][] support, it was possible to define
Using a trailing `"/"` to define
[subpath folder mappings][] in the [subpath exports][] or
[subpath imports][] fields using a trailing `"/"`.
Without `--pending-deprecation`, runtime warnings occur only for exports
resolutions not in `node_modules`. This means there will not be deprecation
warnings for `"exports"` in dependencies. With `--pending-deprecation`, a
runtime warning results no matter where the `"exports"` usage occurs.
[subpath imports][] fields is deprecated. Use [subpath patterns][] instead.
### DEP0149: `http.IncomingMessage#connection`
<!-- YAML

View File

@ -386,9 +386,12 @@ targets, this expansion is dependent on only the files of the package itself.
### Subpath folder mappings
<!-- YAML
changes:
- version: v15.1.0
pr-url: https://github.com/nodejs/node/pull/35746
- version: REPLACEME
pr-url: https://github.com/nodejs/node/pull/37215
description: Runtime deprecation.
- version: v15.1.0
pr-url: https://github.com/nodejs/node/pull/35747
description: Runtime deprecation for self-referencing imports.
- version:
- v14.13.0
- v12.20.0

View File

@ -16,7 +16,6 @@ const {
String,
StringPrototypeEndsWith,
StringPrototypeIndexOf,
StringPrototypeLastIndexOf,
StringPrototypeReplace,
StringPrototypeSlice,
StringPrototypeSplit,
@ -60,23 +59,10 @@ const userConditions = getOptionValue('--conditions');
const DEFAULT_CONDITIONS = ObjectFreeze(['node', 'import', ...userConditions]);
const DEFAULT_CONDITIONS_SET = new SafeSet(DEFAULT_CONDITIONS);
const pendingDeprecation = getOptionValue('--pending-deprecation');
const emittedPackageWarnings = new SafeSet();
function emitFolderMapDeprecation(match, pjsonUrl, isExports, base) {
const pjsonPath = fileURLToPath(pjsonUrl);
if (!pendingDeprecation) {
const nodeModulesIndex =
StringPrototypeLastIndexOf(pjsonPath, sep + 'node_modules' + sep);
if (nodeModulesIndex !== -1) {
const afterNodeModulesPath =
StringPrototypeSlice(pjsonPath, nodeModulesIndex + 14, -13);
try {
const { packageSubpath } = parsePackageName(afterNodeModulesPath);
if (packageSubpath === '.')
return;
} catch {}
}
}
if (emittedPackageWarnings.has(pjsonPath + '|' + match))
return;
emittedPackageWarnings.add(pjsonPath + '|' + match);

View File

@ -11,7 +11,8 @@ const deprecatedFoldersIgnore =
const expectedWarnings = [
'"./" in the "exports" field',
'"#self/" in the "imports" field'
'"#self/" in the "imports" field',
'"./folder/" in the "exports" field',
];
process.addListener('warning', (warning) => {