Skip to content

transpilePackages doesn't tree-shake barrel export in turborepo #55943

Open
@raphaelbadia

Description

@raphaelbadia

Link to the code that reproduces this issue

https://github.com/raphaelbadia/barrel-exports-transpile-module-not-treeshaking

To Reproduce

  1. clone the repository and run yarn build in the root repository

Current vs. Expected behavior

Following the steps from the previous section, I expected the build output to be very light for the / (home page), something like : λ / 137 B 79.4 kB.

However I instead saw : λ / 13.7 kB 92.9 kB

Three tabs opened, in the client.html one, I clicked the left drawer, chose app/page as the chunk to explore and saw packages that aren't used: CleanShot 2023-09-25 at 11 05 52@2x

Verify canary release

  • I verified that the issue exists in the latest Next.js canary release

Provide environment information

yarn run v1.22.19
$ /Users/raphael/code/billiv/turbotranspilepkg/node_modules/.bin/next info

Operating System:
  Platform: darwin
  Arch: x64
  Version: Darwin Kernel Version 22.3.0: Mon Jan 30 20:39:46 PST 2023; root:xnu-8792.81.3~2/RELEASE_ARM64_T6020
Binaries:
  Node: 18.16.0
  npm: 9.5.1
  Yarn: 1.22.19
  pnpm: 8.6.8
Relevant Packages:
  next: 13.5.3-canary.3
  eslint-config-next: N/A
  react: 18.2.0
  react-dom: 18.2.0
  typescript: 4.9.5
Next.js Config:
  output: N/A


✨  Done in 2.67s.

Which area(s) are affected? (Select all that apply)

SWC transpilation

Additional context

I was trying to understand why my website is so heavy, and decided to create a new project from scratch. I realised that the problem appears as soon as I add a library to the UI package.

Metadata

Metadata

Assignees

No one assigned

    Labels

    SWCRelated to minification/transpilation in Next.js.bugIssue was opened via the bug report template.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions