MCPcopy Create free account
hub / github.com/developit/microbundle / renderChunk

Function renderChunk

src/index.js:648–662  ·  view source on GitHub ↗
(code, chunk, opts)

Source from the content-addressed store, hash-verified

646 // Only ESM environments necessitate globalThis, and UMD bundles can't be properly loaded as ESM.
647 // So we remove the globalThis check, replacing it with `this||self` to match Rollup 1's output:
648 renderChunk(code, chunk, opts) {
649 if (opts.format === 'umd') {
650 // minified:
651 code = code.replace(
652 /([a-zA-Z$_]+)="undefined"!=typeof globalThis\?globalThis:(\1\|\|self)/,
653 '$2',
654 );
655 // unminified:
656 code = code.replace(
657 /(global *= *)typeof +globalThis *!== *['"]undefined['"] *\? *globalThis *: *(global *\|\| *self)/,
658 '$1$2',
659 );
660 return { code, map: null };
661 }
662 },
663 // Grab size info before writing files to disk:
664 writeBundle(_, bundle) {
665 config._sizeInfo = Promise.all(

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…