We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
anymaniax
melloware
soartec-lab
Learn more about funding links in repositories.
Report abuse
1 parent d3ddbdd commit a61d26aCopy full SHA for a61d26a
packages/core/src/utils/dynamic-import.ts
@@ -1,3 +1,4 @@
1
+import { pathToFileURL } from 'url';
2
import { isModule, isObject, isString } from './assertion';
3
import { resolve } from './path';
4
@@ -13,7 +14,10 @@ export const dynamicImport = async <T>(
13
14
try {
15
if (isString(toImport)) {
16
const path = resolve(from, toImport);
- const data = await import(path);
17
+ // use pathToFileURL to solve issue #1332.
18
+ // https://github.com/nodejs/node/issues/31710
19
+ const fileUrl = pathToFileURL(path);
20
+ const data = await import(fileUrl.href);
21
if (takeDefault && (isObject(data) || isModule(data)) && data.default) {
22
return (data as any).default as T;
23
}
0 commit comments