Open kirill-konshin opened 2 weeks ago
@jamcalli for now I conclude that best option is to disable ASAR until either Next.js or Electron Builder fixes the issue...
Alternatively you can try to opt out of ASAR just the cache dir:
asarUnpack:
- '.next/standalone/demo/.next/cache/**/*'
It fails in demo due to monorepo, but in your case it might work, just copy there something before the packaging, so the dir will be created.
Made it work for monorepo, does not fix the problem... Electron still tries to write in ASAR instead of the unpacked dir.
@kirill-konshin thanks for looking into this.
It honestly isn't a big deal, and its probably totally ok to just opt out of image optimization caching, at least for my use case.
I appreciate your suggestions, and documenting the nuances will be beneficial for anyone encountering similar situation.
@jamcalli for now I conclude that best option is to disable ASAR until either Next.js or Electron Builder fixes the issue...
~Alternatively you can try to opt out of ASAR just the cache dir:~
asarUnpack: - '.next/standalone/demo/.next/cache/**/*'
~It fails in demo due to monorepo, but in your case it might work, just copy there something before the packaging, so the dir will be created.~
Made it work for monorepo, does not fix the problem... Electron still tries to write in ASAR instead of the unpacked dir.
A true solution would be for next to allows specifying the cache dir. There are some tickets open regarding this, but obviously the use case is so niche that I cant see them working on it anytime soon.
Btw, you can safely disable ASAR: it provides minimal security, primarily through obscurity. While it does package files into a single archive, the contents can be easily extracted, meaning it doesn’t actually encrypt or truly protect the files. This “security” mainly prevents casual users from easily browsing or modifying the app’s code but does little to deter a determined attacker.
asar: false
No issues with cache ;)
This is true.
asar just reduces the bundle size considerably (in my case almost 50% smaller), so it is ideal to use it.
A follow up for https://github.com/kirill-konshin/next-electron-rsc/issues/2#issuecomment-2458552348
Prod run emits errors:
There seems to be a bug in asarUnpack: https://github.com/electron-userland/electron-builder/issues/7264
The following does not work in
demo
:Next.js does not seem to provide
cacheDir
setting: https://github.com/vercel/next.js/blob/canary/packages/next/src/server/image-optimizer.ts#L372Created https://github.com/vercel/next.js/issues/72416