{"id":13394216,"url":"https://github.com/vercel/ncc","last_synced_at":"2025-09-09T19:54:39.396Z","repository":{"id":37937890,"uuid":"157318000","full_name":"vercel/ncc","owner":"vercel","description":"Compile a Node.js project into a single file. Supports TypeScript, binary addons, dynamic requires.","archived":false,"fork":false,"pushed_at":"2025-04-21T15:00:56.000Z","size":11340,"stargazers_count":9576,"open_issues_count":217,"forks_count":297,"subscribers_count":104,"default_branch":"main","last_synced_at":"2025-05-05T20:51:42.054Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://npmjs.com/@vercel/ncc","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vercel.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2018-11-13T04:00:21.000Z","updated_at":"2025-05-04T04:28:05.000Z","dependencies_parsed_at":"2024-06-18T10:59:17.083Z","dependency_job_id":"6e9114c1-cb49-4cde-903d-a861e553497e","html_url":"https://github.com/vercel/ncc","commit_stats":{"total_commits":581,"total_committers":62,"mean_commits":9.370967741935484,"dds":0.6987951807228916,"last_synced_commit":"b2a325dec1dc54f2168f838dee0b9e48ee701d18"},"previous_names":["zeit/ncc"],"tags_count":86,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vercel%2Fncc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vercel%2Fncc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vercel%2Fncc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vercel%2Fncc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vercel","download_url":"https://codeload.github.com/vercel/ncc/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253929358,"owners_count":21985802,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-30T17:01:12.809Z","updated_at":"2025-05-13T11:03:32.980Z","avatar_url":"https://github.com/vercel.png","language":"JavaScript","readme":"# ncc\n\n[![CI Status](https://github.com/vercel/ncc/workflows/CI/badge.svg)](https://github.com/vercel/ncc/actions?workflow=CI)\n\nSimple CLI for compiling a Node.js module into a single file,\ntogether with all its dependencies, gcc-style.\n\n## Motivation\n\n- Publish minimal packages to npm\n- Only ship relevant app code to serverless environments\n- Don't waste time configuring bundlers\n- Generally faster bootup time and less I/O overhead\n- Compiled language-like experience (e.g.: `go`)\n\n## Design goals\n\n- Zero configuration\n- TypeScript built-in\n- Only supports Node.js programs as input / output\n- Support all Node.js patterns and npm modules\n\n## Usage\n\n### Installation\n```bash\nnpm i -g @vercel/ncc\n```\n\n### Usage\n\n```bash\n$ ncc \u003ccmd\u003e \u003copts\u003e\n```\nEg:\n```bash\n$ ncc build input.js -o dist\n```\n\nIf building an `.mjs` or `.js` module inside a `\"type\": \"module\"` [package boundary](https://nodejs.org/dist/latest-v16.x/docs/api/packages.html#packages_package_json_and_file_extensions), an ES module output will be created automatically.\n\nOutputs the Node.js compact build of `input.js` into `dist/index.js`.\n\n\u003e Note: If the input file is using a `.cjs` extension, then so will the corresponding output file.\n\u003e This is useful for packages that want to use `.js` files as modules in native Node.js using\n\u003e a `\"type\": \"module\"` in the package.json file.\n\n#### Commands:\n```\n  build \u003cinput-file\u003e [opts]\n  run \u003cinput-file\u003e [opts]\n  cache clean|dir|size\n  help\n  version\n```\n\n#### Options:\n```\n  -o, --out [dir]          Output directory for build (defaults to dist)\n  -m, --minify             Minify output\n  -C, --no-cache           Skip build cache population\n  -s, --source-map         Generate source map\n  -a, --asset-builds       Build nested JS assets recursively, useful for\n                           when code is loaded as an asset eg for workers.\n  --no-source-map-register Skip source-map-register source map support\n  -e, --external [mod]     Skip bundling 'mod'. Can be used many times\n  -q, --quiet              Disable build summaries / non-error outputs\n  -w, --watch              Start a watched build\n  -t, --transpile-only     Use transpileOnly option with the ts-loader\n  --v8-cache               Emit a build using the v8 compile cache\n  --license [file]         Adds a file containing licensing information to the output\n  --stats-out [file]       Emit webpack stats as json to the specified output file\n  --target [es]            ECMAScript target to use for output (default: es2015)\n                           Learn more: https://webpack.js.org/configuration/target\n  -d, --debug              Show debug logs\n```\n\n### Execution Testing\n\nFor testing and debugging, a file can be built into a temporary directory and executed with full source maps support with the command:\n\n```bash\n$ ncc run input.js\n```\n\n### With TypeScript\n\nThe only requirement is to point `ncc` to `.ts` or `.tsx` files. A `tsconfig.json`\nfile is necessary. Most likely you want to indicate `es2015` support:\n\n```json\n{\n  \"compilerOptions\": {\n    \"target\": \"es2015\",\n    \"moduleResolution\": \"node\"\n  }\n}\n```\n\nIf typescript is found in `devDependencies`, that version will be used.\n\n### Package Support\n\nSome packages may need some extra options for ncc support in order to better work with the static analysis.\n\nSee [package-support.md](package-support.md) for some common packages and their usage with ncc.\n\n### Programmatically From Node.js\n\n```js\nrequire('@vercel/ncc')('/path/to/input', {\n  // provide a custom cache path or disable caching\n  cache: \"./custom/cache/path\" | false,\n  // externals to leave as requires of the build\n  externals: [\"externalpackage\"],\n  // directory outside of which never to emit assets\n  filterAssetBase: process.cwd(), // default\n  minify: false, // default\n  sourceMap: false, // default\n  assetBuilds: false, // default\n  sourceMapBasePrefix: '../', // default treats sources as output-relative\n  // when outputting a sourcemap, automatically include\n  // source-map-support in the output file (increases output by 32kB).\n  sourceMapRegister: true, // default\n  watch: false, // default\n  license: '', // default does not generate a license file\n  target: 'es2015', // default\n  v8cache: false, // default\n  quiet: false, // default\n  debugLog: false // default\n}).then(({ code, map, assets }) =\u003e {\n  console.log(code);\n  // Assets is an object of asset file names to { source, permissions, symlinks }\n  // expected relative to the output code (if any)\n})\n```\n\nWhen `watch: true` is set, the build object is not a promise, but has the following signature:\n\n```js\n{\n  // handler re-run on each build completion\n  // watch errors are reported on \"err\"\n  handler (({ err, code, map, assets }) =\u003e { ... })\n  // handler re-run on each rebuild start\n  rebuild (() =\u003e {})\n  // close the watcher\n  void close ();\n}\n```\n\n## Caveats\n\n- Files / assets are relocated based on a [static evaluator](https://github.com/vercel/webpack-asset-relocator-loader#how-it-works). Dynamic non-statically analyzable asset loads may not work out correctly\n","funding_links":[],"categories":["JavaScript","Developer Tools","others","Node.js","Development tools","Uncategorized"],"sub_categories":["Build","Uncategorized"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvercel%2Fncc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvercel%2Fncc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvercel%2Fncc/lists"}