Skip to content

Commit

Permalink
Pass URLs to import() rather than paths
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolo-ribaudo committed Mar 1, 2020
1 parent 9015fda commit 4074818
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion packages/babel-core/src/config/files/module-types.js
@@ -1,6 +1,7 @@
import { isAsync, waitFor } from "../../gensync-utils/async";
import type { Handler } from "gensync";
import path from "path";
import { pathToFileURL } from "url";

let import_;
try {
Expand Down Expand Up @@ -55,6 +56,8 @@ async function loadMjsDefault(filepath: string) {
);
}

const module = await import_(filepath);
// import() expects URLs, not file paths.
// https://github.com/nodejs/node/issues/31710
const module = await import_(pathToFileURL(filepath));
return module.default;
}

0 comments on commit 4074818

Please sign in to comment.