Crates.io | bndl_cli |
lib.rs | bndl_cli |
version | 1.8.1 |
source | src |
created_at | 2023-11-15 16:10:34.332654 |
updated_at | 2024-10-02 08:51:02.05816 |
description | A basic TypeScript transpiling and bundling tool for (primarily backend) monorepos |
homepage | https://github.com/segersniels/bndl/ |
repository | https://github.com/segersniels/bndl/ |
max_upload_size | |
id | 1036546 |
size | 109,437 |
Introducing bndl
, a barebones TypeScript transpiling and bundling tool for backend monorepos.
It aims to be a near drop-in replacement for those accustomed to tsc
, utilizing the existing tsconfig.json
in your project. bndl
traverses the monorepo, builds the current workspace with SWC, identifies the dependencies used by the consumer, and copies them to the compiled directory's node_modules
.
The result? An output directory containing everything necessary for your app to run. Simply copy the dist directory to a Docker image and execute it.
$ 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
bndl
only builds the current workspace, not its dependencies. You need to build internal dependencies before the consuming workspace. Using something like Turborepo, you can run npx turbo run build --filter <your-workspace>
with a config like this:
{
"tasks": {
"build": {
"dependsOn": ["^build"],
"outputs": ["dist/**"]
}
}
}
This config ensures Turborepo builds internal dependencies first before the consuming workspace, making them ready for bundling.
bndl
only watches the current workspace for changes, not internal dependencies. To handle this, use the --exec
option to recompile and bundle internal dependencies.
bndl --watch --exec "npx turbo run build --filter <your-workspace>^... && npx bndl --only-bundle && npm run start"
This command will first build all internal dependencies (excluding the consuming application) and then tell bndl
to bundle them. Note that this triggers only when a file changes in the consuming application. Save a file in the consuming application to trigger a rebuild.
Using Turborepo and its cache should make this relatively fast, minimizing delay between file changes and restarts.
Expect missing functionality and potential breakage. This tool was created for a specific use case and might differ from your needs. Feel free to open issues or PRs to add the functionality you need.
Submit issues with panic logs or debug information (RUST_LOG=debug bndl ...
) for quicker resolution.