Detalhes do pacote

@guoyunhe/node-scripts

guoyunhe53GPL-3.02.2.0

Scripts for Node.js libraries or command line tools

cli, typescript, build, compile

readme (leia-me)

@guoyunhe/node-scripts

Scripts to build, lint and test Node.js projects.

Features:

  • Minimum configuration, easy to use
  • Output both CJS and ESM bundle
  • Lightning fast build speed, powered by esbuild
  • Full TypeScript support in build, lint and test
  • Ensure good coding style by ESLint and Prettier
  • Out of box unit test support, powered by Jest
  • Global variable PACKAGE_NAME and PACKAGE_VERSION to easily inject package information

Create projects

Node library

npm create @guoyunhe/node my-package

Checkout create-node for more options.

CLI tool

npm create @guoyunhe/cli my-package

Checkout create-cli for more options.

Options

--help

Show help.

--version

Show version.

Commands

build

Build CJS, ESM and TypeScript declaration (*.d.ts).

node-scripts build

CJS and ESM builds are powered by esbuild, one of the fastest JavaScript complier and bundler. TypeScript declarations are generated by TypeScript and bundled by API Extractor from Microsoft.

The build command read entry src/index.ts. CJS is output at dist/index.js. ESM is output at dist/index.mjs. Declaration is output at dist/index.d.ts.

For CLI projects, it scans src/bin/*.ts. For example, src/bin/my-cli.ts outputs dist/my-cli.js (CJS) and dist/my-cli.mjs (ESM).

Support watch mode with --watch option.

node-scripts build --watch

watch

Watch mode. Same as node-scripts build --watch.

node-scripts watch

lint

node-scripts format

Check your code with ESLint.

Support auto fix code issues with --fix option. (This will also run Prettier for formatting)

node-scripts lint --fix

format

Format code and fix ESLint issues. Same as node-scripts lint --fix.

node-scripts format

test

Run unit tests with Jest. Generate coverage report at coverage.

node-scripts test

Support all Jest CLI options. For example:

# Watch mode
node-scripts test --watchAll

# Update snapshots
node-scripts test -u

changelog (log de mudanças)

Changelog

2.2.0 - 2023-06-24

  • Updated esbuild (0.17→0.18)

2.1.0 - 2023-06-20

  • Updated typescript (4→5)
  • Changed to not output CJS and give ESM .js ext when type: "module" found in package.json

2.0.4 - 2023-02-16

  • Fixed peerDependencies eslint and prettier

2.0.2 - 2023-02-11

  • Fixed global type PACKAGE_NAME

2.0.1 - 2023-02-11

  • Fixed exception when here is no src/index.ts

2.0.0 - 2023-02-11

  • BREAKING CHANGE: Changed output file paths
    • dist/cjs/index.js -> dist/index.js
    • dist/cjs/bin/my-cli.js -> dist/my-cli.js
    • dist/esm/index.js -> dist/index.mjs
    • dist/esm/bin/my-cli.js -> (deleted)
    • dist/dts/index.d.ts -> dist/index.d.ts
  • Updated commander from 9.x to 10.x
  • Added PACKAGE_NAME global definition

1.9.0 - 2023-01-30

  • Refactored build action

1.8.0 - 2023-01-30

  • Refactored lint and test actions

1.7.1 - 2023-01-26

  • Fixed package.json spaces

1.7.0 - 2023-01-26

  • Formatted package.json

1.6.0 - 2023-01-22

  • Updated esbuild from 0.16.x to 0.17.x

1.5.1 - 2023-01-22

  • Fixed build bundle size by external devDependencies and peerDependencies

1.5.0 - 2022-12-17

  • Added TypeScript declartion (.d.ts) output

1.4.0 - 2022-12-13

  • Changed lint config package name

1.3.0 - 2022-12-13

  • Added build --watch option
  • Added watch command, same as build --watch

1.2.0 - 2022-12-12

  • Added tsconfig target support

1.1.3 - 2022-12-11

  • Fixed bin scripts

1.1.2 - 2022-12-11

  • Fixed bin scripts

1.1.1 - 2022-12-11

  • Fixed ts-jest dependency

1.1.0 - 2022-12-11

  • Added Jest preset

1.0.1 - 2022-12-11

  • Fixed build bundle

1.0.0 - 2022-12-11

  • Added build command
  • Added format command
  • Added lint command
  • Added test command