@@ -633,8 +633,6 @@ async function buildPolyfillChunk(
633
633
plugins : [ polyfillsPlugin ( imports , excludeSystemJS ) ] ,
634
634
build : {
635
635
write : false ,
636
- // if a value above 'es5' is set, esbuild injects helper functions which uses es2015 features
637
- target : 'es5' ,
638
636
minify,
639
637
assetsDir,
640
638
rollupOptions : {
@@ -646,6 +644,18 @@ async function buildPolyfillChunk(
646
644
entryFileNames : rollupOutputOptions . entryFileNames
647
645
}
648
646
}
647
+ } ,
648
+ // Don't run esbuild for transpilation or minification
649
+ // because we don't want to transpile code.
650
+ esbuild : false ,
651
+ optimizeDeps : {
652
+ esbuildOptions : {
653
+ // If a value above 'es5' is set, esbuild injects helper functions which uses es2015 features.
654
+ // This limits the input code not to include es2015+ codes.
655
+ // But core-js is the only dependency which includes commonjs code
656
+ // and core-js doesn't include es2015+ codes.
657
+ target : 'es5'
658
+ }
649
659
}
650
660
} )
651
661
const _polyfillChunk = Array . isArray ( res ) ? res [ 0 ] : res
@@ -685,21 +695,6 @@ function polyfillsPlugin(
685
695
( excludeSystemJS ? '' : `import "systemjs/dist/s.min.js";` )
686
696
)
687
697
}
688
- } ,
689
- renderChunk ( _ , __ , opts ) {
690
- // systemjs includes code that can't be minified down to es5 by esbuild
691
- if ( ! excludeSystemJS ) {
692
- // @ts -ignore avoid esbuild transform on legacy chunks since it produces
693
- // legacy-unsafe code - e.g. rewriting object properties into shorthands
694
- opts . __vite_skip_esbuild__ = true
695
-
696
- // @ts -ignore force terser for legacy chunks. This only takes effect if
697
- // minification isn't disabled, because that leaves out the terser plugin
698
- // entirely.
699
- opts . __vite_force_terser__ = true
700
- }
701
-
702
- return null
703
698
}
704
699
}
705
700
}
0 commit comments