0.6.2 • Published 3 years ago
@guardian/pkgu v0.6.2
@guardian/pkgu
Automatically build
@guardianpackages for publishing to NPM inline with our recommendations.
Installation
yarn add -D @guardian/pkguor
npm install -D @guardian/pkguUsage
@guardian/pkgu installs a CLI tool called pkgu that you can use to create your build.
Commands
build
Example
// package.json
{
...,
"scripts": {
"prebuild": "rm -rf dist",
"build": "pkgu build"
},
...,
}This will compile your project to a dist directory ready for publishing, performing the following steps:
- Lint your
package.jsonandtsconfig.jsonfiles and update/add/remove any fields as necessary. - Compile 3 versions of your project:
- CommonJS version targetting ES2018 (for Node 10+).
- ESM version targetting ES2020 for use by bundlers (see Using
@guardianNPM packages in the recommendations for more info). - TypeScript declaration files.
- Check that the build artefacts match the
package.jsonconfig. - If your package provides a CLI it will set the permissions needed to make it executable.
You should then be good to publish.
Requirements
- Your source code is written in TypeScript.
- The source code lives in a directory called
srcat the package root level. - There is one entry point:
src/index.ts.