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:
parent
d4693ff430
commit
3cc9aec988
@ -2697,24 +2697,22 @@ Use `fs.rm(path, { recursive: true, force: true })`,
|
|||||||
### DEP0148: Folder mappings in `"exports"` (trailing `"/"`)
|
### DEP0148: Folder mappings in `"exports"` (trailing `"/"`)
|
||||||
<!-- YAML
|
<!-- YAML
|
||||||
changes:
|
changes:
|
||||||
|
- version: REPLACEME
|
||||||
|
pr-url: https://github.com/nodejs/node/pull/37215
|
||||||
|
description: Runtime deprecation.
|
||||||
- version: v15.1.0
|
- version: v15.1.0
|
||||||
pr-url: https://github.com/nodejs/node/pull/35747
|
pr-url: https://github.com/nodejs/node/pull/35747
|
||||||
description: Runtime deprecation.
|
description: Runtime deprecation for self-referencing imports.
|
||||||
- version: v14.13.0
|
- version: v14.13.0
|
||||||
pr-url: https://github.com/nodejs/node/pull/34718
|
pr-url: https://github.com/nodejs/node/pull/34718
|
||||||
description: Documentation-only deprecation.
|
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 folder mappings][] in the [subpath exports][] or
|
||||||
[subpath imports][] fields using a trailing `"/"`.
|
[subpath imports][] fields is deprecated. Use [subpath patterns][] instead.
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
||||||
### DEP0149: `http.IncomingMessage#connection`
|
### DEP0149: `http.IncomingMessage#connection`
|
||||||
<!-- YAML
|
<!-- YAML
|
||||||
|
@ -386,9 +386,12 @@ targets, this expansion is dependent on only the files of the package itself.
|
|||||||
### Subpath folder mappings
|
### Subpath folder mappings
|
||||||
<!-- YAML
|
<!-- YAML
|
||||||
changes:
|
changes:
|
||||||
- version: v15.1.0
|
- version: REPLACEME
|
||||||
pr-url: https://github.com/nodejs/node/pull/35746
|
pr-url: https://github.com/nodejs/node/pull/37215
|
||||||
description: Runtime deprecation.
|
description: Runtime deprecation.
|
||||||
|
- version: v15.1.0
|
||||||
|
pr-url: https://github.com/nodejs/node/pull/35747
|
||||||
|
description: Runtime deprecation for self-referencing imports.
|
||||||
- version:
|
- version:
|
||||||
- v14.13.0
|
- v14.13.0
|
||||||
- v12.20.0
|
- v12.20.0
|
||||||
|
@ -16,7 +16,6 @@ const {
|
|||||||
String,
|
String,
|
||||||
StringPrototypeEndsWith,
|
StringPrototypeEndsWith,
|
||||||
StringPrototypeIndexOf,
|
StringPrototypeIndexOf,
|
||||||
StringPrototypeLastIndexOf,
|
|
||||||
StringPrototypeReplace,
|
StringPrototypeReplace,
|
||||||
StringPrototypeSlice,
|
StringPrototypeSlice,
|
||||||
StringPrototypeSplit,
|
StringPrototypeSplit,
|
||||||
@ -60,23 +59,10 @@ const userConditions = getOptionValue('--conditions');
|
|||||||
const DEFAULT_CONDITIONS = ObjectFreeze(['node', 'import', ...userConditions]);
|
const DEFAULT_CONDITIONS = ObjectFreeze(['node', 'import', ...userConditions]);
|
||||||
const DEFAULT_CONDITIONS_SET = new SafeSet(DEFAULT_CONDITIONS);
|
const DEFAULT_CONDITIONS_SET = new SafeSet(DEFAULT_CONDITIONS);
|
||||||
|
|
||||||
const pendingDeprecation = getOptionValue('--pending-deprecation');
|
|
||||||
const emittedPackageWarnings = new SafeSet();
|
const emittedPackageWarnings = new SafeSet();
|
||||||
function emitFolderMapDeprecation(match, pjsonUrl, isExports, base) {
|
function emitFolderMapDeprecation(match, pjsonUrl, isExports, base) {
|
||||||
const pjsonPath = fileURLToPath(pjsonUrl);
|
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))
|
if (emittedPackageWarnings.has(pjsonPath + '|' + match))
|
||||||
return;
|
return;
|
||||||
emittedPackageWarnings.add(pjsonPath + '|' + match);
|
emittedPackageWarnings.add(pjsonPath + '|' + match);
|
||||||
|
@ -11,7 +11,8 @@ const deprecatedFoldersIgnore =
|
|||||||
|
|
||||||
const expectedWarnings = [
|
const expectedWarnings = [
|
||||||
'"./" in the "exports" field',
|
'"./" in the "exports" field',
|
||||||
'"#self/" in the "imports" field'
|
'"#self/" in the "imports" field',
|
||||||
|
'"./folder/" in the "exports" field',
|
||||||
];
|
];
|
||||||
|
|
||||||
process.addListener('warning', (warning) => {
|
process.addListener('warning', (warning) => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user