|
1 | | -const { builtinModules } = require('module'); |
2 | 1 | const generate = require('@babel/generator').default; |
3 | 2 | const AST = require("./ast"); |
4 | 3 | const { ExecutorFactory, JestMock } = require("./executorConfig"); |
5 | 4 | const resolver = require("./resolver"); |
6 | 5 | const BarrelFileManagerFacade = require("./barrel"); |
7 | 6 | const pluginOptions = require("./pluginOptions"); |
8 | 7 | const logger = require("./logger"); |
9 | | -const PathFunctions = require("./path"); |
10 | 8 |
|
11 | 9 | const jestMockFunction = new JestMock(); |
12 | 10 |
|
13 | 11 | const importDeclarationVisitor = (path, state) => { |
14 | 12 | const importsSpecifiers = path.node.specifiers; |
15 | | - if (!AST.isAnySpecifierExist(importsSpecifiers)) return; |
16 | | - if (AST.getSpecifierType(importsSpecifiers[0]) === "namespace") return; |
17 | 13 | const parsedJSFile = state.filename; |
18 | 14 | const importsPath = path.node.source.value; |
19 | | - if (pluginOptions.options.executorName === "vite" && importsPath.startsWith("/")) return; |
20 | | - if (pluginOptions.options.executorName === "webpack" && importsPath.includes("!")) return; |
21 | | - if (PathFunctions.isSpecialCharInBundlerPathImport(importsPath)) return; |
22 | | - if (builtinModules.includes(importsPath)) return; |
| 15 | + if (AST.isSpecialImportCases(path.node)) return; |
23 | 16 | logger.log(`Source import line: ${generate(path.node, { comments: false, concise: true }).code}`); |
24 | 17 | resolver.from = parsedJSFile; |
25 | 18 | const resolvedPathObject = resolver.resolve(importsPath ,parsedJSFile); |
|
0 commit comments