Skip to content

Commit

Permalink
fix(ssr): ssrTransform handling for empty ArrayPattern (vitejs#5988)
Browse files Browse the repository at this point in the history
  • Loading branch information
antfu committed Dec 7, 2021
1 parent 1102789 commit 79aa687
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 6 additions & 0 deletions packages/vite/src/node/ssr/__tests__/ssrTransform.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -375,3 +375,9 @@ test('overwrite bindings', async () => {
"
`)
})

test('Empty array pattern', async () => {
expect(
(await ssrTransform(`const [, LHS, RHS] = inMatch;`, null, null)).code
).toMatchInlineSnapshot(`"const [, LHS, RHS] = inMatch;"`)
})
2 changes: 1 addition & 1 deletion packages/vite/src/node/ssr/ssrTransform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ function walk(
}
})
} else if (node.id.type === 'ArrayPattern') {
node.id.elements.forEach((element) => {
node.id.elements.filter(Boolean).forEach((element) => {
setScope(parentFunction, (element as Identifier).name)
})
} else {
Expand Down

0 comments on commit 79aa687

Please sign in to comment.