Skip to content

Commit d741640

Browse files
committed
fix: get builtin modules from node core
1 parent 0110101 commit d741640

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

CHANGELOG.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,9 @@
1818
* `[docs]` Add tutorial page for ES6 class mocks.
1919
([#5383]https://github.com/facebook/jest/pull/5383))
2020
* `[jest-resolve]` Search required modules in node_modules and then in custom
21-
paths.
22-
([#5403](https://github.com/facebook/jest/pull/5403))
21+
paths. ([#5403](https://github.com/facebook/jest/pull/5403))
22+
* `[jest-resolve]` Get builtin modules from node core.
23+
([#5411](https://github.com/facebook/jest/pull/5411))
2324

2425
## jest 22.1.4
2526

@@ -1493,4 +1494,4 @@ See https://facebook.github.io/jest/blog/2016/12/15/2016-in-jest.html
14931494

14941495
## <=0.4.0
14951496

1496-
* See commit history for changes in previous versions of jest.
1497+
* See commit history for changes in previous versions of jest.

packages/jest-resolve/src/is_builtin_module.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,20 @@
77
* @flow
88
*/
99

10+
// $FlowFixMe: Flow doesn't know about the `module` module
11+
import {builtinModules} from 'module';
12+
1013
// https://github.com/facebook/flow/pull/5160
1114
declare var process: {
1215
binding(type: string): {},
1316
};
1417

1518
const BUILTIN_MODULES =
16-
module.builtinModules ||
19+
builtinModules ||
1720
Object.keys(process.binding('natives')).filter(
1821
(module: string) => !/^internal\//.test(module),
1922
);
2023

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

0 commit comments

Comments
 (0)