Skip to content

Commit

Permalink
chore: remove unused function parameter (#56)
Browse files Browse the repository at this point in the history
  • Loading branch information
holazz committed Aug 16, 2023
1 parent 0fce4b6 commit 28bb84b
Showing 1 changed file with 12 additions and 18 deletions.
30 changes: 12 additions & 18 deletions packages/plugin-vue-jsx/src/index.ts
Expand Up @@ -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)
}
Expand All @@ -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) {
Expand All @@ -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({
Expand All @@ -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'),
})
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 28bb84b

Please sign in to comment.