We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent c06d427 commit acbc66fCopy full SHA for acbc66f
src/helpers/import-helper.js
@@ -1,3 +1,5 @@
1
+const url = require('url');
2
+
3
async function supportsDynamicImport() {
4
try {
5
// imports are cached.
@@ -20,8 +22,13 @@ async function supportsDynamicImport() {
20
22
async function importModule(modulePath) {
21
23
// JSON modules are still behind a flag. Fallback to require for now.
24
// https://nodejs.org/api/esm.html#json-modules
- if (!modulePath.endsWith('.json') && (await supportsDynamicImport())) {
- return import(modulePath);
25
+ if (
26
+ url.pathToFileURL &&
27
+ !modulePath.endsWith('.json') &&
28
+ (await supportsDynamicImport())
29
+ ) {
30
+ // 'import' expects a URL. (https://github.com/sequelize/cli/issues/994)
31
+ return import(url.pathToFileURL(modulePath));
32
}
33
34
// mimics what `import()` would return for
0 commit comments