Skip to content

chore: remove unused function parameter #56

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 16, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 12 additions & 18 deletions packages/plugin-vue-jsx/src/index.ts
Original file line number Diff line number Diff line change
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