File tree Expand file tree Collapse file tree 1 file changed +6
-1
lines changed
packages/plugin-legacy/src Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Original file line number Diff line number Diff line change @@ -237,7 +237,7 @@ function viteLegacyPlugin(options: Options = {}): Plugin[] {
237237 `[@vitejs/plugin-legacy] modern polyfills:` ,
238238 modernPolyfills ,
239239 )
240- await buildPolyfillChunk (
240+ const polyfillChunk = await buildPolyfillChunk (
241241 config . mode ,
242242 modernPolyfills ,
243243 bundle ,
@@ -247,6 +247,9 @@ function viteLegacyPlugin(options: Options = {}): Plugin[] {
247247 opts ,
248248 true ,
249249 )
250+ if ( genLegacy && polyfillChunk ) {
251+ polyfillChunk . code = modernChunkLegacyGuard + polyfillChunk . code
252+ }
250253 return
251254 }
252255
@@ -734,6 +737,8 @@ async function buildPolyfillChunk(
734737
735738 // add the chunk to the bundle
736739 bundle [ polyfillChunk . fileName ] = polyfillChunk
740+
741+ return polyfillChunk
737742}
738743
739744const polyfillId = '\0vite/legacy-polyfills'
You can’t perform that action at this time.
0 commit comments