Skip to content

Commit

Permalink
Implement jest-haste-map instead of node-haste
Browse files Browse the repository at this point in the history
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
  • Loading branch information
cpojer authored and Facebook Github Bot 6 committed Apr 22, 2016
1 parent 9d17595 commit 052af96
Show file tree
Hide file tree
Showing 47 changed files with 3,661 additions and 456 deletions.
1 change: 0 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
"arrow-spacing": [2],
"babel/arrow-parens": [2, "as-needed"],
"brace-style": [2, "1tbs", {"allowSingleLine": true}],
"camelcase": [2, {"properties": "always"}],
"comma-dangle": [2, "always-multiline"],
"comma-spacing": [2],
"comma-style": [2, "last"],
Expand Down
14 changes: 11 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@
"istanbul": "^0.4.2",
"jest-environment-jsdom": "^11.0.2",
"jest-environment-node": "^11.0.2",
"jest-haste-map": "^11.0.2",
"jest-jasmine1": "^11.0.2",
"jest-jasmine2": "^11.0.2",
"jest-mock": "^11.0.2",
"jest-util": "^11.0.2",
"json-stable-stringify": "^1.0.0",
"lodash.template": "^4.2.4",
"mkdirp": "^0.5.1",
"node-haste": "^2.5.0",
"optimist": "^0.6.1",
"resolve": "^1.1.6",
"sane": "^1.2.0",
Expand All @@ -44,11 +44,19 @@
"url": "https://github.com/facebook/jest"
},
"scripts": {
"jasmine1": "node bin/jest.js --testRunner=jasmine1",
"jest-cache": "node bin/jest.js",
"jest-heap-usage": "node bin/jest.js --runInBand --logHeapUsage",
"jest-in-band": "node bin/jest.js --runInBand",
"jest-jasmine1": "node bin/jest.js --testRunner=jasmine1",
"jest-json": "node bin/jest.js --json",
"jest-no-cache": "node bin/jest.js --no-cache",
"jest-node-cache": "node bin/jest.js --no-watchman",
"jest-node-no-cache": "node bin/jest.js --no-watchman --no-cache",
"jest-verbose": "node bin/jest.js --verbose",
"lint": "eslint .",
"postinstall": "node postinstall.js",
"prepublish": "npm test",
"test": "npm run lint && node bin/jest.js && npm run jasmine1 && npm link --ignore-scripts && node ./run_tests.js"
"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"
},
"jest": {
"rootDir": "src",
Expand Down
2 changes: 2 additions & 0 deletions packages/jest-environment-jsdom/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
__mocks__/
__tests__/
2 changes: 2 additions & 0 deletions packages/jest-environment-node/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
__mocks__/
__tests__/
2 changes: 2 additions & 0 deletions packages/jest-haste-map/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
__mocks__/
__tests__/
25 changes: 25 additions & 0 deletions packages/jest-haste-map/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"name": "jest-haste-map",
"version": "11.0.2",
"repository": {
"type": "git",
"url": "https://github.com/facebook/jest.git"
},
"license": "BSD-3-Clause",
"main": "src/index.js",
"dependencies": {
"denodeify": "^1.2.1",
"fb-watchman": "^1.9.0",
"graceful-fs": "^4.1.3"
},
"jest": {
"testEnvironment": "node",
"unmockedModulePathPatterns": [
"denodeify"
]
},
"scripts": {
"prepublish": "npm test",
"test": "node -e \"const spawn = require('child_process').spawn, path=require('path'); spawn('node', [path.resolve('../../bin/jest.js')], {stdio:'inherit'})\""
}
}
Loading

0 comments on commit 052af96

Please sign in to comment.