diff --git a/utils/moduleVisitor.js b/utils/moduleVisitor.js index 8466fa65e7..69269985bd 100644 --- a/utils/moduleVisitor.js +++ b/utils/moduleVisitor.js @@ -36,7 +36,17 @@ exports.default = function visitModules(visitor, options) { // for esmodule dynamic `import()` calls function checkImportCall(node) { - const modulePath = node.source; + let modulePath; + // refs https://github.com/estree/estree/blob/master/es2020.md#importexpression + if (node.type === 'ImportExpression') { + modulePath = node.source; + } else if (node.type === 'CallExpression') { + if (node.callee.type !== 'Import') return; + if (node.arguments.length !== 1) return; + + modulePath = node.arguments[0]; + } + if (modulePath.type !== 'Literal') return; if (typeof modulePath.value !== 'string') return; @@ -83,6 +93,7 @@ exports.default = function visitModules(visitor, options) { 'ImportDeclaration': checkSource, 'ExportNamedDeclaration': checkSource, 'ExportAllDeclaration': checkSource, + 'CallExpression': checkImportCall, 'ImportExpression': checkImportCall, }); }