summaryrefslogtreecommitdiff
path: root/test/sequential/test-module-loading.js
diff options
context:
space:
mode:
authorBen Noordhuis <info@bnoordhuis.nl>2017-11-09 13:26:46 +0100
committerBen Noordhuis <info@bnoordhuis.nl>2017-11-15 12:00:25 +0100
commitfdbb6dd042a560fc5d3b3ad682a13ddf506128e6 (patch)
tree9ff1cc45bc3f3e69f35d0a8826a40fddfcda1f93 /test/sequential/test-module-loading.js
parent1132ea743449f63d6b1dd09f82ec3bb6f3f402f0 (diff)
downloadandroid-node-v8-fdbb6dd042a560fc5d3b3ad682a13ddf506128e6.tar.gz
android-node-v8-fdbb6dd042a560fc5d3b3ad682a13ddf506128e6.tar.bz2
android-node-v8-fdbb6dd042a560fc5d3b3ad682a13ddf506128e6.zip
module: speed up package.json parsing
If the package.json does not contain the string '"main"', skip parsing it to JSON. Note that this changes the behavior of the module loader in the presence of package.json files that don't contain legal JSON. Such files used to throw an exception but now they are simply ignored unless they contain a "main" property. To me, that seems like a good trade-off: I observe a 25% reduction in start-up time on a medium-sized application[0]. [0] https://github.com/strongloop/sls-sample-app PR-URL: https://github.com/nodejs/node/pull/15767 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'test/sequential/test-module-loading.js')
-rw-r--r--test/sequential/test-module-loading.js8
1 files changed, 0 insertions, 8 deletions
diff --git a/test/sequential/test-module-loading.js b/test/sequential/test-module-loading.js
index 47916d352d..790331a37b 100644
--- a/test/sequential/test-module-loading.js
+++ b/test/sequential/test-module-loading.js
@@ -100,14 +100,6 @@ const d2 = require('../fixtures/b/d');
assert.notStrictEqual(threeFolder, three);
}
-console.error('test package.json require() loading');
-assert.throws(
- function() {
- require('../fixtures/packages/invalid');
- },
- /^SyntaxError: Error parsing .+: Unexpected token , in JSON at position 1$/
-);
-
assert.strictEqual(require('../fixtures/packages/index').ok, 'ok',
'Failed loading package');
assert.strictEqual(require('../fixtures/packages/main').ok, 'ok',