
Dce Edge
vercel/next.jsOfficial
Conditional require() and edge-runtime guardrails for webpack DCE in Next.js builds.
- skills.sh installs
- 842
- GitHub stars
- 143.6K
- last updated
- May 16, 2026
What it does
- Covers DCE-safe
require()patterns:if/elsebranching, TypeScript definite assignment, and theNEXT_RUNTIMEversus real feature flag distinction - Includes a compile-time switcher pattern for node and web variants, exemplified by
stream-ops.tsanddebug-channel-server.ts - Enforces forcing feature flags to
falsefor edge builds indefine-env.ts, sonode:streamimports never resolve - Designed for editing
define-env-plugin.ts,app-page.ts, andstream-utilswhen changing edge or Node-only code paths
Install
$ npx -y skills add vercel/next.js --skill dce-edge -yInstalls into .agents/skills for every agent it finds here, and .claude/skills for Claude Code.
Files
DCE + Edge
Use this skill when changing conditional require() paths, Node-only imports, or edge/runtime branching.
DCE-Safe require() Pattern
Webpack only DCEs a require() when it sits inside the dead branch of an if/else whose condition DefinePlugin can evaluate at compile time.
// CORRECT - webpack can eliminate the dead branch
if (process.env.__NEXT_USE_NODE_STREAMS) {
require('node:stream')
} else {
// web path
}
What does NOT work:
- Early-return/throw guards: webpack doesn't do control-flow analysis for throws/returns, so the
require()is still traced. - Bare
ifwithoutelse: works for inlinenode:*specifiers but NOT forrequire('./some-module')that pulls a new file into the module graph.
Always test edge changes with pnpm test-start-webpack on test/e2e/app-dir/app/standalone.test.ts (has edge routes), not with NEXT_SKIP_ISOLATE=1 which skips the full webpack compilation.
TypeScript + DCE Interaction
Details
- Repository
- github.com/vercel/next.js
- Categories
- Frontend & UI Code, Backend & APIs
- First seen
- Apr 16, 2026
More from vercel/next.js
All 14Similar to Dce Edge
More Frontend & UI Code
flagsSkillvercel/next.js900 installsStep-by-step guide for wiring a new or changed Next.js experimental flag from type declaration through runtime bundles.
nextjsPluginvercel/next.js143.7K starsOfficial Next.js skills: adopt and optimize Cache Components, adopt Partial Prefetching, and verify runtime behavior against a running dev server.
netlify-edge-functionsSkillnetlify/context-and-tools3.5K installsEdge-runtime handlers for Deno, with routing, rewrites, middleware, caching, and geolocation guidance.
cloudflare-opennextSkillnull-shot/cloudflare-skills468 installsNext.js on Cloudflare Workers via OpenNext, covering App Router, Pages Router, ISR, SSG, and bindings.
Next Devtools McpMCP serververcel839 starsConnects to running Next.js dev servers for live errors, routes, and logs, plus docs and browser gateways.