From fb00715da494e6fe2bafa88ca9e92291cca2c80b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=89=E5=92=B2=E6=99=BA=E5=AD=90=20Kevin=20Deng?= Date: Wed, 20 Mar 2024 01:59:13 +0800 Subject: [PATCH] fix: don't merge imports revert: https://github.com/vuejs/babel-plugin-jsx/pull/274 --- packages/babel-plugin-jsx/src/index.ts | 38 -------------------------- 1 file changed, 38 deletions(-) diff --git a/packages/babel-plugin-jsx/src/index.ts b/packages/babel-plugin-jsx/src/index.ts index 9038353..50654a4 100644 --- a/packages/babel-plugin-jsx/src/index.ts +++ b/packages/babel-plugin-jsx/src/index.ts @@ -191,44 +191,6 @@ export default declare>( } } }, - exit(path) { - const body = path.get('body') as NodePath[]; - const specifiersMap = new Map(); - - body - .filter( - (nodePath) => - t.isImportDeclaration(nodePath.node) && - nodePath.node.source.value === 'vue' - ) - .forEach((nodePath) => { - const { specifiers } = nodePath.node as t.ImportDeclaration; - let shouldRemove = false; - specifiers.forEach((specifier) => { - if ( - !specifier.loc && - t.isImportSpecifier(specifier) && - t.isIdentifier(specifier.imported) - ) { - specifiersMap.set(specifier.imported.name, specifier); - shouldRemove = true; - } - }); - if (shouldRemove) { - nodePath.remove(); - } - }); - - const specifiers = [...specifiersMap.keys()].map( - (imported) => specifiersMap.get(imported)! - ); - if (specifiers.length) { - path.unshiftContainer( - 'body', - t.importDeclaration(specifiers, t.stringLiteral('vue')) - ); - } - }, }, }, };