
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-codeInstalls 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
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
Sponsors
Details
- Repository
- github.com/vercel/next.js
- Categories
- Frontend Development, Backend & APIs, Cloud & Infrastructure
- First seen
- Apr 16, 2026