Skip to content

Commit 17ea3d4

Browse files
misoguycpojer
authored andcommitted
Use module.builtinModules when it exists (#5099)
* Use module.builtinModules when it exists * Update CHANGELOG * Add FlowFixMe for module.builtinModules
1 parent 7e564b0 commit 17ea3d4

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
### Fixes
44

5+
* `[jest-resolve]` Use `module.builtinModules` as `BUILTIN_MODULES` when it exists
56
* `[jest-worker]` Remove `debug` and `inspect` flags from the arguments sent to
67
the child ([#5068](https://github.com/facebook/jest/pull/5068))
78
* `[jest-config]` Use all `--testPathPattern` and `<regexForTestFiles>` args in

packages/jest-resolve/src/is_builtin_module.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,13 @@ declare var process: {
1212
binding(type: string): {},
1313
};
1414

15-
const BUILTIN_MODULES = Object.keys(process.binding('natives')).filter(
16-
(module: string) => !/^internal\//.test(module),
17-
);
15+
const BUILTIN_MODULES =
16+
module.builtinModules ||
17+
Object.keys(process.binding('natives')).filter(
18+
(module: string) => !/^internal\//.test(module),
19+
);
1820

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

0 commit comments

Comments
 (0)