npm install @vercel/ncc
76.6
Supply Chain Risk
98.4
Quality
83.6
Maintenance
100
Vulnerability
9,098 Stars
587 Commits
288 Forks
92 Watching
39 Branches
123 Contributors
Updated on 12 Sept 2024
Minified
Minified + Gzipped
JavaScript (98.41%)
TypeScript (0.85%)
Shell (0.35%)
C++ (0.29%)
Python (0.09%)
Cumulative downloads
Total Downloads
Last day
19.7%
97,773
Compared to previous day
Last week
0%
427,332
Compared to previous week
Last month
6.5%
1,884,362
Compared to previous month
Last year
8.1%
17,718,434
Compared to previous year
89
Simple CLI for compiling a Node.js module into a single file, together with all its dependencies, gcc-style.
go
)npm i -g @vercel/ncc
$ ncc <cmd> <opts>
Eg:
$ ncc build input.js -o dist
If building an .mjs
or .js
module inside a "type": "module"
package boundary, an ES module output will be created automatically.
Outputs the Node.js compact build of input.js
into dist/index.js
.
Note: If the input file is using a
.cjs
extension, then so will the corresponding output file. This is useful for packages that want to use.js
files as modules in native Node.js using a"type": "module"
in the package.json file.
build <input-file> [opts]
run <input-file> [opts]
cache clean|dir|size
help
version
-o, --out [dir] Output directory for build (defaults to dist)
-m, --minify Minify output
-C, --no-cache Skip build cache population
-s, --source-map Generate source map
-a, --asset-builds Build nested JS assets recursively, useful for
when code is loaded as an asset eg for workers.
--no-source-map-register Skip source-map-register source map support
-e, --external [mod] Skip bundling 'mod'. Can be used many times
-q, --quiet Disable build summaries / non-error outputs
-w, --watch Start a watched build
-t, --transpile-only Use transpileOnly option with the ts-loader
--v8-cache Emit a build using the v8 compile cache
--license [file] Adds a file containing licensing information to the output
--stats-out [file] Emit webpack stats as json to the specified output file
--target [es] ECMAScript target to use for output (default: es2015)
Learn more: https://webpack.js.org/configuration/target
-d, --debug Show debug logs
For testing and debugging, a file can be built into a temporary directory and executed with full source maps support with the command:
$ ncc run input.js
The only requirement is to point ncc
to .ts
or .tsx
files. A tsconfig.json
file is necessary. Most likely you want to indicate es2015
support:
{ "compilerOptions": { "target": "es2015", "moduleResolution": "node" } }
If typescript is found in devDependencies
, that version will be used.
Some packages may need some extra options for ncc support in order to better work with the static analysis.
See package-support.md for some common packages and their usage with ncc.
require('@vercel/ncc')('/path/to/input', { // provide a custom cache path or disable caching cache: "./custom/cache/path" | false, // externals to leave as requires of the build externals: ["externalpackage"], // directory outside of which never to emit assets filterAssetBase: process.cwd(), // default minify: false, // default sourceMap: false, // default assetBuilds: false, // default sourceMapBasePrefix: '../', // default treats sources as output-relative // when outputting a sourcemap, automatically include // source-map-support in the output file (increases output by 32kB). sourceMapRegister: true, // default watch: false, // default license: '', // default does not generate a license file target: 'es2015', // default v8cache: false, // default quiet: false, // default debugLog: false // default }).then(({ code, map, assets }) => { console.log(code); // Assets is an object of asset file names to { source, permissions, symlinks } // expected relative to the output code (if any) })
When watch: true
is set, the build object is not a promise, but has the following signature:
{ // handler re-run on each build completion // watch errors are reported on "err" handler (({ err, code, map, assets }) => { ... }) // handler re-run on each rebuild start rebuild (() => {}) // close the watcher void close (); }
Reason
license file detected
Details
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
security policy file detected
Details
Reason
packaging workflow detected
Details
Reason
Found 4/7 approved changesets -- score normalized to 5
Reason
dependency not pinned by hash detected -- score normalized to 5
Details
Reason
0 commit(s) and 2 issue activity found in the last 90 days -- score normalized to 1
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
project is not fuzzed
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
64 existing vulnerabilities detected
Details
Score
Last Scanned on 2024-09-02
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More@vercel/webpack-asset-relocator-loader
Asset relocation loader used in ncc for performing Node.js builds while emitting and relocating any asset references.
@henderea/my-ncc
My custom wrapper around @vercel/ncc to avoid ESM output
serverless-package-ncc
Serverless Framework plugin to work with @vercel/ncc
@fye/serverless-package-ncc
Serverless Framework plugin to work with @vercel/ncc