Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use file urls when calling import() #9558

Merged
merged 2 commits into from Feb 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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);