Skip to content

Commit

Permalink
Add jest-resolve to resolve modules based on the Facebook module re…
Browse files Browse the repository at this point in the history
…solution algorithm.

Summary:
This refactors Runtime.js and TestRunner.js and pulls out the resolution code into a new module `jest-resolve` which now encodes Facebook's module resolution algorithm. It provides the second half of node-haste and together with `jest-haste-map` can be seen as a full replacement.

There is very little new code in this diff. Most code is existing code that was lifted from another module and brought together. The next step after this diff will be to see if it makes sense to fork the `resolve` module and speed up how it works.

It doesn't come with its own tests (yet) because its functionality is completely covered by all the tests in Runtime.js. I have also cleaned up all of the Runtime tests and added a new `createRuntime` helper for testing, which should make it much easier from now on to change how an instance of Runtime is constructed for tests.

Closes #1007

Reviewed By: dmitriiabramov

Differential Revision: D3302805

fbshipit-source-id: d1c96de7ed09e36aa1b2b5a4656260e79d1fb3e2
  • Loading branch information
cpojer authored and Facebook Github Bot 3 committed May 18, 2016
1 parent 49e5230 commit ddbd3be
Show file tree
Hide file tree
Showing 30 changed files with 1,114 additions and 982 deletions.
4 changes: 2 additions & 2 deletions integration_tests/__tests__/stack_trace-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,12 @@ describe('Stack Trace', () => {
/\s+at\s(?:.+?)\s\(__tests__\/test-error-test\.js/
);

// Make sure we show Jest's Runtime.js as part of the stack trace
// Make sure we show Jest's jest-resolve as part of the stack trace
expect(stdout).toMatch(
/Error: Cannot find module 'this-module-does-not-exist' from 'test-error-test\.js'/
);
expect(stdout).toMatch(
/\s+at\s(?:.+?)\s\((?:.+?)Runtime\/Runtime\.js/
/\s+at\s(?:.+?)\s\((?:.+?)jest-resolve\/src\/index\.js/
);
});

Expand Down
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"lerna": "2.0.0-beta.7",
"lerna": "2.0.0-beta.10",
"version": "12.0.2"
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"eslint": "^1.10.3",
"eslint-plugin-babel": "^3.2.0",
"fbjs-scripts": "^0.6.0",
"lerna": "2.0.0-beta.7",
"lerna": "2.0.0-beta.10",
"rimraf": "^2.4.4"
},
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion packages/jest-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
"jest-jasmine1": "^12.0.2",
"jest-jasmine2": "^12.0.2",
"jest-mock": "^12.0.2",
"jest-resolve": "^12.0.2",
"jest-util": "^12.0.2",
"json-stable-stringify": "^1.0.0",
"lodash.template": "^4.2.4",
"optimist": "^0.6.1",
"resolve": "^1.1.6",
"sane": "^1.2.0",
"which": "^1.1.1",
"worker-farm": "^1.3.1"
Expand Down
Loading

0 comments on commit ddbd3be

Please sign in to comment.