Skip to main content

@hz-9/heft-node-rig

About 1 min

@hz-9/heft-node-rig

A rig package for Node.js projects that build using Heft build system. To learn more about rig packages, consult the @rushstack/rig-packageopen in new window documentation.

NPM Version NPM License NPM Downloads
Node Version Last Commit

Introduction

@hz-9/heft-node-rig is a rigopen in new window pacakge. So the project must have used Heftopen in new window.

@hz-9/heft-node-rig provides two profiles.

  • default: A configuration for common, exporting CommonJS (CJS) and ES Module (ESM).
  • tool: A configuration for command-line tool, exporting CommonJS (CJS) .

Installation

npm install @hz-9/heft-node-rig --save-dev

For information on the PeerDependencies of @hz-9/heft-node-rig, please see.

Usage

  1. add file config/rig.json:

    // The "rig.json" file directs tools to look for their config files in an external package.
    // Documentation for this system: https://www.npmjs.com/package/@rushstack/rig-package
    {
      "$schema": "https://developer.microsoft.com/json-schemas/rig-package/rig.schema.json",
    
      /**
       * (Required) The name of the rig package to inherit from.
      * It should be an NPM package name with the "-rig" suffix.
      */
      "rigPackageName": "@hz-9/heft-node-rig",
      /**
       * (Optional) Selects a config profile from the rig package.  The name must consist of
      * lowercase alphanumeric words separated by hyphens, for example "sample-profile".
      * If omitted, then the "default" profile will be used."
      */
      "rigProfile": "tool"
    }
    
    
  2. add file config/jest.config.json:

    {
      "extends": "@hz-9/heft-node-rig/profiles/tool/config/jest.config.json"
    }
    
    
  3. add to config/tsconfig.json:

    {
      "extends": "./node_modules/@hz-9/heft-node-rig/profiles/tool/tsconfig.json",
      "compilerOptions": {
        // ...
      }
    }
    
    
  4. add to package.json:

    {
      "scripts": {
        // ...
    
        "build": "heft test --clean",
        "test": "heft test --clean",
        "test:watch": "heft test-watch --clean"
      }
    }
    
  5. now, you can run:

    npm run build