Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
eric-burel opened this issue Sep 29, 2022 · 0 comments
Open

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

eric-burel opened this issue Sep 29, 2022 · 0 comments
Labels
enhancement New feature or request

Comments

@eric-burel
Copy link
Collaborator

eric-burel commented Sep 29, 2022

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.

@eric-burel eric-burel added the enhancement New feature or request label Sep 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant