React Vendoring and Server Layer Boundaries

VerifiedSafe

Guide for editing vendored React packages and the react-server layer boundaries in Next.js. Covers entry-base.ts, type declarations, Turbopack remap, and ComponentMod access patterns.

Sby Skills Guide Bot
DevelopmentAdvanced
8/29/2026
Claude Code
#react#vendoring#nextjs#turbopack#react-server

Recommended for

Automated summary

Governs edits to Next.js's vendored React packages and the react-server layer boundary, including the rule that all Flight APIs must be reached through entry-base.ts.

Strengths

  • States a crisp boundary rule: every react-server-dom-webpack/* import must go through entry-base.ts
  • Gives a concrete recipe for adding a Node-only React API (type declaration, guarded export, ComponentMod access)
  • Clarifies exactly where eslint-disable comments belong around guarded require() calls
  • Flags the silent remap to react-server-dom-turbopack that misleads stack-trace debugging

Limitations

  • Tightly coupled to the Next.js monorepo and unusable outside it
  • Assumes familiarity with pnpm build, taskfile.js and rspack layer config
  • Does not explain the Flight protocol or React internals, only the plumbing rules
When to use it

Use it whenever a change touches vendored React packages, $$compiled.internal.d.ts, entry-base.ts, or any react-server-dom-* import.

When not to use it

Avoid it for ordinary application-level React work or for projects that do not vendor React the way Next.js does.

Security analysis

Safe
Quality score88/100

This is an internal documentation skill describing React vendoring boundaries, type declarations, guarded requires, and Turbopack remapping. It contains no destructive commands, secret exfiltration, obfuscated payloads, or instructions to disable safety mechanisms; the only code snippet is a guarded module import pattern for legitimate Next.js internals.

No concerns found

How this analysis is made

Examples

Add a Node-only React API
Add `prerenderToNodeStream` from `react-server-dom-webpack/server.node` to Next.js: declare the types in `packages/next/types/$$compiled.internal.d.ts`, export it from `entry-base.ts` behind the `__NEXT_USE_NODE_STREAMS` env guard, and access it via `ComponentMod` in the renderer.
Debug a react-server condition error
I get "The react-server condition must be enabled" in production workers but not in dev. Find which file outside `entry-base.ts` imports from `react-server-dom-webpack/static` and move it behind the `ComponentMod` boundary.
Fix ESLint suppression placement
A guarded `require()` in `stream-ops.node.ts` trips `import/no-extraneous-dependencies`. Show me the correct scoped eslint-disable/enable block placement for this pattern.

name: react-vendoring description: > React vendoring and react-server layer boundaries. Use when editing entry-base.ts, $$compiled.internal.d.ts, compiled/react* packages, or taskfile.js copy_vendor_react. Covers the entry-base.ts boundary (all react-server-dom-webpack/* imports must go through it), vendored React channels, type declarations, Turbopack remap to react-server-dom-turbopack, ComponentMod access patterns, and ESLint suppression for guarded requires. metadata: internal: true

React Vendoring

Use this skill for changes touching vendored React, react-server-dom-webpack/*, or react-server layer boundaries.

App Router Vendoring

React is NOT resolved from node_modules for App Router. It's vendored into packages/next/src/compiled/ during pnpm build (task: copy_vendor_react() in taskfile.js). Pages Router resolves React from node_modules normally.

  • Two channels: stable (compiled/react/) and experimental (compiled/react-experimental/). The runtime bundle webpack config aliases to the correct channel via makeAppAliases({ experimental }).

entry-base.ts Boundary

Only entry-base.ts is compiled in rspack's (react-server) layer. ALL imports from react-server-dom-webpack/* (Flight server/static APIs) must go through entry-base.ts. Other files like stream-ops.node.ts or app-render.tsx must access Flight APIs via the ComponentMod parameter (which is the entry-base.ts module exposed through the app-page.ts build template).

Direct imports from react-server-dom-webpack/server.node or react-server-dom-webpack/static in files outside entry-base.ts will fail at runtime with "The react-server condition must be enabled". Dev mode may mask this error, but production workers fail immediately.

Type Declarations

packages/next/types/$$compiled.internal.d.ts contains declare module blocks for vendored React packages. When adding new APIs (e.g. renderToPipeableStream, prerenderToNodeStream), you must add type declarations here. The bare specifier types (e.g. declare module 'react-server-dom-webpack/server') are what source code in src/ imports against.

Adding Node.js-Only React APIs

These exist in .node builds but not in the type definitions. Steps:

  1. Add type declarations to $$compiled.internal.d.ts.
  2. Export the API from entry-base.ts behind a process.env guard.
  3. Access it via ComponentMod in other files.
// In entry-base.ts (react-server layer) only:
/* eslint-disable import/no-extraneous-dependencies */
export let renderToPipeableStream: ... | undefined
if (process.env.__NEXT_USE_NODE_STREAMS) {
  renderToPipeableStream = (
    require('react-server-dom-webpack/server.node') as typeof import('react-server-dom-webpack/server.node')
  ).renderToPipeableStream
} else {
  renderToPipeableStream = undefined
}
/* eslint-enable import/no-extraneous-dependencies */

// In other files, access via ComponentMod:
ComponentMod.renderToPipeableStream!(payload, clientModules, opts)

ESLint Practical Rule

For guarded runtime require() blocks that need import/no-extraneous-dependencies suppression, prefer scoped block disable/enable. If using eslint-disable-next-line, the comment must be on the line immediately before the require() call, NOT before the const declaration. When the const and require() are on different lines, this is error-prone.

Turbopack Remap

react-server-dom-webpack/* is silently remapped to react-server-dom-turbopack/* by Turbopack's import map. Code says "webpack" everywhere, but Turbopack gets its own bindings at runtime. This affects debugging: stack traces and error messages will reference the turbopack variant.

Related Skills

  • $flags - flag wiring (config/schema/define-env/runtime env)
  • $dce-edge - DCE-safe require patterns and edge constraints
  • $runtime-debug - reproduction and verification workflow

From the file to a first result

The download contains exactly the content displayed on this page. This copy may differ from the latest version in the source repository.

View the source and supporting files

This download contains SKILL.md only. Any scripts, references, templates and dependencies are not included. Get the required files from the source, preserving their directory structure, before continuing.

1. Download the file

Download SKILL.md

From the root of a test project, save the file as .skill-downloads/react-vendoring-and-server-layer-boundaries-mte1lko1/SKILL.md, or use the command below. This folder is for inspecting the skill before installation.

Command for macOS/Linux or WSL: requires a POSIX shell and curl. On Windows without WSL, use the download button and create the folder manually.

mkdir -p '.skill-downloads/react-vendoring-and-server-layer-boundaries-mte1lko1' && curl --fail --show-error --location 'https://skills-guides.com/api/skills/react-vendoring-and-server-layer-boundaries-mte1lko1/download' --output '.skill-downloads/react-vendoring-and-server-layer-boundaries-mte1lko1/SKILL.md.part' && mv '.skill-downloads/react-vendoring-and-server-layer-boundaries-mte1lko1/SKILL.md.part' '.skill-downloads/react-vendoring-and-server-layer-boundaries-mte1lko1/SKILL.md'

2. Check prerequisites

Read SKILL.md before using it. If it references scripts or external services, inspect them and prepare the required access in your test environment.

No recognized prerequisites section in this file. This does not mean it is self-contained: libraries, tools and access requirements may be mentioned elsewhere in the content or source repository.

The platforms on this page are catalog indications. The paths below follow tool documentation; they do not prove this skill has been run in those tools. No minimum tool version is confirmed for this listing.

3. Load the skill

After inspection, copy the complete folder into your project using one of the commands below, then open a new tool session. The command stops if a folder with the same name already exists: compare the files before replacing it.

Claude Code
test -f '.skill-downloads/react-vendoring-and-server-layer-boundaries-mte1lko1/SKILL.md' && test -s '.skill-downloads/react-vendoring-and-server-layer-boundaries-mte1lko1/SKILL.md' && mkdir -p '.claude/skills' && test ! -e '.claude/skills/react-vendoring' && cp -R '.skill-downloads/react-vendoring-and-server-layer-boundaries-mte1lko1' '.claude/skills/react-vendoring'

OpenSkills

OpenSkills must already be installed. The local install/read procedure is checked with OpenSkills 1.5.0, which requires Node.js ≥ 20.6.0. Catalog slugs are not resolved automatically.

Official OpenSkills installation
openskills install './.skill-downloads/react-vendoring-and-server-layer-boundaries-mte1lko1'

openskills read 'react-vendoring-and-server-layer-boundaries-mte1lko1'

Reading should display the installed file content and its base directory. It does not run the skill or install its dependencies.

For an agent that reads AGENTS.md, then sync the index. This command changes AGENTS.md: review the diff before using it.

openskills sync

Manual method or another tool: attach SKILL.md to a conversation, or open it in an agent that can read files. Include any required supporting resources. No universal folder is recognized by every tool.

4. Try a first task

Use a short, synthetic input: an API endpoint, a small document or an interface brief. In a new conversation, attach the file or give the agent its path, then adapt this request:

Read .skill-downloads/react-vendoring-and-server-layer-boundaries-mte1lko1/SKILL.md and apply its instructions to this example: [describe a test input]. Identify any missing files, dependencies or access. Produce the result requested by the skill without inventing data or running unreviewed scripts.

Expected result: output matching the skill instructions, or a precise list of missing prerequisites. A read confirmation alone does not validate a first use. If an external resource is unavailable, that path remains untested.

Related skills