nccpo v0.0.1
ncc package optimization
nccpo sits on top of the @zeit/ncc project, and adds additional optimization to the generated builds by stripping away bundled package.json dependencies and automatically pack-ing the build.
Following in the steps of zeit's philosophy of zero configuration, there is no configuration needed to run nccpo:
nccpo build ./src/index.ts -o dist [-- pack arguments]All other commands are passed directly to the @zeit/ncc module, making nccp a full stand-in:
npx nccpo run src/index.tsInstallation
The package can be installed globally or run by npx
yarn add nccpo @zeit/ncc@^0.20.5Usage
This module provides a simple CLI command, nccpo, that fronts the @zeit/ncc project with a bit of additional build behavior.
If combined with Yarn or npm, it can be run as:
yarn nccpo help
# or
npx nccpo helpIt can also be used as part of an npm script:
{
"scripts": {
"build": "tsc",
"predist": "yarn test",
"dist": "nccpo build src/index.js -o dist",
"prepublishOnly": "yarn dist"
},
"devDependencies": {
"@camacho/nccp": "latest"
}
}yarn format:pkgCLI
The CLI accepts the @zeit/ncc build arguments:
yarn @camacho/nccp build src/index.ts -o distIntegrating
Development
The repository comes with several built in tools to help maintain the package. All the scripts are run through yarn.
Building
To create a production ready version of the application, run:
yarn distTo create a fresh, unbundled build of the application, run:
yarn buildTo go into watch mode (which is not necessary for testing):
yarn devDocs
Documentation helps lower the barrier of entry and get new users involved. It can also make them feel welcome to the project and more willing to contribute or ask questions.
To keep the documentation up to date, run:
yarn docsFormatting
To help remove any worries about content consistency, formatting is managed automatically with prettier, and format-package.
These formatters can be run with:
yarn formatLinting
The code linters help catch simple bugs and keep the codebase consistent. They can be run with:
yarn lintCommit Messages
Commit messages are linted with commitlint to help with consistency and enable semantic-release in the future.
Git Hooks
A series of GitHooks have been setup and are managed through husky and lint-staged. These hooks automate dependency installation, formatting, testing, commit linting, and a host of other behavior.
Scripts
These scripts can be run via yarn or npm run:
| Script | Description |
|---|---|
build | transpile TypeScript files in the src directory into JavaScript files in the build directory |
clean | clean build and dist directory |
dev | run ts-node-dev with src/cli/index.ts entrypoint |
dist | package a dist version of the repository (dogfooding) |
docs | update auto-generated-content blocks in Markdown files |
format | format repository code |
format-package | format package.json files using format-package |
format-source | format source content using prettier |
gamut | run the full gamut of checks - reset environment, generate docs, format and lint code, run tests, and build |
lint | lint the application code |
prepublishOnly | build the package before publishing |
prerelease | yarn gamut |
release | semantic-release |
reset | clean dist, build, and node_modules directories |
start | run the compiled application from dist directory |
start-dev | run the application using ncc run |
type-check | check source types |
Note - This repo depends on husky and lint-staged to automatically format code and update documents. If these commands are not run, code changes will most likely fail.