Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
5f8c6fd
fix(ssr): hoist export to handle cyclic import better
hi-ogawa Dec 17, 2024
b537976
chore: remove override temporarily
hi-ogawa Dec 17, 2024
3cc86da
wip: forget this one too for now
hi-ogawa Dec 17, 2024
ed79e4d
wip: workaround cyclic import
hi-ogawa Dec 17, 2024
95f47eb
chore: unused
hi-ogawa Dec 17, 2024
2245aaa
test: fix hmr-ssr
hi-ogawa Dec 18, 2024
a8c1d12
Merge branch 'main' into fix-ssr-transform-hoist-export
hi-ogawa Dec 18, 2024
c2f7d75
test: fix importing broken entries
hi-ogawa Dec 18, 2024
96f123a
test: tweak
hi-ogawa Dec 18, 2024
d5b2333
Merge branch 'main' into fix-ssr-transform-hoist-export
hi-ogawa Dec 25, 2024
d252b5c
fix: remove new line
hi-ogawa Dec 25, 2024
7904808
test: update
hi-ogawa Dec 25, 2024
45e74ac
chore: comment
hi-ogawa Dec 25, 2024
83a7a1f
test: test invalid cyclic
hi-ogawa Dec 25, 2024
af7de84
chore: comment
hi-ogawa Dec 25, 2024
b0b75eb
chore: comment
hi-ogawa Dec 25, 2024
958467a
test: simplify
hi-ogawa Dec 25, 2024
19f7533
test: add test in ssr playground
sapphi-red Jan 7, 2025
059d132
Merge branch 'main' into fix-ssr-transform-hoist-export
hi-ogawa Jan 8, 2025
677949c
test: hacky setupFiles
hi-ogawa Jan 10, 2025
a844104
chore: remove unused
hi-ogawa Jan 10, 2025
94a2d1f
Merge branch 'main' into fix-ssr-transform-hoist-export
hi-ogawa Jan 13, 2025
7d75d1f
Merge branch 'main' into fix-ssr-transform-hoist-export
hi-ogawa Mar 7, 2025
1d5110e
fix: give up preserving lines
hi-ogawa Mar 7, 2025
7e7b660
fix: tweak new lines
hi-ogawa Mar 7, 2025
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
Prev Previous commit
Next Next commit
chore: remove unused
  • Loading branch information
hi-ogawa committed Jan 10, 2025
commit a844104345d2382810b73095ba2d2587b57456e8
17 changes: 6 additions & 11 deletions packages/vite/src/node/ssr/ssrTransform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ async function ssrTransformScript(
return importId
}

function defineExport(_position: number, name: string, local = name) {
function defineExport(name: string, local = name) {
s.appendLeft(
fileStartIndex,
`Object.defineProperty(${ssrModuleExportsKey}, ${JSON.stringify(name)}, ` +
Expand Down Expand Up @@ -251,13 +251,13 @@ async function ssrTransformScript(
node.declaration.type === 'ClassDeclaration'
) {
// export function foo() {}
defineExport(node.end, node.declaration.id!.name)
defineExport(node.declaration.id!.name)
} else {
// export const foo = 1, bar = 2
for (const declaration of node.declaration.declarations) {
const names = extractNames(declaration.id as any)
for (const name of names) {
defineExport(node.end, name)
defineExport(name)
}
}
}
Expand All @@ -282,14 +282,9 @@ async function ssrTransformScript(
) as string

if (spec.local.type === 'Identifier') {
defineExport(
node.end,
exportedAs,
`${importId}.${spec.local.name}`,
)
defineExport(exportedAs, `${importId}.${spec.local.name}`)
} else {
defineExport(
node.end,
exportedAs,
`${importId}[${JSON.stringify(spec.local.value as string)}]`,
)
Expand All @@ -305,7 +300,7 @@ async function ssrTransformScript(
spec.exported,
) as string

defineExport(node.end, exportedAs, binding || local)
defineExport(exportedAs, binding || local)
}
}
}
Expand Down Expand Up @@ -345,7 +340,7 @@ async function ssrTransformScript(
const exportedAs = getIdentifierNameOrLiteralValue(
node.exported,
) as string
defineExport(node.end, exportedAs, `${importId}`)
defineExport(exportedAs, `${importId}`)
} else {
s.appendLeft(node.end, `${ssrExportAllKey}(${importId});\n`)
}
Expand Down
Loading