npm i -g @zeit/ncc
ncccompiler, which has been compiled with
cd myapp npm i chalk
const chalk = require("chalk"); console.log(chalk.blue.bgRed.bold("Hello world!"));
ncc buildit for production:
We output the final version to the
go-style API and design philosophy. Compiling a program should be intuitive, single-command, zero-configuration.
ncc helpor check out the api docs.
nccby extracting the best practices out of our
Deploying a very large dependency tree in just
graphqland all their sub-dependencies.
node_modulesalone amounts to 35 times the size of our bundle:
nccmakes deployment faster and more secure, by only shipping the necessary code to production.
nccdevelopment, it used to bundle webpack as a regular npm dependency. It eventually became good enough to self-host.
In most of our tests,
ncc would take between 15 and 30 seconds to install
nccversion (usually 5-10x faster):
The installation performance of
ncc is solely bound by your download speed
src/index.js, where every subsequent
requireinvokes file-system lookups.
nccis already quite fast, even though no optimizations have been made.
ncc runand default on for
ncc build. Developers might want to opt out of this feature when debugging programs or dependencies.
nccwill favor safety over maximally optimal minification.
go's example, we intend for
nccto transparently ensure dependencies have been installed, by executing
git pull node my-program
git pullthe dependencies (
package-lock.json) might have changed.
git pull ncc run my-program
ncc build my-app.ts
nccis that it yields an output directory containing one or more files. Typically it's one, but we also perform static analysis on synchronous filesystem reads.
pdkfitand its dependencies read a lot of files that are bundled with their packages upon initialization:
ncc is capable of emitting dependencies, such as statically analyzable file-system lookups
ncca complete solution that supports the vast majority of npm modules in the ecosystem out of the box.
ncc runis optional, but it has the following current and future benefits:
- Fewer surprises upon
ncc build. While
nccgets remarkably close to the native
nodesemantics (with many integration tests) from time to time some modules with unusually-dynamic dependencies or filesystem reads could give it trouble.
- TypeScript support (planned)
- Transparent dependency installation (planned)
nccoutputs scripts (text),
pkgoutputs executables (binary).