ncc
Expert guidance for @vercel/ncc — a simple CLI for compiling Node.js modules into a single file with all dependencies included. Use when bundling serverless functions, CLI tools, or any Node.js project into a self-contained file.
- License 许可
- AGPL-3.0
- 所属仓库
- wxdwu/new-api
- 最近更新
- 2026-10-05
- Stars
- ★ 0
- Forks
- 0
01 前言 Front Matter
- name
- ncc
- metadata
- { "docs": [ "https://github.com/vercel/ncc" ], "priority": 4, "bashPatterns": [ "\\bnpm\\s+(install|i|add)\\s+[^\\n]*@vercel/ncc\\b", "\\bpnpm\\s+(install|i|add)\\s+[^\\n]*@vercel/ncc\\b", "\\bbun\\s+(install|i|add)\\s+[^\\n]*@vercel/ncc\\b", "\\byarn\\s+add\\s+[^\\n]*@vercel/ncc\\b", "\\bncc\\s+build\\b" ], "pathPatterns": [], "importPatterns": [ "@vercel/ncc" ] }
- description
- Expert guidance for @vercel/ncc — a simple CLI for compiling Node.js modules into a single file with all dependencies included. Use when bundling serverless functions, CLI tools, or any Node.js project into a self-contained file.
02 资源文件 1
- 参考文档agents/openai.yaml169 B
03 SKILL.md 正文
@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
npm install -g @vercel/ncc
# Or as a dev dependency
npm install --save-dev @vercel/ncc
Basic Usage
# 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
{
"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:
# 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):
# 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
# Build a minimal serverless handler
ncc build api/handler.ts -o .output/ -m --no-cache
CLI Tool Distribution
{
"bin": "dist/index.js",
"scripts": {
"prepublishOnly": "ncc build src/index.ts -o dist/ -m"
}
}
GitHub Actions
# 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
- Single-file output — all dependencies inlined, no
node_modulesneeded at runtime - TypeScript native — compiles
.tsfiles directly using the project'stsconfig.json - No config file — entirely driven by CLI flags
- Asset handling — non-JS files are automatically copied to the output directory
- Use externals for native modules — binary
.nodemodules often need to be external - Source maps for debugging — use
-sflag to generate.js.mapfiles - Watch mode for dev — use
-wfor fast iteration during development
Official Resources
04 同仓库更多 Skills
Zotero
Use Zotero Desktop from Codex to enable/probe the local API, search a local Zotero library, list items/collections/tags, export BibTeX, insert citation keys into LaTeX or Markdown drafts, read indexed full text when requested, and import BibTeX/RIS records into Zotero through the connector server. Use when the user mentions Zotero, citations, references.bib, BibTeX export, local Zotero API, localhost:23119, or adding citations from a Zotero library.
zoom-apps-sdk
Use when using Apps SDK.
setup-zoom-websockets
Use when building Zoom WebSockets.
setup-zoom-webhooks
Use when building Zoom webhooks.
zoom-virtual-agent-web
Zoom Virtual Agent SDK for web embeds. Use for campaign or entry ID chat launch, event-driven controls, user context updates, and CSP-safe deployment.
zoom-virtual-agent-ios
Zoom Virtual Agent iOS integration via WKWebView. Use for Swift/Objective-C script injection, message handlers, support_handoff relay, and URL routing policies.