MCPcopy
hub / github.com/vitejs/vite / prependModenChunkLegacyGuardPlugin

Function prependModenChunkLegacyGuardPlugin

packages/plugin-legacy/src/index.ts:995–1018  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

993}
994
995function prependModenChunkLegacyGuardPlugin(): Plugin {
996 let sourceMapEnabled!: boolean
997 return {
998 name: 'vite:legacy-prepend-moden-chunk-legacy-guard',
999 configResolved(config) {
1000 sourceMapEnabled = !!config.build.sourcemap
1001 },
1002 renderChunk(code, chunk) {
1003 const modernChunkLegacyGuard = createModernChunkLegacyGuard(
1004 chunk.fileName,
1005 )
1006 if (!sourceMapEnabled) {
1007 return modernChunkLegacyGuard + code
1008 }
1009
1010 const ms = new MagicString(code)
1011 ms.prepend(modernChunkLegacyGuard)
1012 return {
1013 code: ms.toString(),
1014 map: ms.generateMap({ hires: 'boundary' }),
1015 }
1016 },
1017 }
1018}
1019
1020function isLegacyChunk(chunk: Rollup.RenderedChunk) {
1021 return chunk.fileName.includes('-legacy')

Callers 1

buildPolyfillChunkFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected