vercel avatar

Dce Edge

When you're working on Next.js edge runtime code or touching conditional imports that need to work across Node and edge environments, this keeps you from breaking dead code elimination. Webpack can only strip out unused requires when they're structured exactly right, with DefinePlugin-evaluable conditions wrapping them. The skill knows the pattern that actually works (checking process.env flags in a clean if/else) versus the stuff that looks fine but silently bloats your edge bundle because webpack can't analyze it. Honestly pretty narrow in scope, but if you're deep in Next.js internals or debugging why your edge function is suddenly 500KB, this is the guardrail you want.

skills.sh installs
842
GitHub stars
139.5K
last updated
May 16, 2026

Install

$ npx -y skills add vercel/next.js --skill dce-edge --agent claude-code

Installs into .claude/skills of the current project.

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 if without else: works for inline node:* specifiers but NOT for require('./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

Sponsors

Details

Repository
github.com/vercel/next.js
Categories
Frontend Development, Backend & APIs, Cloud & Infrastructure
First seen
Apr 16, 2026

More from vercel/next.js

All 14
1vercel avatarpr-status-triagevercel/next.jspr status triage839skills.sh installs
2vercel avatarwrite-guidevercel/next.jswrite guide721skills.sh installs
3plugin87 avatardesign-reviewplugin87/ux-ui-agent-skillsReview or audit a design/UI across 6 weighted dimensions with Nielsen's 10 heuristics and a prioritized findings table. Use when the user wants a design critiqu644skills.sh installs
4plugin87 avatarredesignplugin87/ux-ui-agent-skillsUpgrade an existing website or app to premium quality without breaking functionality — audit the current design, identify generic/AI tells, then apply taste and580skills.sh installs
5plugin87 avatarux-writingplugin87/ux-ui-agent-skillsWrite or review UI copy — buttons, errors, empty states, microcopy, notifications, labels — using the voice & tone system (clear, concise, useful, human, honest564skills.sh installs
6vercel avatarrouter-actvercel/next.jsrouter act549skills.sh installs