Skip to content

Commit

Permalink
fix: use file urls when calling import() (#9558)
Browse files Browse the repository at this point in the history
  • Loading branch information
SimenB committed Feb 11, 2020
1 parent 3aef448 commit 7d59561
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -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 ([#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))
Expand Down
5 changes: 4 additions & 1 deletion packages/jest-config/src/importMjs.ts
Expand Up @@ -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);

0 comments on commit 7d59561

Please sign in to comment.