nextjs - ✅(Solved) Fix Importing types from "server-only" w/ `"verbatimModuleSyntax": true` errors after #90907 [1 pull requests, 1 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#92025Fetched 2026-04-08 01:40:09
View on GitHub
Comments
0
Participants
1
Timeline
4
Reactions
1
Participants
Timeline (top)
cross-referenced ×1issue_type_added ×1labeled ×1subscribed ×1

Error Message

After upgrading to Next.js 16.2.1 (after canary builds that included #90907), import { type X } from a server-only module inside a "use client" component now throws a boundary error.

Fix Action

Fixed

PR fix notes

PR #92032: fix(turbopack): ignore type-only import edges

Description (problem / solution / changelog)

Summary

  • skip Turbopack module-evaluation edges for imports that are erased at runtime because they are entirely type-only
  • ignore named type-only specifiers when recording imported symbols so client graphs do not keep server-only modules alive through import { type X }
  • add focused analyzer tests for full type-only, named type-only, and mixed runtime imports

Fixes #92025.

Testing

  • cargo test -p turbopack-ecmascript test_analyze -- --nocapture
  • cargo fmt --check --all -- turbopack/crates/turbopack-ecmascript/src/analyzer/imports.rs

Changed files

Code Example

// lib/server.ts
  import "server-only";
  export type MyType = boolean;

  // components/client.tsx
  "use client";
  import { type MyType } from "@/lib/server";

  export function MyComponent({ value }: { value: MyType }) { ... }

---

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: 10
Binaries:
  Node: 25.0.0
  npm: 11.6.2
  Yarn: 1.22.19
  pnpm: 10.28.1
Relevant Packages:
  next: 16.2.0-canary.94 // There is a newer canary version (16.2.1-canary.11) available, please upgrade! 
  eslint-config-next: N/A
  react: 19.2.4
  react-dom: 19.2.4
  typescript: 5.9.3
Next.js Config:
  output: N/A
RAW_BUFFERClick to expand / collapse

Link to the code that reproduces this issue

https://github.com/kevin-admoai/types-server

To Reproduce

// lib/server.ts
import "server-only";
export type MyType = boolean;

// components/client.tsx
"use client";
import { type MyType } from "@/lib/server";

export function MyComponent({ value }: { value: MyType }) { ... }

You're importing a module that depends on "server-only" into a React Client Component module. This API is only available in Server Components but one of its parents is marked with "use client", so this module is also a Client Component.

Is it possible to get some feedback on this? Is this desired behavior or not? This does not happen in Webpack, there are no issues, only in turbopack after 16.2.0-canary.94.

tsconfig.json: { "compilerOptions": { "verbatimModuleSyntax": true } }

Current vs. Expected behavior

After upgrading to Next.js 16.2.1 (after canary builds that included #90907), import { type X } from a server-only module inside a "use client" component now throws a boundary error.

This did not happen previously, and does not happen with webpack.

Also maybe related https://github.com/vercel/next.js/issues/91906

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: 10
Binaries:
  Node: 25.0.0
  npm: 11.6.2
  Yarn: 1.22.19
  pnpm: 10.28.1
Relevant Packages:
  next: 16.2.0-canary.94 // There is a newer canary version (16.2.1-canary.11) available, please upgrade! 
  eslint-config-next: N/A
  react: 19.2.4
  react-dom: 19.2.4
  typescript: 5.9.3
Next.js Config:
  output: N/A

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

Turbopack

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

next dev (local)

Additional context

N/A

extent analysis

Fix Plan

To resolve the issue, you need to refactor your code to avoid importing server-only modules into client components. Here are the steps:

  • Create a new file for the shared type, e.g., types.ts:

// types.ts export type MyType = boolean;

*   Import the shared type in both the server and client components:
    ```tsx
// lib/server.ts
import type { MyType } from "@/types";

// components/client.tsx
import type { MyType } from "@/types";
  • Ensure that the types.ts file does not import any server-only modules.

Verification

After applying the fix, verify that the error is resolved by running next dev and checking the console for any errors. The application should compile and run without any issues related to importing server-only modules into client components.

Extra Tips

  • Make sure to keep server-only logic separate from client-side code to avoid similar issues in the future.
  • Consider using a linter or code analyzer to detect and prevent such issues early in the development process.
  • If you're using a monorepo or a complex project structure, ensure that your tsconfig.json files are properly configured to handle the different environments and module types.

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