AG Grid: ES Modules & CommonJS

  |   Testing

AG Grid v30.0 Change to ES Modules

As part of AG Grid v30.0 and AG Charts v8.0 we made the decision to use ES Modules by default (instead of CommonJS, as in previous versions). There were two motivators for this - user demand and decreased application bundle size.

By making this switch we were able to allow the grid part of user applications to shrink by an average of 10-15% with no changes required by developers. This is obviously a fairly substantial decrease resulting in quicker load times and an overall improved end user experience.

Unintended Consequences

However, despite extensive testing it turns out that many downstream testing tools (Jest for example) do not yet support ES Modules - at least not without extra configuration.

We resolved many of these issues but also felt that this was creating unnecessary noise and complications for some users - especially those users that favoured simplicity over a smaller bundle size.

A Compromise

After listening to the community and following internal discussions we are going to revert the changes for Packages (i.e. ag-grid-community/ag-grid-enterprise) - from version 30.0.6 onwards packages will once again default to CommonJS, while Modules (i.e. @ag-grid-community/xxx / @ag-grid-enterprise/xxx) will continue to default to ES Modules.

What this means is that if you favour a simpler implementation then you should use Packages while if your main concern is bundle size then you should continue (or switch to) Modules.

If you use Packages you shouldn't need to make any configuration changes to support downstream tools whereas if you choose to use Modules you may need to.

Please refer to the Testing section of the documentation for more information about potential configuration changes required.

Read more posts about...