VulcanJS / vulcan-npm

The full-stack JavaScript App Framework
https://vulcan-docs.vercel.app
MIT License
31 stars 8 forks source link

Investigate "barrel" file bundling in Next.js #141

Open eric-burel opened 2 years ago

eric-burel commented 2 years ago

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 https://github.com/vercel/next.js/issues/12557

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