Skip to content

Commit 052af96

Browse files
cpojerFacebook Github Bot 6
authored andcommitted
Implement jest-haste-map instead of node-haste
Summary:This is a new haste map implementation for Jest which is much more scalable than node-haste. node-haste2 isn't well designed and not scalable for short-lived services like Jest. The startup time of node-haste1 vs. node-haste2 on www is almost the same, both between 6 and 8 seconds which is not acceptable for our engineers. This implementation is attempting to accomplish a much reduced and more scalable startup time. It also has reduced scope ? the goal of this is to only build a haste map and provide a way to resolve a one-level deep dependency tree, which is all that Jest really needs from node-haste. `jest-haste-map` can serve as an ideal basis for rewriting node-haste2 (into node-haste3!). With this, the cold start time (building the entire haste map) is now about 14 seconds on www (that's acceptable) but the incremental invocation is only 2 seconds (kyldvs will love me). I haven't heavily micro-optimized the JavaScript in `packages/jest-haste-map/src/index.js` and there is a bunch of data copying Closes #896 Reviewed By: kentaromiura Differential Revision: D3206943 fb-gh-sync-id: 247c4e15ef6dc7e0b1151b7e2539d053389bd249 fbshipit-source-id: 247c4e15ef6dc7e0b1151b7e2539d053389bd249
1 parent 9d17595 commit 052af96

47 files changed

Lines changed: 3661 additions & 456 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.eslintrc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
"arrow-spacing": [2],
1010
"babel/arrow-parens": [2, "as-needed"],
1111
"brace-style": [2, "1tbs", {"allowSingleLine": true}],
12-
"camelcase": [2, {"properties": "always"}],
1312
"comma-dangle": [2, "always-multiline"],
1413
"comma-spacing": [2],
1514
"comma-style": [2, "last"],

package.json

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@
1111
"istanbul": "^0.4.2",
1212
"jest-environment-jsdom": "^11.0.2",
1313
"jest-environment-node": "^11.0.2",
14+
"jest-haste-map": "^11.0.2",
1415
"jest-jasmine1": "^11.0.2",
1516
"jest-jasmine2": "^11.0.2",
1617
"jest-mock": "^11.0.2",
1718
"jest-util": "^11.0.2",
1819
"json-stable-stringify": "^1.0.0",
1920
"lodash.template": "^4.2.4",
2021
"mkdirp": "^0.5.1",
21-
"node-haste": "^2.5.0",
2222
"optimist": "^0.6.1",
2323
"resolve": "^1.1.6",
2424
"sane": "^1.2.0",
@@ -44,11 +44,19 @@
4444
"url": "https://github.com/facebook/jest"
4545
},
4646
"scripts": {
47-
"jasmine1": "node bin/jest.js --testRunner=jasmine1",
47+
"jest-cache": "node bin/jest.js",
48+
"jest-heap-usage": "node bin/jest.js --runInBand --logHeapUsage",
49+
"jest-in-band": "node bin/jest.js --runInBand",
50+
"jest-jasmine1": "node bin/jest.js --testRunner=jasmine1",
51+
"jest-json": "node bin/jest.js --json",
52+
"jest-no-cache": "node bin/jest.js --no-cache",
53+
"jest-node-cache": "node bin/jest.js --no-watchman",
54+
"jest-node-no-cache": "node bin/jest.js --no-watchman --no-cache",
55+
"jest-verbose": "node bin/jest.js --verbose",
4856
"lint": "eslint .",
4957
"postinstall": "node postinstall.js",
5058
"prepublish": "npm test",
51-
"test": "npm run lint && node bin/jest.js && npm run jasmine1 && npm link --ignore-scripts && node ./run_tests.js"
59+
"test": "npm run lint && npm run jest-no-cache && npm run jest-cache && npm run jest-node-no-cache && npm run jest-node-cache && npm run jest-jasmine1 && npm run jest-in-band && npm run jest-heap-usage && npm run jest-json && npm run jest-verbose && npm link --ignore-scripts && node ./run_tests.js"
5260
},
5361
"jest": {
5462
"rootDir": "src",
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
__mocks__/
2+
__tests__/
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
__mocks__/
2+
__tests__/

packages/jest-haste-map/.npmignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
__mocks__/
2+
__tests__/
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"name": "jest-haste-map",
3+
"version": "11.0.2",
4+
"repository": {
5+
"type": "git",
6+
"url": "https://github.com/facebook/jest.git"
7+
},
8+
"license": "BSD-3-Clause",
9+
"main": "src/index.js",
10+
"dependencies": {
11+
"denodeify": "^1.2.1",
12+
"fb-watchman": "^1.9.0",
13+
"graceful-fs": "^4.1.3"
14+
},
15+
"jest": {
16+
"testEnvironment": "node",
17+
"unmockedModulePathPatterns": [
18+
"denodeify"
19+
]
20+
},
21+
"scripts": {
22+
"prepublish": "npm test",
23+
"test": "node -e \"const spawn = require('child_process').spawn, path=require('path'); spawn('node', [path.resolve('../../bin/jest.js')], {stdio:'inherit'})\""
24+
}
25+
}

0 commit comments

Comments
 (0)