Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | 1x 1x 4x 4x 4x 4x 4x 4x 4x 4x | import MagicString from "magic-string";
import type { OutputBundle, NormalizedOutputOptions } from "rollup";
import { composeSourcemap } from "../utils/compose-sourcemap";
export const header = (headerValue: string) => ({
name: "header",
generateBundle: {
order: "pre" as const,
handler(_options: NormalizedOutputOptions, bundle: OutputBundle) {
for (const chunk of Object.values(bundle)) {
Iif (chunk.type !== "chunk") continue;
const s = new MagicString(chunk.code!);
s.prepend(headerValue);
chunk.code = s.toString();
const newMap = s.generateMap({ includeContent: true, hires: true });
composeSourcemap(chunk, newMap, bundle);
}
},
},
});
|