Skip to content
Prev Previous commit
Next Next commit
Update packages/vite/src/node/ssr/ssrTransform.ts
Co-authored-by: 翠 / green <[email protected]>
  • Loading branch information
aleclarson and sapphi-red authored Dec 20, 2024
commit defd7f41c56945ed56ce6e6f45a8ec3c8f335df1
7 changes: 4 additions & 3 deletions packages/vite/src/node/ssr/ssrTransform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,10 @@ async function ssrTransformScript(

s.update(importNode.start, importNode.end, transformedImport)

// Check for non-whitespace characters between the last import and the
// current one, to determine if hoisting is needed.
// TODO: Account for comments between imports.
// If there's only whitespace characters between the last import and the
// current one, that means there's no statements between them and
// hoisting is not needed.
// FIXME: account for comments between imports
const nonWhitespaceRegex = /\S/g
nonWhitespaceRegex.lastIndex = index
nonWhitespaceRegex.exec(code)
Expand Down
Loading