Skip to content

Commit

Permalink
fix: get builtin modules from node core (#5411)
Browse files Browse the repository at this point in the history
  • Loading branch information
SimenB authored and cpojer committed Jan 28, 2018
1 parent 2f0dec5 commit ffb3be8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
7 changes: 4 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@
* `[docs]` Add tutorial page for ES6 class mocks.
([#5383]https://github.com/facebook/jest/pull/5383))
* `[jest-resolve]` Search required modules in node_modules and then in custom
paths.
([#5403](https://github.com/facebook/jest/pull/5403))
paths. ([#5403](https://github.com/facebook/jest/pull/5403))
* `[jest-resolve]` Get builtin modules from node core.
([#5411](https://github.com/facebook/jest/pull/5411))

## jest 22.1.4

Expand Down Expand Up @@ -1496,4 +1497,4 @@ See https://facebook.github.io/jest/blog/2016/12/15/2016-in-jest.html

## <=0.4.0

* See commit history for changes in previous versions of jest.
* See commit history for changes in previous versions of jest.
6 changes: 4 additions & 2 deletions packages/jest-resolve/src/is_builtin_module.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,20 @@
* @flow
*/

// $FlowFixMe: Flow doesn't know about the `module` module
import {builtinModules} from 'module';

// https://github.com/facebook/flow/pull/5160
declare var process: {
binding(type: string): {},
};

const BUILTIN_MODULES =
module.builtinModules ||
builtinModules ||
Object.keys(process.binding('natives')).filter(
(module: string) => !/^internal\//.test(module),
);

export default function isBuiltinModule(module: string): boolean {
// $FlowFixMe: module.builtinModules is not added to the flow type definitions yet
return BUILTIN_MODULES.indexOf(module) !== -1;
}

0 comments on commit ffb3be8

Please sign in to comment.