An esbuild based file-to-file transformer and bundler.
fast and minimal builds with esbuild (integrates with the build api for plugin support — say toodles 👋🏾 to transform api hacks! 😉)
create bundleless distributions with file-to-file transpilation and static asset copying
create es modules + add file extensions to specifiers in modules and declaration files
generate declarations for .cjs
, .cts
, .js
, .jsx
, .mjs
, .mts
, .ts
, and .tsx
files
resolve path aliases in .cjs
, .cts
, .d.cts
, .d.mts
, .d.ts
, .js
, .jsx
, .mjs
, .mts
, .ts
, and .tsx
files
This package is ESM only.
yarn add -D @flex-development/mkbuild esbuild typescript
From Git:
yarn add -D @flex-development/mkbuild@flex-development/mkbuild esbuild typescript
See Git - Protocols | Yarn for details on requesting a specific branch, commit, or tag.
mkbuild
Running the command above without a build configuration file will create a bundleless esm build with declarations.
Files within the src
directory will be transpiled or copied and output to dist/**.{d.mts,mjs}
. Declaration files,
dist/**.d.mts
, will be generated if typescript
is installed. The original folder structure and extensions of copied
files will remain in tact.
Create build.config.{cjs,cts,js,json,mjs,mts,ts}
:
/**
* @file Build Config
* @module config/build
*/
import { defineBuildConfig } from '@flex-development/mkbuild'
export default defineBuildConfig({
// esbuild options; see https://esbuild.github.io/api/#build-api
sourcemap: 'external',
sourcesContent: false,
treeShaking: true,
tsconfig: 'tsconfig.build.json'
})
See all configuration options here.
Options common to build configs and build entries can be seen here.
/**
* @file Build Config
* @module config/build
*/
import { defineBuildConfig } from '@flex-development/mkbuild'
import pkg from './package.json' assert { type: 'json' }
export default defineBuildConfig({
entries: [
{ dts: true, ignore: ['cli.ts'] }, // dist/**.{d.mts,mjs}
{ dts: true, ext: '.cjs', format: 'cjs', ignore: ['cli.ts'] }, // dist/**.{cjs,d.cts}
{ dts: 'only', ext: '.js', ignore: ['cli.ts'] }, // dist/**.d.ts
{ bundle: true, minify: true, source: 'src/cli.ts' } // dist/cli.mjs
],
platform: 'node',
sourcemap: 'external',
sourcesContent: false,
target: 'node' + pkg.engines.node.replace(/^\D+/, ''),
treeShaking: true,
tsconfig: 'tsconfig.build.json'
})
See all build entry options here.
This package is fully typed with TypeScript.
See CONTRIBUTING.md
.