VulcanJS/vulcan-npm

Investigate "barrel" file bundling in Next.js

eric-burel opened this issue · 0 comments

Barrel files are "index.ts" files within folders that reexport code.

In the context of the Next.js app (not packages, bundling them is a different subject), barrel file might lead to pages not being tree-shaken correctly. Eg if page A uses "core/components" a,b,c, and page B uses "core/components" d and e, page B might still have the code of components a,b,c, and pge A the components d and e.

Using "sideEffects": false in app package.json seems to improve that but may have unintended consequences. It's also possible to tweak the Webpack config to indicate which index.ts files are sideEffects free more precisely (eg React components)

See vercel/next.js#12557

Trying "sideEffects": false in package.json didn't have any noticeable effect in Devographics surveyform a this point.