Skip to content

Commit ffb3be8

Browse files
SimenBcpojer
authored andcommitted
fix: get builtin modules from node core (#5411)
1 parent 2f0dec5 commit ffb3be8

2 files changed

Lines changed: 8 additions & 5 deletions

File tree

CHANGELOG.md

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

2728
## jest 22.1.4
2829

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

14971498
## <=0.4.0
14981499

1499-
* See commit history for changes in previous versions of jest.
1500+
* 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)