0.4.0 • Published 2 months ago

@fp-tx/build-tools v0.4.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 months ago

build-tools

@fp-tx/build-tools is a thin wrapper around tsup for the purpose of building dual ESM/CJS packages. It contains a chief export makeConfig which will read from a configurable source directory and determine which files to include as entrypoints. Using these entrypoints, it also adds a dynamic "exports" field with import and default fields based on the determined entrypoints and module type (determined by package.json > type).

Additionally, build-tools will emit smart declaration files with rewritten import, export, and declare module paths.

Usage

// tsup.config.js
import { makeConfig } from '@fp-tx/build-tools'

const config = makeConfig(
  // Configuration Parameters
  {
    buildType: 'dual',
    buildMode: {
      type: 'Single',
      entrypoint: 'index.ts',
    },
    iife: false,

    srcDir: 'src',
    basePath: '.',
    outDir: 'dist',

    emitTypes: true,
    dtsConfig: 'tsconfig.json',

    omittedPackageKeys: ['devDependencies', 'scripts', 'lint-staged'],
    copyFiles: ['README.md', 'LICENSE'],
    // ^^^ These are the default options
  },
  // Tsup options (overrides the above)
  {
    clean: true,
  },
  // CLI options override both of the above
)

export default config

Installation

PNPM

pnpm add -D tsup @fp-tx/build-tools

Yarn

yarn add -D tsup @fp-tx/build-tools

NPM

npm install -D tsup @fp-tx/build-tools

Configuration Parameters

ParameterTypeDescriptionDefault
iifebooleanInclude IIFE generation as fallback. This setting is recommended for single-target buildsfalse
emitTypesbooleanGenerate .d.ts, and .d.cts or .d.mts filestrue
dtsConfigstringThe tsconfig.json for types generationtsconfig.json
srcDirstringThe source directory to read from'src'
basePathstringThe current working directory'.'
buildModeBuildModeDetermines the package entrypoints, "Single" and entrypoint or "Multi" and entrypointGlobs{ type: "Single", entrypoint: "index.ts" }
buildTypecjs, esm, or dualDetermines the output module format along with package.json > typedual
omittedPackageKeysReadonlyArray<string>Array of keys to omit from the package.json file["devDependencies", "scripts"]
copyFilesReadonlyArray<string>Whether to copy non-typescript files['README.md', 'LICENSE']
outDirstringThe output directorydist
0.4.0

2 months ago

0.3.2

3 months ago

0.3.3

3 months ago

0.3.0

3 months ago

0.3.1

3 months ago

0.2.0

3 months ago

0.1.3

4 months ago

0.1.2

5 months ago

0.1.1

5 months ago

0.1.0

5 months ago