diff options
author | Ruben Bridgewater <ruben@bridgewater.de> | 2019-03-20 17:00:57 +0100 |
---|---|---|
committer | Ruben Bridgewater <ruben@bridgewater.de> | 2019-03-27 17:11:53 +0100 |
commit | 115f0f5a57f50f6b039f28a56910207f92df116d (patch) | |
tree | b8937769e8c49b2a51b4ed7772e6bafc2657a14a /test/parallel/test-module-loading-deprecated.js | |
parent | 7bddfcc61a5a7d04583a8c4fec462ca5ce45b677 (diff) | |
download | android-node-v8-115f0f5a57f50f6b039f28a56910207f92df116d.tar.gz android-node-v8-115f0f5a57f50f6b039f28a56910207f92df116d.tar.bz2 android-node-v8-115f0f5a57f50f6b039f28a56910207f92df116d.zip |
module: throw an error for invalid package.json main entries
We currently ignore invalid `main` entries in package.json files.
This does not seem to be very user friendly as it's certainly an
error if the `main` entry is not a valid file name. So instead of
trying to resolve the file otherwise, throw an error immediately to
improve the user experience.
To keep it backwards compatible `index.js` files in the same directory
as the `package.json` will continue to be resolved instead but that
behavior is now deprecated.
PR-URL: https://github.com/nodejs/node/pull/26823
Fixes: https://github.com/nodejs/node/issues/26588
Reviewed-By: Guy Bedford <guybedford@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Diffstat (limited to 'test/parallel/test-module-loading-deprecated.js')
-rw-r--r-- | test/parallel/test-module-loading-deprecated.js | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/test/parallel/test-module-loading-deprecated.js b/test/parallel/test-module-loading-deprecated.js new file mode 100644 index 0000000000..3aa81eea6e --- /dev/null +++ b/test/parallel/test-module-loading-deprecated.js @@ -0,0 +1,12 @@ +// Flags: --pending-deprecation + +'use strict'; + +const common = require('../common'); +const assert = require('assert'); + +common.expectWarning('DeprecationWarning', { + DEP0128: /^Invalid 'main' field in '.+main[/\\]package\.json' of 'doesnotexist\.js'\..+module author/ +}); + +assert.strictEqual(require('../fixtures/packages/missing-main').ok, 'ok'); |