File tree Expand file tree Collapse file tree 2 files changed +13
-3
lines changed Expand file tree Collapse file tree 2 files changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -789,7 +789,15 @@ async function buildEnvironment(
789
789
( typeof input === 'string' || Object . keys ( input ) . length === 1 ) ) ,
790
790
minify :
791
791
options . minify === 'oxc'
792
- ? true
792
+ ? libOptions && ( format === 'es' || format === 'esm' )
793
+ ? {
794
+ compress : true ,
795
+ mangle : true ,
796
+ // Do not minify whitespace for ES lib output since that would remove
797
+ // pure annotations and break tree-shaking
798
+ removeWhitespace : false ,
799
+ }
800
+ : true
793
801
: options . minify === false
794
802
? 'dce-only'
795
803
: false ,
Original file line number Diff line number Diff line change @@ -53,14 +53,16 @@ describe.runIf(isBuild)('build', () => {
53
53
expect ( code ) . not . toMatch ( '__vitePreload' )
54
54
55
55
// Test that library chunks are hashed
56
- expect ( code ) . toMatch ( / a w a i t i m p o r t \( ` \. \/ m e s s a g e - [ - \w ] { 8 } .j s ` \) / )
56
+ expect ( code ) . toMatch ( / a w a i t i m p o r t \( " \. \/ m e s s a g e - [ - \w ] { 8 } .j s " \) / )
57
57
} )
58
58
59
59
test ( 'Library mode does not have any reference to pure CSS chunks' , async ( ) => {
60
60
const code = readFile ( 'dist/lib/dynamic-import-message.es.mjs' )
61
61
62
62
// Does not import pure CSS chunks and replaced by `Promise.resolve({})` instead
63
- expect ( code ) . not . toMatch ( / a w a i t i m p o r t \( ` \. \/ d y n a m i c - [ - \w ] { 8 } .j s ` \) / )
63
+ expect ( code ) . not . toMatch (
64
+ / a w a i t i m p o r t \( [ ' " ` ] \. \/ d y n a m i c - [ - \w ] { 8 } .j s [ ' " ` ] \) / ,
65
+ )
64
66
expect ( code ) . toMatch ( / a w a i t P r o m i s e .r e s o l v e \( \{ .* \} \) / )
65
67
} )
66
68
You can’t perform that action at this time.
0 commit comments