On a large project which uses pnpm with many packages & sapper run dev, when a file changes, sapper reloads then panics with a FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory error. This issue did not occur over the last few months but has begun occurring.
I'm attempting to run the process using node --max-old-space-size=8192, but ran into issues passing cli arguments directly to nodejs. To fix, I have the script:
#!/bin/sh
cat ./node_modules/.bin/sapper | sed -E 's/(node\"?)(\s+\")/\1 --max-old-space-size=8192 \2/' > ./node_modules/.bin/sapper-himem
chmod a+x ./node_modules/.bin/sapper-himem
./node_modules/.bin/sapper-himem dev
I tried several other solutions but had to use sed to inject cli args to the node process. A proper solution would be to have a way to pass cli args from the sapper script into the node process.