From 371986194e80d0f6f92fb5f5eeceb6d772b545dd Mon Sep 17 00:00:00 2001 From: Simen Bekkhus Date: Tue, 11 Feb 2020 11:56:24 +0100 Subject: [PATCH 1/2] fix: use file urls when calling `import()` --- CHANGELOG.md | 1 + packages/jest-config/src/importMjs.ts | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e3376f7ee7dd..0472c02dc7f5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ ### Fixes - `[jest-config]` Treat `setupFilesAfterEnv` like `setupFiles` when normalizing configs against presets ([#9495](https://github.com/facebook/jest/pull/9495)) +- `[jest-config]` Support `.mjs` config files on Windows as well - `[jest-matcher-utils]` Fix diff highlight of symbol-keyed object. ([#9499](https://github.com/facebook/jest/pull/9499)) - `[jest-resolve]` Fix module identity preservation with symlinks and browser field resolution ([#9511](https://github.com/facebook/jest/pull/9511)) - `[jest-resolve]` Do not confuse directories with files ([#8912](https://github.com/facebook/jest/pull/8912)) diff --git a/packages/jest-config/src/importMjs.ts b/packages/jest-config/src/importMjs.ts index 693bac33185b..85d82fa10dd2 100644 --- a/packages/jest-config/src/importMjs.ts +++ b/packages/jest-config/src/importMjs.ts @@ -5,7 +5,10 @@ * LICENSE file in the root directory of this source tree. */ +import {pathToFileURL} from 'url'; + // this is in a separate file so that node 8 don't explode with a syntax error. // Remove this file when we drop support for Node 8 export default (specifier: string): Promise<{default: unknown}> => - import(specifier); + // node `import()` supports URL, but TypeScript doesn't know that + import(pathToFileURL(specifier).href); From ad8d87400777abadd72dce07ce5f6f69197f5219 Mon Sep 17 00:00:00 2001 From: Simen Bekkhus Date: Tue, 11 Feb 2020 11:58:38 +0100 Subject: [PATCH 2/2] link to PR --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0472c02dc7f5..252bdf4262c5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,7 +8,7 @@ ### Fixes - `[jest-config]` Treat `setupFilesAfterEnv` like `setupFiles` when normalizing configs against presets ([#9495](https://github.com/facebook/jest/pull/9495)) -- `[jest-config]` Support `.mjs` config files on Windows as well +- `[jest-config]` Support `.mjs` config files on Windows as well ([#9558](https://github.com/facebook/jest/pull/9558)) - `[jest-matcher-utils]` Fix diff highlight of symbol-keyed object. ([#9499](https://github.com/facebook/jest/pull/9499)) - `[jest-resolve]` Fix module identity preservation with symlinks and browser field resolution ([#9511](https://github.com/facebook/jest/pull/9511)) - `[jest-resolve]` Do not confuse directories with files ([#8912](https://github.com/facebook/jest/pull/8912))