
Ncc
Bundle Node.js apps and serverless handlers into a single deployable file with @vercel/ncc instead of shipping whole node_modules trees.
Overview
ncc is an agent skill most often used in Ship (also Build backend, Operate infra) that guides bundling Node.js projects into a single file with @vercel/ncc for serverless and CLI releases.
Install
npx skills add https://github.com/vercel-labs/vercel-plugin --skill nccWhat is this skill?
- Expert guidance for @vercel/ncc compiling entry JS plus all dependencies into one output file
- Covers ncc build, ncc run, and watch mode for serverless functions, CLI tools, and smaller Docker images
- Documents CLI flags table (out dir, minify, source maps, externals, asset emission)
- Detects installs via npm/pnpm/yarn/bun and ncc build bash patterns in agent context
Adoption & trust: 2 installs on skills.sh; 187 GitHub stars; 3/3 security scanners passed (skills.sh audits).
What problem does it solve?
Your Node serverless function or CLI drags a huge node_modules tree into deploy artifacts, slowing uploads and bloating images.
Who is it for?
Solo devs on Vercel (or similar) packaging Node handlers, CLIs, or slim container entrypoints with ncc build.
Skip if: Pure frontend Vite apps, native addons that cannot bundle cleanly without externals expertise, or teams standardized on esbuild-only pipelines who do not use ncc.
When should I use this skill?
Bundling serverless functions, CLI tools, or Node projects with @vercel/ncc, npm install @vercel/ncc, or ncc build commands.
What do I get? / Deliverables
You ship a self-contained compiled JS bundle with dependencies inlined, ready for serverless deploy or distribution.
- dist/ single-file bundle
- Documented ncc build or watch command for CI
Recommended Skills
Journey fit
Spans multiple journey phases - primary shelf plus alternate fits below.
Canonical shelf is Ship launch prep because ncc’s primary win is deployment-shaped: one artifact for serverless, CLIs, and slim containers right before you ship. Launch subphase covers packaging and release mechanics—ncc build/run/watch are the pre-flight compile step for Vercel-style functions and distributable binaries.
Where it fits
Add an ncc build script to your API entry so local dev matches the single-file artifact CI emits.
Compile the serverless handler to dist/ immediately before uploading to Vercel without node_modules.
Rebuild the bundled worker after a dependency security patch to keep Docker images minimal.
How it compares
Use for Vercel’s opinionated single-file Node compile, not as a general monorepo task runner.
Common Questions / FAQ
Who is ncc for?
Indie backend and platform builders using Node who need one-file bundles for serverless, CLIs, or Docker before release.
When should I use ncc?
Use in Ship launch when preparing serverless uploads; also during Build backend when structuring compile scripts, and Operate infra when trimming deployment artifacts—especially after adding @vercel/ncc or running ncc build in CI.
Is ncc safe to install?
Review the Security Audits panel on this Prism page; bundling executes your dependency graph—pin versions and audit externals/minify flags like any compile step.
SKILL.md
READMESKILL.md - Ncc
# @vercel/ncc — Node.js Compiler Collection You are an expert in `@vercel/ncc`, Vercel's simple CLI for compiling a Node.js module into a single file, together with all its dependencies. ## Overview ncc bundles a Node.js application and all of its `node_modules` into a single output file. This is ideal for: - **Serverless functions** — deploy a single file instead of `node_modules` - **CLI tools** — distribute a self-contained executable - **Docker images** — reduce image size by eliminating `node_modules` ## Installation ```bash npm install -g @vercel/ncc # Or as a dev dependency npm install --save-dev @vercel/ncc ``` ## Basic Usage ```bash # Compile index.js into dist/index.js ncc build input.js -o dist/ # Watch mode for development ncc build input.js -o dist/ -w # Run directly without writing to disk ncc run input.js ``` ## CLI Options | Flag | Description | |---|---| | `-o, --out [dir]` | Output directory (default: `dist`) | | `-m, --minify` | Minify the output | | `-s, --source-map` | Generate source maps | | `-a, --asset-builds` | Build nested JS assets recursively | | `-e, --external [mod]` | Keep module as external (don't bundle) | | `-w, --watch` | Watch mode — rebuild on changes | | `-t, --transpile-only` | Skip TypeScript type checking | | `--license [file]` | Output licenses to a file | | `-q, --quiet` | Suppress non-error output | | `--no-cache` | Skip the build cache | | `--no-asset-builds` | Skip nested JS asset builds | ## package.json Integration ```json { "scripts": { "build": "ncc build src/index.ts -o dist/ -m", "build:watch": "ncc build src/index.ts -o dist/ -w", "start": "node dist/index.js" }, "devDependencies": { "@vercel/ncc": "^0.38.0" } } ``` ## TypeScript Support ncc natively supports TypeScript — no separate `tsc` step needed: ```bash # Compiles TypeScript directly ncc build src/index.ts -o dist/ # Skip type checking for faster builds ncc build src/index.ts -o dist/ -t ``` ncc uses the project's `tsconfig.json` automatically. ## Externals Keep specific modules out of the bundle (useful for native modules or optional dependencies): ```bash # Single external ncc build input.js -e aws-sdk # Multiple externals ncc build input.js -e aws-sdk -e sharp ``` For serverless environments where the runtime provides certain modules (like AWS Lambda's `aws-sdk`), mark them as external. ## Static Assets ncc handles non-JS assets (`.json`, `.node`, binary files) by copying them to the output directory alongside the compiled JS file. They are referenced correctly at runtime. ## Common Patterns ### Serverless Function Bundling ```bash # Build a minimal serverless handler ncc build api/handler.ts -o .output/ -m --no-cache ``` ### CLI Tool Distribution ```json { "bin": "dist/index.js", "scripts": { "prepublishOnly": "ncc build src/index.ts -o dist/ -m" } } ``` ### GitHub Actions ```bash # Bundle a GitHub Action into a single file ncc build src/index.ts -o dist/ -m --license licenses.txt ``` GitHub Actions require all dependencies bundled — ncc is the recommended bundler for custom JS/TS actions. ## Key Points 1. **Single-file output** — all dependencies inlined, no `node_modules` needed at runtime 2. **TypeScript native** — compiles `.ts` files directly using the project's `tsconfig.json` 3. **No config file** — entirely driven by CLI flags 4. **Asset handling** — non-JS f