plugin-terser does not share nameCache between minify invocations when chunking across multiple entrypoint and common files

Open
#1,970 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
45/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
javascript
Domain
tooling

Research direction

Start with the linked StackBlitz reproduction and inspect plugin-terser's minify invocations, focusing on how nameCache is handled across chunks and entrypoints. Confirm the issue by comparing the mangled Foo._bar() names in dist/common.js and dist/entry2.js; done means the shared nameCache produces matching property names.

Written by the indexing model from the issue text.

Description

Expected Behavior

plugin-terser shares the nameCache between minify invocations when rollup is configured to create multiple entry files and common files.

Actual Behavior

plugin-terser does not share the nameCache when rollup is configured to create multiple entry files and common files, this results in property mangling where names do not match between chunks.

Additional Information

In the linked reproduction observe that

  • in file dist/common.js the method Foo._bar() is renamed to .o().
  • in file dist/entry2.js the method Foo._bar() is renamed to .m().

If you inspect the execution of the terser plugin, it is observed that the nameCache is not shared between invocations of minify. This is true even for maxWorkers: 1.

Dominant language
JavaScript
Stars
3.8k
Forks
635
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from rollup/plugins

All issues in rollup/plugins

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.