diff --git a/packages/docs/package.json b/packages/docs/package.json index d9e5615..6922c9d 100644 --- a/packages/docs/package.json +++ b/packages/docs/package.json @@ -3,6 +3,7 @@ "type": "module", "private": true, "scripts": { + "prepare": "node ./scripts/fix-heroicons.js", "serve": "esmo --experimental-import-meta-resolve --experimental-json-modules --no-warnings --enable-source-maps src/main.tsx | pino-colada", "dev": "nodemon --exec \"pnpm serve\" --watch src --ext ts,tsx,md,css", "start": "NODE_ENV=production pnpm serve", diff --git a/packages/docs/scripts/fix-heroicons.js b/packages/docs/scripts/fix-heroicons.js new file mode 100644 index 0000000..1583007 --- /dev/null +++ b/packages/docs/scripts/fix-heroicons.js @@ -0,0 +1,15 @@ +// heroicons doesn't have "sideEffects": false in it's package json, +// which causes esbuild to bundle in 460+ imports of react for some reason, +// which causes memory issues +import glob from "fast-glob" +import { readFile, writeFile } from "node:fs/promises" + +const files = await glob("node_modules/@heroicons/react/**/*.json", { + absolute: true, +}) + +for (const file of files) { + const data = JSON.parse(await readFile(file, "utf8")) + data.sideEffects = false + await writeFile(file, JSON.stringify(data, undefined, 2)) +}