pica: Uncaught ReferenceError: n is not defined
I’m using image-blob-reduce
in a next.js app. In dev mode it works fine, but in prod mode, I get this error:
Uncaught ReferenceError: n is not defined
It happens in the pica source:
I already tried turning off Terser, did not change anything.
Do you have any ideas what I could change to get this to work?
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 1
- Comments: 20 (5 by maintainers)
@puzrin I could get it to work, but not as-is. I needed to modify the
pica
andimage-blob-reduce
libs in this way:module
in the package.json and notexports
on purpose, because that would cause issues and make image-blob-reduce pick up the non-esm version because it usesrequires
.arguments
which later causes a build error in the client project. It also uses some weirdrequire
magic which I don’t know if it would work when not built with browserify.requireReturnsDefault
option for the commonjs plugin in the rollup config of image-blob-reduce.You can see the code changes here:
And this is the working image-blob-reduce esm module: https://github.com/fabb/image-blob-reduce/blob/pica-esm/dist/image-blob-reduce.esm.mjs
I did not test the non-esm build outputs, so I don’t know if they would still work as expected.
Would you be interested in integrating these changes into your packages? The webworkify part would need to be figured out still, and the non-esm libs of image-blob-reduce would need to be tested.
I ended up using
patch-package
to force using source version. Works fine so far.That works. I don’t know why you have problems.
At current moment i don’t know good alternatives to existing approach. Everything was already considered.
I’m closing this, but if you find anything to mention on readme - let me know.