Introducing bndl
, a basic TypeScript transpiling and bundling tool for backend monorepos. It uses SWC under the hood so it benefits from the speed improvements that it brings over tsc
.
It aims to be a near drop in replacement for people already accustomed to tsc
and uses the tsconfig.json
already present in your project. bndl
goes through the monorepo, builds the current app (or package) with swc
, identifies which dependencies are used by the consumer and copies them over to the compiled directory node_modules
of said consumer.
The result? A dist
that contains everything for your app to run. Simply copy the dist
over to a Docker image and run it. Read more about it here.
$ cargo install bndl_cli
$ npm install -g bndl-cli
$ sh -c "$(curl -fsSL https://raw.githubusercontent.com/segersniels/bndl/master/scripts/install.sh)"
$ sh -c "$(wget https://raw.githubusercontent.com/segersniels/bndl/master/scripts/install.sh -O -)"
Usage: bndl [OPTIONS] [COMMAND]
Options:
-p, --project <project> The path to the project config file
--outDir <outDir> Specify an output folder for all emitted files.
--clean Clean the output folder if it exists before bundling
--only-bundle Skips compilation and only bundles the input files, assuming they are already compiled beforehand
--no-bundle Disable automatic bundling of internal monorepo dependencies
-m, --minify Minify the output bundle
-w, --watch Experimental: watch the input files for changes and recompile when they change
--exec <exec> Experimental: use in conjunction with --watch to execute a command after each successful compilation
-h, --help Print help
-V, --version Print version
As bndl
only watches for files in the current workspace for changes it won't detect file changes in internal dependencies. To save on resources and extended downtime between file changes and restarts, bndl
also skips the bundling of internal dependencies. To work around this you could allow bndl
to recompile and bundle the internal dependencies --exec
for you.
bndl --watch --exec "npx turbo run build --filter <your-workspace>^... && npx bndl --only-bundle && npm run start"
The above will first build all internal dependencies (excl. the consuming application) and tell bndl
to only bundle those internal dependencies, skipping any form of compilation. Keep in mind that this will only run when a file changes in the consuming application, not when you save the dependency itself. So make sure you save a file in the consuming application to trigger a rebuild.
Luckily due to the nice benefits of using turbo
and the cache it provides this should be a relatively fast operation and doesn't slow down the restart much.
Expect a lot of missing functionality and potential things breaking. This was made with a specific use case in mind and there might be cases where functionality drifts from what you might need. Feel free to make issues or PRs adding your requested functionality.
Please provide the provided panic log or debug logging with RUST_LOG=debug bndl ...
so your issue can get resolved quicker.