Open farseekers opened 3 months ago
Seems like it's because we run terser with a worker, and the options can't be properly serialized. We should definitely fix and provide a better error message, but for the serialization it's not always possible to assume that a function is isolated for serializing. I guess the solution would be either:
Thanks very much for the confirmation that I wasn't missing something.
@bluwy this option is needed to have consistent names between builds so that chunks stay the same as much as possible, thereby reducing traffic.
Can't you assume that if a function is passed, it is self-contained?
Failing that, how about a special option type where you can provide source code to eval?
Describe the bug
I'm attempting to prefix mangled variable names.
https://vitejs.dev/config/build-options#build-terseroptions told me that under
build.terserOptions
, I could addhttps://terser.org/docs/api-reference/#minify-options
https://terser.org/docs/options/#mangle-properties-options
So following that, I constructed the following (a minimal reproduction of it, anyway).
However, it fails to work, raising an error.
After removing two catches in the node modules to find the origin of the problem, I got
Please let me know if I've missed something, as it would seem that the inability to clone a function is preventing this feature from working.
Reproduction
https://github.com/farseekers/terserOptions
Steps to reproduce
npm install
node index.js
./node_modules/.bin/vite build
, raising an errorSystem Info
Used Package Manager
npm
Logs
Validations