Skip to content

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

Open
@eric-burel

Description

@eric-burel

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions