Father (NPM Package Build Tool)

4.6.18 · active · verified Tue Apr 21

Father is a comprehensive NPM package development tool within the UmiJS ecosystem, designed to streamline the building, generating, and publishing of JavaScript and TypeScript packages. It features a dual-mode build system: 'Bundless' for ESModule and CommonJS outputs, leveraging esbuild, Babel, or SWC; and 'Bundle' for UMD artifacts powered by Webpack. The package, currently at version 4.6.18, maintains an active release cadence with frequent minor updates and patches. Its key differentiators include robust type generation for TypeScript, persistent caching for accelerated builds, and integrated project health checks to prevent common development pitfalls. Father also offers micro-generators for common engineering tasks and experimental dependency pre-bundling to enhance stability in Node.js frameworks and libraries.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates setting up a basic TypeScript package with Father, including configuration for ESModule and CommonJS outputs, and a build script.

{
  "name": "my-package",
  "version": "1.0.0",
  "type": "module",
  "scripts": {
    "build": "father build"
  },
  "devDependencies": {
    "father": "^4.6.18",
    "typescript": "^5.0.0"
  }
}
// father.config.ts
import { defineConfig } from 'father';

export default defineConfig({
  esm: { type: 'babel', importLibToEs: true },
  cjs: { type: 'babel', lazy: true },
  // Optional: UMD build for browser compatibility
  // umd: { name: 'myPackage', output: 'dist' },
  // Persistent caching for faster rebuilds
  extraBabelPlugins: [
    ['babel-plugin-import', { libraryName: 'lodash', libraryDirectory: 'es' }]
  ],
  targets: { esmodules: true, node: 14 }
});
// src/index.ts
export const greet = (name: string): string => `Hello, ${name} from Father!`;

export const add = (a: number, b: number): number => a + b;

view raw JSON →