#monorepo #typescript #bundling #back-end #swc #build #build-tool

app bndl_cli

A basic TypeScript transpiling and bundling tool for (primarily backend) monorepos

41 stable releases

1.6.5 Mar 7, 2024
1.6.4 Mar 5, 2024
1.5.7 Jan 22, 2024
1.5.2 Dec 15, 2023
1.3.1 Nov 29, 2023

#315 in Command line utilities

Download history 12/week @ 2024-01-07 28/week @ 2024-01-14 8/week @ 2024-01-21 20/week @ 2024-02-18 18/week @ 2024-02-25 739/week @ 2024-03-03 75/week @ 2024-03-10 4/week @ 2024-03-17 143/week @ 2024-03-31

253 downloads per month

MIT license

65KB
1.5K SLoC

bndl

crates.io npm GitHub Workflow Status (with event)

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.

Installing

cargo

$ cargo install bndl_cli

npm

$ npm install -g bndl-cli

curl

$ sh -c "$(curl -fsSL https://raw.githubusercontent.com/segersniels/bndl/master/scripts/install.sh)"

wget

$ sh -c "$(wget https://raw.githubusercontent.com/segersniels/bndl/master/scripts/install.sh -O -)"

Usage

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
  -h, --help               Print help
  -V, --version            Print version

Known limitations

Watch

As bndl watches files in the current workspace for changes it won't detect file changes in internal dependencies. To save on resouces and downtime between file changes and restarts bndl also skips the bundling of internal dependencies. To work around this you could make clever use of nodemon and let it watch the output directory and recompile the changed files from the internal dependencies.

npx nodemon --watch <out-dir> --delay 100ms -e js,json --exec "npx turbo run build --filter <your-workspace>^... && npx bndl --only-bundle && npm run start"

The above will first build all internal dependendies (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.

Contributing

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.

Dependencies

~26–40MB
~698K SLoC