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

Tree shaking in middleware doesn't work #75180

Open
amannn opened this issue Jan 22, 2025 · 0 comments
Open

Tree shaking in middleware doesn't work #75180

amannn opened this issue Jan 22, 2025 · 0 comments
Labels
Middleware Related to Next.js Middleware.

Comments

@amannn
Copy link
Contributor

amannn commented Jan 22, 2025

Link to the code that reproduces this issue

amannn/nextjs-bug-repro-middleware@6c442b0

To Reproduce

  1. Run pnpm i && pnpm build
  2. See console output and analyzer output

Current vs. Expected behavior

Console output:

ƒ Middleware                             1.07 MB

I'd expect getMessages to not be bundled into the middleware as it's not used there.

See also the analyzer output:

Image

Provide environment information

Operating System:
  Platform: darwin
  Arch: x64
  Version: Darwin Kernel Version 23.6.0: Mon Jul 29 21:13:00 PDT 2024; root:xnu-10063.141.2~1/RELEASE_X86_64
  Available memory (MB): 16384
  Available CPU cores: 12
Binaries:
  Node: 20.11.1
  npm: 10.2.4
  Yarn: 1.22.22
  pnpm: 9.15.4
Relevant Packages:
  next: 15.1.5 // Latest available version is detected (15.1.5).
  eslint-config-next: N/A
  react: 19.0.0
  react-dom: 19.0.0
  typescript: 5.7.3
Next.js Config:
  output: N/A

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

Middleware

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

next build (local)

Additional context

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Middleware Related to Next.js Middleware.
Projects
None yet
Development

No branches or pull requests

1 participant