Simple utilities for modern npm packages.
npm install @ptkhanh94npm/nihil-id-dolore -D
# Initialize a new package
pnpx @ptkhanh94npm/nihil-id-dolore@latest init my-package
# In a Node.js package directory with `package.json` present
# Check the package
pkg-utils check
# Build the package
pkg-utils build
# Watch the package
pkg-utils watch
Run pkg-utils -h
for more information on CLI usage.
@ptkhanh94npm/nihil-id-dolore
reads most of its configuration from package.json
. But sometimes you need more
control. You may then add a configuration file named package.config.ts
(or .js
, .cjs
, or
.mjs
).
// package.config.ts
import {defineConfig} from '@ptkhanh94npm/nihil-id-dolore'
export default defineConfig({
extract: {
rules: {
// do not require internal members to be prefixed with `_`
'ae-internal-missing-underscore': 'off',
},
},
// the path to the tsconfig file for distributed builds
tsconfig: 'tsconfig.dist.json',
})
- Type:
PkgBundle[]
- Default:
undefined
An array of entry points to bundle. This is useful if you want to bundle something that should not be exported by the package, e.g. CLI scripts or Node.js workers.
- Type:
Record<string, string | number | boolean | null | undefined>
- Default:
{}
An object defining globals within the package.
- Type:
string
- Default:
'./dist'
The path to the directory to which bundle and chunk files should be written.
- Type:
PkgConfigProperty<PkgExports>
- Default: the value of
"exports"
inpackage.json
Override or modify the value of the exports
before it’s parsed internally.
- Type:
{ rules?: { 'ae-forgotten-export'?: PkgRuleLevel 'ae-incompatible-release-tags'?: PkgRuleLevel 'ae-internal-missing-underscore'?: PkgRuleLevel 'ae-missing-release-tag'?: PkgRuleLevel } }
- Default:
undefined
Configure the level of reporting of API Extractor (which is used to bundle the type definitions, as well as lint the TSDoc of the package).
- Type:
string[]
- Default:
[]
Packages to exclude from bundles.
- Type:
'transform' | 'preserve' | 'automatic'
- Default:
'automatic'
Strategy for bundling JSX.
- Type:
string
- Default:
'createElement'
The name of the function that creates JSX elements.
- Type:
string
- Default:
'Fragment'
The name of JSX fragment elements.
- Type:
string
- Default:
'react'
The name of the library from which to import JSX factory and fragment names.
- Type:
boolean
- Default:
false
Build package with support for legacy exports (writes root <export>.js
files). Use this if you
need to support older bundlers.
- Type:
boolean
- Default:
false
Whether to minify the bundled JavaScript.
- Type:
PkgConfigProperty<RollupPlugin[]>
- Default:
[]
Rollup plugins to load when bundling.
- Type:
'*' | 'browser' | 'node'
- Default:
'*'
Default runtime of package exports
- Type:
boolean
- Default:
true
Whether to include source map files.
- Type:
string
- Default:
'./src'
The path to the directory in which source code is located.
- Type:
string
- Default:
'tsconfig.json'
The path to the TypeScript configuration file.
MIT