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

Function polyfillsPlugin

packages/plugin-legacy/src/index.ts:973–993  ·  view source on GitHub ↗
(
  imports: Set<string>,
  excludeSystemJS?: boolean,
)

Source from the content-addressed store, hash-verified

971const polyfillId = '\0vite/legacy-polyfills'
972
973function polyfillsPlugin(
974 imports: Set<string>,
975 excludeSystemJS?: boolean,
976): Plugin {
977 return {
978 name: 'vite:legacy-polyfills',
979 resolveId(id) {
980 if (id === polyfillId) {
981 return id
982 }
983 },
984 load(id) {
985 if (id === polyfillId) {
986 return (
987 [...imports].map((i) => `import ${JSON.stringify(i)};`).join('') +
988 (excludeSystemJS ? '' : `import "systemjs/dist/s.min.js";`)
989 )
990 }
991 },
992 }
993}
994
995function prependModenChunkLegacyGuardPlugin(): Plugin {
996 let sourceMapEnabled!: boolean

Callers 1

buildPolyfillChunkFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected