File tree Expand file tree Collapse file tree 2 files changed +37
-2
lines changed
packages/vite/src/node/ssr Expand file tree Collapse file tree 2 files changed +37
-2
lines changed Original file line number Diff line number Diff line change @@ -1285,6 +1285,14 @@ switch (1) {
1285
1285
f()
1286
1286
break
1287
1287
}
1288
+
1289
+ if(0){}f()
1290
+
1291
+ if(0){}else{}f()
1292
+
1293
+ switch(1){}f()
1294
+
1295
+ {}f(1)
1288
1296
` ) ,
1289
1297
) . toMatchInlineSnapshot ( `
1290
1298
"
@@ -1346,7 +1354,34 @@ switch (1) {
1346
1354
x;
1347
1355
(0,__vite_ssr_import_0__.f)();
1348
1356
break
1349
- }
1357
+ };
1358
+
1359
+ if(0){};(0,__vite_ssr_import_0__.f)();
1360
+
1361
+ if(0){}else{};(0,__vite_ssr_import_0__.f)();
1362
+
1363
+ switch(1){};(0,__vite_ssr_import_0__.f)();
1364
+
1365
+ {}(0,__vite_ssr_import_0__.f)(1)
1350
1366
"
1351
1367
` )
1352
1368
} )
1369
+
1370
+ test ( 'does not break minified code' , async ( ) => {
1371
+ // Based on https://unpkg.com/@headlessui /vue@1.7.23/dist/components/transitions/transition.js
1372
+ expect (
1373
+ await ssrTransformSimpleCode (
1374
+ `import O from 'a';
1375
+ const c = () => {
1376
+ if(true){return}O(1,{})
1377
+ }` ,
1378
+ ) ,
1379
+ ) . toMatchInlineSnapshot (
1380
+ `
1381
+ "const __vite_ssr_import_0__ = await __vite_ssr_import__("a", {"importedNames":["default"]});
1382
+ const c = () => {
1383
+ if(true){return};(0,__vite_ssr_import_0__.default)(1,{})
1384
+ }"
1385
+ ` ,
1386
+ )
1387
+ } )
Original file line number Diff line number Diff line change @@ -364,7 +364,7 @@ async function ssrTransformScript(
364
364
stmt . type !== 'BlockStatement' &&
365
365
stmt . type !== 'ImportDeclaration'
366
366
) {
367
- s . appendRight ( stmt . end , ';' )
367
+ s . appendLeft ( stmt . end , ';' )
368
368
}
369
369
}
370
370
} ,
You can’t perform that action at this time.
0 commit comments