diff --git a/packages/plugin-vue-jsx/src/index.ts b/packages/plugin-vue-jsx/src/index.ts index a1e74d2a..e7464540 100644 --- a/packages/plugin-vue-jsx/src/index.ts +++ b/packages/plugin-vue-jsx/src/index.ts @@ -136,13 +136,13 @@ function vueJsxPlugin(options: Options = {}): Plugin { } // check for hmr injection - const declaredComponents: { name: string }[] = [] + const declaredComponents: string[] = [] const hotComponents: HotComponent[] = [] let hasDefault = false for (const node of result.ast!.program.body) { if (node.type === 'VariableDeclaration') { - const names = parseComponentDecls(node, code) + const names = parseComponentDecls(node) if (names.length) { declaredComponents.push(...names) } @@ -154,13 +154,11 @@ function vueJsxPlugin(options: Options = {}): Plugin { node.declaration.type === 'VariableDeclaration' ) { hotComponents.push( - ...parseComponentDecls(node.declaration, code).map( - ({ name }) => ({ - local: name, - exported: name, - id: getHash(id + name), - }), - ), + ...parseComponentDecls(node.declaration).map((name) => ({ + local: name, + exported: name, + id: getHash(id + name), + })), ) } else if (node.specifiers.length) { for (const spec of node.specifiers) { @@ -169,7 +167,7 @@ function vueJsxPlugin(options: Options = {}): Plugin { spec.exported.type === 'Identifier' ) { const matched = declaredComponents.find( - ({ name }) => name === spec.local.name, + (name) => name === spec.local.name, ) if (matched) { hotComponents.push({ @@ -186,12 +184,10 @@ function vueJsxPlugin(options: Options = {}): Plugin { if (node.type === 'ExportDefaultDeclaration') { if (node.declaration.type === 'Identifier') { const _name = node.declaration.name - const matched = declaredComponents.find( - ({ name }) => name === _name, - ) + const matched = declaredComponents.find((name) => name === _name) if (matched) { hotComponents.push({ - local: node.declaration.name, + local: _name, exported: 'default', id: getHash(id + 'default'), }) @@ -255,13 +251,11 @@ function vueJsxPlugin(options: Options = {}): Plugin { } } -function parseComponentDecls(node: types.VariableDeclaration, source: string) { +function parseComponentDecls(node: types.VariableDeclaration) { const names = [] for (const decl of node.declarations) { if (decl.id.type === 'Identifier' && isDefineComponentCall(decl.init)) { - names.push({ - name: decl.id.name, - }) + names.push(decl.id.name) } } return names