add prepare script to add sideEffects: false to heroicons

This commit is contained in:
MapleLeaf
2022-01-07 02:45:29 -06:00
parent ba603fca9e
commit 449b99f76f
2 changed files with 16 additions and 0 deletions

View File

@@ -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))
}