-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(ssr): fix semicolon injection by ssr transform (#19097)
Co-authored-by: Hiroshi Ogawa <[email protected]>
- Loading branch information
1 parent
677508b
commit 1c102d5
Showing
2 changed files
with
37 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1285,6 +1285,14 @@ switch (1) { | |
f() | ||
break | ||
} | ||
if(0){}f() | ||
if(0){}else{}f() | ||
switch(1){}f() | ||
{}f(1) | ||
`), | ||
).toMatchInlineSnapshot(` | ||
" | ||
|
@@ -1346,7 +1354,34 @@ switch (1) { | |
x; | ||
(0,__vite_ssr_import_0__.f)(); | ||
break | ||
} | ||
}; | ||
if(0){};(0,__vite_ssr_import_0__.f)(); | ||
if(0){}else{};(0,__vite_ssr_import_0__.f)(); | ||
switch(1){};(0,__vite_ssr_import_0__.f)(); | ||
{}(0,__vite_ssr_import_0__.f)(1) | ||
" | ||
`) | ||
}) | ||
|
||
test('does not break minified code', async () => { | ||
// Based on https://unpkg.com/@headlessui/[email protected]/dist/components/transitions/transition.js | ||
expect( | ||
await ssrTransformSimpleCode( | ||
`import O from 'a'; | ||
const c = () => { | ||
if(true){return}O(1,{}) | ||
}`, | ||
), | ||
).toMatchInlineSnapshot( | ||
` | ||
"const __vite_ssr_import_0__ = await __vite_ssr_import__("a", {"importedNames":["default"]}); | ||
const c = () => { | ||
if(true){return};(0,__vite_ssr_import_0__.default)(1,{}) | ||
}" | ||
`, | ||
) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters