You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
nth_identifer (default: an internal mangler that weights based on character frequency analysis) -- Pass an object with a get(n) function that converts an ordinal into the nth most favored (usually shortest) identifier. Optionally also provide reset(), sort(), and consider(chars, delta) to use character frequency analysis of the source code.
So following that, I constructed the following (a minimal reproduction of it, anyway).
> vite v5.2.12 building for production...
> ✓ 1 modules transformed.
> x Build failed in 24ms
> error during build:
> Cannot set property code of which has only a getter
> at logPluginError (file:///reproduction/node_modules/rollup/dist/es/shared/parseAst.js:894:16)
> at file:///reproduction/node_modules/rollup/dist/es/shared/node-entry.js:19800:26
> at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
> at async transformChunk (file:///reproduction/node_modules/rollup/dist/es/shared/node-entry.js:17934:16)
> at async file:///reproduction/node_modules/rollup/dist/es/shared/node-entry.js:18008:17
> at async Promise.all (index 0)
> at async transformChunksAndGenerateContentHashes (file:///reproduction/node_modules/rollup/dist/es/shared/node-entry.js:18003:5)
> at async renderChunks (file:///reproduction/node_modules/rollup/dist/es/shared/node-entry.js:17912:137)
> at async Bundle.generate (file:///reproduction/node_modules/rollup/dist/es/shared/node-entry.js:18145:13)
> at async file:///reproduction/node_modules/rollup/dist/es/shared/node-entry.js:20692:27
After removing two catches in the node modules to find the origin of the problem, I got
error during build:
DataCloneError: (n) => {
return "prefix_" + n.toString();
} could not be cloned.
at new DOMException (node:internal/per_context/domexception:53:5)
at Worker.postMessage (node:internal/worker:366:5)
at file:///reproduction/node_modules/vite/dist/node/chunks/dep-BKbDVx1T.js:15135:14
at new Promise (<anonymous>)
at Worker.run (file:///reproduction/node_modules/vite/dist/node/chunks/dep-BKbDVx1T.js:15132:12)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async Object.renderChunk (file:///reproduction/node_modules/vite/dist/node/chunks/dep-BKbDVx1T.js:15382:25)
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.
vite v5.2.12 building for production...
✓ 1 modules transformed.
x Build failed in 24ms
error during build:
Cannot set property code of which has only a getter
at logPluginError (file:///reproduction/node_modules/rollup/dist/es/shared/parseAst.js:894:16)
at file:///reproduction/node_modules/rollup/dist/es/shared/node-entry.js:19800:26
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async transformChunk (file:///reproduction/node_modules/rollup/dist/es/shared/node-entry.js:17934:16)
at async file:///reproduction/node_modules/rollup/dist/es/shared/node-entry.js:18008:17
at async Promise.all (index 0)
at async transformChunksAndGenerateContentHashes (file:///reproduction/node_modules/rollup/dist/es/shared/node-entry.js:18003:5)
at async renderChunks (file:///reproduction/node_modules/rollup/dist/es/shared/node-entry.js:17912:137)
at async Bundle.generate (file:///reproduction/node_modules/rollup/dist/es/shared/node-entry.js:18145:13)
at async file:///reproduction/node_modules/rollup/dist/es/shared/node-entry.js:20692:27
Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
Make sure this is a Vite issue and not a framework-specific issue. For example, if it's a Vue SFC related bug, it should likely be reported to vuejs/core instead.
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:
Like CSS preprocessing, maybe we could have a fallback mode that runs on the current thread if there's no serializable values, but that may make things slower.
Or force serialize functions and require the definition to always be isolated.
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
The text was updated successfully, but these errors were encountered: