Skip to content

Commit 7d59561

Browse files
authored
fix: use file urls when calling import() (#9558)
1 parent 3aef448 commit 7d59561

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
### Fixes
99

1010
- `[jest-config]` Treat `setupFilesAfterEnv` like `setupFiles` when normalizing configs against presets ([#9495](https://github.com/facebook/jest/pull/9495))
11+
- `[jest-config]` Support `.mjs` config files on Windows as well ([#9558](https://github.com/facebook/jest/pull/9558))
1112
- `[jest-matcher-utils]` Fix diff highlight of symbol-keyed object. ([#9499](https://github.com/facebook/jest/pull/9499))
1213
- `[jest-resolve]` Fix module identity preservation with symlinks and browser field resolution ([#9511](https://github.com/facebook/jest/pull/9511))
1314
- `[jest-resolve]` Do not confuse directories with files ([#8912](https://github.com/facebook/jest/pull/8912))

packages/jest-config/src/importMjs.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@
55
* LICENSE file in the root directory of this source tree.
66
*/
77

8+
import {pathToFileURL} from 'url';
9+
810
// this is in a separate file so that node 8 don't explode with a syntax error.
911
// Remove this file when we drop support for Node 8
1012
export default (specifier: string): Promise<{default: unknown}> =>
11-
import(specifier);
13+
// node `import()` supports URL, but TypeScript doesn't know that
14+
import(pathToFileURL(specifier).href);

0 commit comments

Comments
 (0)