Skip to content

fix(rollup-plugin): use stable chunk ids in symbol-set mode - #4686

Draft
Cypher-Aura-19 wants to merge 2 commits into
PostHog:mainfrom
Cypher-Aura-19:fix/4670-stable-rollup-chunk-ids
Draft

fix(rollup-plugin): use stable chunk ids in symbol-set mode#4686
Cypher-Aura-19 wants to merge 2 commits into
PostHog:mainfrom
Cypher-Aura-19:fix/4670-stable-rollup-chunk-ids

Conversation

@Cypher-Aura-19

Copy link
Copy Markdown

Problem

The default symbol-set renderChunk path injected a random UUID into each chunk before Rollup calculated [hash] filenames. Because the random ID became part of the emitted content, identical builds produced different chunk hashes and renamed every JS chunk on every build, breaking long-term asset caching and causing Failed to fetch dynamically imported module errors on stale tabs.

Changes

  • Use content-derived chunk IDs in symbol-set mode, matching the stable behavior already used by event mode
  • Update unit coverage so identical content keeps the same chunk ID and changed content gets a different ID
  • Add a Vite regression test verifying identical builds keep identical [hash] filenames
  • Add a patch changeset for @posthog/rollup-plugin

Testing

  • Rollup-plugin unit tests: 26/26 passing

  • Lint on modified rollup-plugin files: passing

  • Standalone regression verification confirms:

    • identical content → same chunk ID and hash
    • changed content → different chunk ID and hash
    • reverting the fix restores the failing random-hash behavior
  • The Vite functional test cannot run locally on Windows because this repository intentionally installs native bindings only for Linux/macOS; it should run in CI

Closes #4670

Release info Sub-libraries affected

Libraries affected

  • @posthog/rollup-plugin

Checklist

  • Tests for new code
  • Accounted for the impact of any changes across different platforms
  • Accounted for backwards compatibility of any changes (no breaking changes!)
  • Took care not to unnecessarily increase the bundle size

If releasing new changes

  • Ran pnpm changeset to generate a changeset file

🤖 Agent context

Autonomy: Human-driven (agent-assisted)

Implemented with Claude Code under human direction and review. The root cause was confirmed in the default symbol-set renderChunk path, the fix is limited to using the existing content-derived chunk-ID helper, and the regression was verified with unit tests and a standalone content-hash check. The Vite functional test was added but could not be executed locally on Windows due to the repository's Linux/macOS-only native binding configuration.

@Cypher-Aura-19
Cypher-Aura-19 requested review from a team as code owners August 29, 2026 10:19
@marandaneto marandaneto self-assigned this Aug 31, 2026
Cypher-Aura-19 and others added 2 commits August 31, 2026 13:32
Use the content-derived createStableChunkId in the default symbol-set renderChunk path so identical builds keep the same chunk id and the same [hash] file names instead of renaming every chunk on every build.

Co-Authored-By: Claude <noreply@anthropic.com>
Comment thread packages/plugin-utils/src/cli.ts
@marandaneto
marandaneto force-pushed the fix/4670-stable-rollup-chunk-ids branch from 5f88aca to b396894 Compare August 31, 2026 11:33
@marandaneto

Copy link
Copy Markdown
Member

cc @PostHog/team-error-tracking i reviewed and fixed an issue, pls double check

@ablaszkiewicz

Copy link
Copy Markdown
Contributor

@marandaneto we can't use stable chunk ids in symbol set mode because if we do and some chunks are the same across releases, we lose correct release attribution for versions which are still using old chunks. So two things happen here:

  • if somebody runs this without any flags (vast majority of people in JS world), you get an error that this chunk already belongs to a different release,
  • if somebody uses force flag, we overwrite the release this chunk belongs to to a new one so old versions of the app report exceptions as if they were the newest release.

In event mode we can do this because release is injected into the chunk and attached to the event (and not fetched from the symbol set)

We need to solve this in a different way. I'll think about this.

@ablaszkiewicz ablaszkiewicz left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As per my comment above. Let me see what's up with this and come up with a better solution

@marandaneto
marandaneto marked this pull request as draft August 31, 2026 11:43
@marandaneto

Copy link
Copy Markdown
Member

As per my comment above. Let me see what's up with this and come up with a better solution

thanks for the review and good catch
moving to draft until we know how to solve this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

@posthog/rollup-plugin 1.4.9: random chunk IDs injected in renderChunk change every content hash, so every build renames every chunk

3 participants