Skip to content
Merged
Show file tree
Hide file tree
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
13 changes: 13 additions & 0 deletions packages/vite/src/node/ssr/__tests__/ssrTransform.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,19 @@ test('named import: arbitrary module namespace specifier', async () => {
)
})

test('named import colliding with label', async () => {
expect(
await ssrTransformSimpleCode(
`import { query } from 'vue';function foo() { query: while (true) { continue query; break query } }`,
),
).toMatchInlineSnapshot(
`
"const __vite_ssr_import_0__ = await __vite_ssr_import__("vue", {"importedNames":["query"]});
function foo() { query: while (true) { continue query; break query } }"
`,
)
})

test('namespace import', async () => {
expect(
await ssrTransformSimpleCode(
Expand Down
10 changes: 10 additions & 0 deletions packages/vite/src/node/ssr/ssrTransform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -712,6 +712,16 @@ function isRefIdentifier(
return false
}

// label declaration or break/continue target
if (
(parent.type === 'LabeledStatement' ||
parent.type === 'BreakStatement' ||
parent.type === 'ContinueStatement') &&
parent.label === id
) {
return false
}

// meta property (e.g. import.meta)
if (parent.type === 'MetaProperty') {
return false
Expand Down
Loading