From bb9e91f2ffd831e256f57bc1a704fe718ae30b4a Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Wed, 3 Feb 2021 14:19:24 +0100 Subject: [PATCH 1/2] modules: runtime deprecate invalid package.json main entries --- doc/api/deprecations.md | 5 ++++- lib/internal/modules/cjs/loader.js | 2 +- test/parallel/test-module-loading-deprecated.js | 2 -- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/doc/api/deprecations.md b/doc/api/deprecations.md index 92203b8112f416..ee6f057005ac89 100644 --- a/doc/api/deprecations.md +++ b/doc/api/deprecations.md @@ -2347,12 +2347,15 @@ with no performance impact since Node.js 10. ### DEP0128: modules with an invalid `main` entry and an `index.js` file -Type: Documentation-only (supports [`--pending-deprecation`][]) +Type: Runtime Modules that have an invalid `main` entry (e.g., `./does-not-exist.js`) and also have an `index.js` file in the top level directory will resolve the diff --git a/lib/internal/modules/cjs/loader.js b/lib/internal/modules/cjs/loader.js index 0c69d547d40b9a..4cbaea4a743b86 100644 --- a/lib/internal/modules/cjs/loader.js +++ b/lib/internal/modules/cjs/loader.js @@ -350,7 +350,7 @@ function tryPackage(requestPath, exts, isMain, originalPath) { err.requestPath = originalPath; // TODO(BridgeAR): Add the requireStack as well. throw err; - } else if (pendingDeprecation) { + } else { const jsonPath = path.resolve(requestPath, 'package.json'); process.emitWarning( `Invalid 'main' field in '${jsonPath}' of '${pkg}'. ` + diff --git a/test/parallel/test-module-loading-deprecated.js b/test/parallel/test-module-loading-deprecated.js index 3aa81eea6e906a..3b43284aec762d 100644 --- a/test/parallel/test-module-loading-deprecated.js +++ b/test/parallel/test-module-loading-deprecated.js @@ -1,5 +1,3 @@ -// Flags: --pending-deprecation - 'use strict'; const common = require('../common'); From 62449e7016a7168f707139459854f85f11756ee9 Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Wed, 3 Feb 2021 15:51:17 +0100 Subject: [PATCH 2/2] fixup! modules: runtime deprecate invalid package.json main entries --- doc/api/deprecations.md | 2 +- test/sequential/test-module-loading.js | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/doc/api/deprecations.md b/doc/api/deprecations.md index ee6f057005ac89..29e5703e51ff60 100644 --- a/doc/api/deprecations.md +++ b/doc/api/deprecations.md @@ -2348,7 +2348,7 @@ with no performance impact since Node.js 10.