nextjs - ✅(Solved) Fix Typescript(~20MB) present in build .next/standalone/node_modules when using standalone output [2 pull requests, 6 comments, 6 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
vercel/next.js#86981Fetched 2026-04-08 02:08:09
View on GitHub
Comments
6
Participants
6
Timeline
19
Reactions
0
Timeline (top)
commented ×6labeled ×3subscribed ×3cross-referenced ×2

Root Cause

I would expected that in the .next/standalone/node_modules/typescript there would be no Typescript because it is not runtime dependency and it has a huge size.

Fix Action

Fixed

PR fix notes

PR #87262: fix(turbopack): prevent TypeScript from being bundled in standalone output

Description (problem / solution / changelog)

What?

Exclude dev-only dependencies from being traced into the .next/standalone output when using Turbopack, preventing large build-time tools (e.g. TypeScript) from being bundled into the runtime artifact.

Why?

When output: "standalone" is enabled with Turbopack, devDependencies are currently traced and copied into the standalone bundle, even though they are never required at runtime. This leads to significantly larger standalone outputs (e.g. typescript ~20 MB) and unexpected Docker image bloat.

Webpack does not exhibit this behavior, so this is a Turbopack-specific issue.

How?

Treat packages declared as devDependencies as untraced externals during standalone output generation.

Update the server resolver logic to respect this distinction while keeping existing external resolution behavior unchanged.

This ensures only runtime-required dependencies are included in .next/standalone.

Fixes and closes #86981

Changed files

  • crates/next-core/src/next_server/context.rs (modified, +10/-2)
  • crates/next-core/src/next_server/resolve.rs (modified, +35/-1)
  • crates/next-core/src/util.rs (modified, +20/-0)

PR #88321: Don't import typescript at runtime

Description (problem / solution / changelog)

Closes https://github.com/vercel/next.js/issues/86981 Closes PACK-6209

Don't import typescript at runtime to determine the tsconfig, to be able to transpile next.config.ts.

Instead, read the tsconfig file directly.

Changed files

  • packages/next/src/build/next-config-ts/transpile-config.ts (modified, +102/-74)
  • packages/next/src/lib/typescript/writeConfigurationDefaults.ts (modified, +1/-3)
  • packages/next/src/server/config.ts (modified, +1/-2)
  • test/production/next-server-nft/next-server-nft.test.ts (modified, +0/-1)

Code Example

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 25.1.0: Mon Oct 20 19:32:41 PDT 2025; root:xnu-12377.41.6~2/RELEASE_ARM64_T6000
  Available memory (MB): 16384
  Available CPU cores: 8
Binaries:
  Node: 24.5.0
  npm: 11.5.1
  Yarn: 1.22.22
  pnpm: 9.15.9
Relevant Packages:
  next: 16.0.8 // Latest available version is detected (16.0.8).
  eslint-config-next: N/A
  react: 19.2.1
  react-dom: 19.2.1
  typescript: 5.9.3
Next.js Config:
  output: standalone
RAW_BUFFERClick to expand / collapse

Link to the code that reproduces this issue

https://github.com/BlvckParrot/nextjs-issue-typescript-in-standalone-output

To Reproduce

  1. create new next app pnpx create-next-app@latest(with defaults)
  2. change output: "standalone" in next.config.ts
  3. run build pnpm build

Then see directory .next/standalone/node_modules/typescript

Current vs. Expected behavior

I would expected that in the .next/standalone/node_modules/typescript there would be no Typescript because it is not runtime dependency and it has a huge size.

<img width="323" height="810" alt="Image" src="https://github.com/user-attachments/assets/5a7e1fdb-1931-4502-bd4c-20ef1ba6bee4" />

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 25.1.0: Mon Oct 20 19:32:41 PDT 2025; root:xnu-12377.41.6~2/RELEASE_ARM64_T6000
  Available memory (MB): 16384
  Available CPU cores: 8
Binaries:
  Node: 24.5.0
  npm: 11.5.1
  Yarn: 1.22.22
  pnpm: 9.15.9
Relevant Packages:
  next: 16.0.8 // Latest available version is detected (16.0.8).
  eslint-config-next: N/A
  react: 19.2.1
  react-dom: 19.2.1
  typescript: 5.9.3
Next.js Config:
  output: standalone

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

Turbopack

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

next build (local)

Additional context

I have tried this also with bun, deno, pnpm, npm, all with the same result.

extent analysis

TL;DR

  • The issue can be mitigated by exploring ways to exclude TypeScript from the .next/standalone/node_modules directory during the build process.

Guidance

  • Review the next.config.ts file for any configurations that might be including TypeScript in the standalone build.
  • Investigate the use of pnpm build flags or next configuration options to optimize the build and exclude unnecessary dependencies.
  • Consider using a custom webpack or next configuration to explicitly exclude TypeScript from the build output.
  • Check if there are any open issues or discussions in the Next.js repository related to this problem that might provide a solution or workaround.

Example

No specific code example can be provided without further details on the custom configurations or modifications made to the next.config.ts file.

Notes

The provided information suggests that the issue is related to the next build process and the inclusion of TypeScript in the standalone output. However, without more specific details on the configurations or customizations made, it's challenging to provide a precise solution.

Recommendation

  • Apply workaround: The best approach seems to be applying a workaround, such as customizing the build process to exclude TypeScript, as the issue appears to be related to the build configuration rather than a version-specific problem that could be resolved by upgrading.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

nextjs - ✅(Solved) Fix Typescript(~20MB) present in build .next/standalone/node_modules when using standalone output [2 pull requests, 6 comments, 6 participants]