this package contains utilities for building packages and managing monorepos.
existing similar tools try to do too much and accomodate for every possible use case, which makes them quite hard to use and don't provide enough consistency. unlike them, this package is very opinionated and might not be for you.
this package works on some assumptions, allowing to abstract some of the complexity away:
workspace:
protocol,
and versions are replaced with the actual version at build timetsc
to build is such a pain that it's just not worth it.type: module
, because commonjs sucks (you can still build into commonjs, tho).exports
and .bin
fields in package.json are build entrypoints, e.g.:{
"exports": {
".": "./src/index.ts"
},
"bin": {
"fuman-build": "./src/cli.ts"
}
}
.main
, .module
, .types
, .browser
are explicitly not supported. for browser-specific code, you should make a secondary entrypoint/package instead of relying on bundle-time magicit might work with other setups, but that is not supported.
because node sucks. package.json
is an absolute mess – it's not standardized properly, and it's a pain to work with.
when it was invented, typescript wasn't even a thing, and as such it's a pain to set it up correctly for libraries.
and npm is also a pain due to similar reasons. everything is so fragile and inconsistent that it's very easy to make mistakes.
deno and jsr fix some of the issues, but i just generally don't like deno because it feels very limiting and vendor-locking, and there isn't any tool to write cross-runtime code under deno anyway.
additionally there's quite some pain writing release ci/cd flows for libraries. especially for monorepos, especially when you want to cross-publish to npm and jsr.
...provided by processPackageJson
function
workspace:
dependencies with the actual version from the workspacescripts
(except ones listed in keepScripts
)devDependencies
, typedoc
/prettier
/etcexports
and bin
build.config.js
filesthis allows to:
workspace:
protocol, but i don't like the idea of using something other than npm cli to publish to npm)prepare
/install
/etc. scripts to npm (and also reduces install size by a bit).types
field for developmentpackage.json
across all packages (and accidentally publish them broken)just put this in your vite.config.js
:
import { fumanBuild } from '@fuman/build/vite'
export default {
plugins: [
fumanBuild({
root: __dirname,
// if you're using `vite-plugin-dts`, make sure to add this option,
// otherwise additional entrypoints will not have proper types
// (and DO NOT add this option to the dts plugin itself)
insertTypesEntry: true,
}),
],
}
fuman-build also supports jsr by being able to convert a pnpm workspace into a deno workspace,
which can then be published via simple deno publish
command.
to generate a deno workspace, run fuman-build jsr gen-deno-workspace
.
fuman-build has a pretty cool cli, check it out via fuman-build --help
fuman-build also makes it very easy to use in CI/CD pipelines. a very simple release flow powered by fuman build and github actions can be found here.
the release
command basically combines a bunch of other commands
(namely, bump-version
, gen-changelog
, publish
and jsr
subcommands)
into one and adds some additional release-specific features (like git tagging and github release generation), and is the recommended way to use fuman-build in CI/CD pipelines.
though it is definitely possible to use the other commands directly, in case you need to do something that is not supported out of the box.