[Bug]: Published AG Grid packaging prevents effective route-level bundle splitting
Link to reproducible scenario
https://codesandbox.io/p/github/ESkeltonUniverus/ag-grid-bundle-issue/master?import=true
Describe the bug
Steps to reproduce
- Clone the repro repo and install dependencies. a. node 24+ (nvm install 24) b. pnpm (npm i pnpm -g) c. pnpm install
- Run the published-package build: -
pnpm build - Open:
projects/ag-grid-bundle-issue/dist/stats.html
- Inspect the chunk graph for the lazy-route app:
SimpleGridPageimports onlyClientSideRowModelModule,ModuleRegistry, andthemeQuartzComplexGridPageimports those same symbols plusCsvExportModule,PaginationModule,RowSelectionModule, andNumberFilterModule
- Run the source-resolved build:
pnpm build:local
- Open:
projects/ag-grid-bundle-issue/dist-source/stats.html
- Compare both visualizer outputs, especially:
- the shared AG Grid chunk
- the
SimpleGridPageroute chunk - the
ComplexGridPageroute chunk
Actual behaviour
With the published package build, AG Grid code is split too coarsely.
Code that is only used by ComplexGridPage is pulled into shared output more aggressively than expected, so the simpler route ends up paying for AG Grid functionality it does not use.
Published package mode: AG Grid code used only by the complex route is still heavily represented in shared output (which is index.esm....)
AG Grid Community shows as one big block in rollup-plugin-visualizer
Expected behaviour
AG Grid code should split along the lazy-route boundaries more effectively.
Shared/core AG Grid code can remain shared, but optional modules used only by ComplexGridPage should stay primarily in the complex route chunk rather than being hoisted into common output.
The source-resolved build demonstrates a much closer version of the expected chunk shape.
Source mode: complex-only AG Grid modules stay much closer to the complex route chunk, with less over-sharing into the common bundle.
Ag Grid Community shows modules instead of one big box
More information
This repro directly demonstrates the issue with ag-grid-community, but the same packaging pattern likely affects ag-grid-enterprise as well.
The key comparison is that the app code is the same in both cases. The only meaningful difference is how AG Grid is resolved:
- published package mode uses the installed
ag-grid-communitypackage - source mode aliases
ag-grid-communityto the local AG Grid source entry
Important context about the source-mode comparison:
- This source-mode setup was added strictly to show the chunk shape I would expect to see from downstream bundling. It is a comparison aid, not a claim that this is a production-ready or officially supported way to consume AG Grid.
- Source mode depends on a Git submodule checkout of AG Grid under
packages/ag-gridso the app can alias directly to the local source tree. - Because of that, CodeSandbox is not a good environment for the full repro. It struggles to clone the AG Grid repository due to its size, so the source-mode comparison is realistically something that needs to be cloned and run locally.
Because the chunking improves when the package is resolved from source, this appears to be caused by the published AG Grid package structure rather than by the consuming app’s route setup.
To be clear, this does not claim that the package is not tree-shakeable at all. The issue is that, while the published package can still be tree-shaken, it is much less splitable at route/chunk boundaries than I would expect. If my app were to strictly contain just the SimpleGridPage, it would be tree shaken successfully
From a consumer perspective, this also feels like a regression from the earlier modular package model. With the older modularized package layout, bundling behavior was more flexible and optional capabilities were easier to keep isolated. With the current published package shape, the result is much larger, less flexible bundle “boxes,” which makes downstream route-level splitting less effective.
I used react 19 with a combination of [email protected] (rollup under the hood) and vite@beta (rolldown under the hood). Both bundlers exhibit the same behavior. I strongly suspect this is NOT specific to either of those bundlers or react itself
Repro repo:
https://github.com/ESkeltonUniverus/ag-grid-bundle-issue
Version
35.1.0
Does the issue occur for a specific framework only?
All languages
Is the issue only observable on a specific browser?
All browsers
Source: ag-grid/ag-grid