diff --git a/CHANGELOG.md b/CHANGELOG.md index 4d7052f994b6..d1f6d78038a1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 @@ -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. \ No newline at end of file +* See commit history for changes in previous versions of jest. diff --git a/packages/jest-resolve/src/is_builtin_module.js b/packages/jest-resolve/src/is_builtin_module.js index c7dd31efbd3a..67762edc1ee8 100644 --- a/packages/jest-resolve/src/is_builtin_module.js +++ b/packages/jest-resolve/src/is_builtin_module.js @@ -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; }