lpm bundle
Bundle JavaScript and TypeScript with managed Rolldown, per-project pins, and workspace selection.
Bundle an application or a script with Rolldown. LPM CLI manages the bundler and can run it across selected workspace members.
lpm bundle [OPTIONS] [ARGS]...Quickstart
lpm bundle --entry src/index.ts --out-dir dist --format esm --platform browserLPM CLI downloads its approved Rolldown version and checks its integrity on first use. A project-local Rolldown installation is unnecessary.
The command supports a single build, workspace builds, and watch mode. Use lpm pack for library builds with tsdown.
Project configuration
Pin an approved Rolldown version and a Node runtime in lpm.json:
{
"tools": {
"rolldown": "1.2.14"
},
"runtime": {
"node": "22"
}
}tools.rolldown selects an exact version. The version must match the bundled baseline or an approved version from lpm plugin update.
Without a pin, LPM CLI selects its bundled baseline or a newer approved version. A workspace member inherits the root pin unless its own lpm.json overrides it. Invocations from nested directories retain the project pin.
There is no command flag to override or skip tools.rolldown. Bundle inputs and output options belong in CLI arguments or a Rolldown configuration file.
Node selection
Rolldown needs Node. The bundled Rolldown 1.2.14 requires Node ^20.19.0 || >=22.12.0.
lpm use node@22
lpm bundle --entry src/index.ts --out-dir distThe bundle command uses an installed managed runtime selected by lpm.json, .nvmrc, or .node-version. It does not download a missing runtime. lpm use installs the runtime.
A member inherits the workspace root's Node selection unless it selects its own Node version. A Bun-only member selection retains the inherited Node selection.
Executable lookup uses local node_modules/.bin directories, then the selected managed runtimes, then the inherited PATH. Automatic local lookup stops at the project or workspace root.
If the selected Node version is unavailable, lookup falls back to the inherited PATH. An unavailable member selection does not use the root's managed Node selection.
Recipes
Build for Node
lpm bundle --entry src/cli.ts --out-dir dist --format esm --platform nodeMinify a browser bundle
lpm bundle --entry src/index.ts --out-dir dist --platform browser --minify --sourcemapUse a Rolldown configuration file
export default {
input: 'src/index.ts',
output: {
dir: 'dist',
format: 'esm',
},
};lpm bundle --config rolldown.config.mjs
lpm bundle --config rolldown.config.mjs --minifyCLI options override the corresponding configuration values. Relative paths use the current directory, or each selected member's directory in workspace mode.
To ask Rolldown to discover its configuration file in that directory:
lpm bundle -- --configRolldown checks rolldown.config.js, .mjs, .cjs, .ts, .mts, and .cts, in that order. Bare lpm bundle shows Rolldown help.
Watch one project
lpm bundle --entry src/index.ts --out-dir dist -- --watch
lpm bundle --filter web --config rolldown.config.mjs -- --watchWatch mode requires an output directory or file. In workspace mode, it requires exactly one selected member. It rejects --json.
Forwarded --watch=false and -w=false run a finite build. A watch object in a Rolldown configuration file does not enable watch mode by itself.
Run in CI
lpm bundle --filter web --fail-if-no-match --config rolldown.config.mjs --jsonThe command requires no interactive input. Prepare the approved engine and Node runtime before a run without network access.
Forward other Rolldown options
lpm bundle --entry src/index.ts --out-dir dist -- --external react --external react-dom
lpm bundle -- --helpArguments after -- go to Rolldown unchanged. --entry maps to --input, and --out-dir maps to --dir.
Without an output directory or file, a single build can print its generated code to stdout. Use an output path for JSON runs, which suppress successful child output.
Workspaces
lpm bundle --all --config rolldown.config.mjs
lpm bundle --filter web --filter api --config rolldown.config.mjs
lpm bundle --filter-prod '...shared' --config rolldown.config.mjs
lpm bundle --affected --base origin/main --config rolldown.config.mjsSelected dependencies run before their dependents. Independent members can run concurrently, up to the host CPU count. A ready member can start when a slot becomes available.
LPM CLI prepares each requested engine version before member execution. Members with the same requested pin share a prepared engine.
--all conflicts with --filter, --filter-prod, and --affected. Filters and --affected combine their selections.
An empty selection succeeds without a build. Add --fail-if-no-match when a selected member must exist. Watch mode always rejects an empty selection.
See workspace filters for dependency closures, exclusions, path patterns, and Git references.
JSON and exit codes
lpm bundle --entry src/index.ts --out-dir dist --json
lpm bundle --all --config rolldown.config.mjs --jsonBoth modes emit one JSON object with member results, exit codes, and durations. Failed members include captured diagnostics. Successful members omit captured output.
A launch failure has exit_code: null and an error message. Earlier preparation errors can use the standard error object.
See the lpm lint JSON example for the envelope shape. LPM CLI retains at most 10 MiB per output stream, with a truncation marker for longer diagnostics.
Single-project runs preserve Rolldown's exit code. Workspace runs exit 1 if any member fails. On Unix, interruption stops active tool descendants and exits 130 for SIGINT or 143 for SIGTERM.
Cache and recovery
Managed engines normally live under ~/.lpm/engines/rolldown/<version>/<platform>/. LPM_HOME changes the base directory.
LPM CLI checks downloaded package integrity and the installed engine before reuse. It replaces a cached engine that fails this check.
lpm plugin outdated
lpm plugin update rolldownThe bundle command does not check for the latest upstream version. lpm plugin update approves an available update.
If Node cannot start, install a compatible runtime with lpm use. If configuration parsing fails, correct the reported file before retrying.
Flags
| Flag | Effect |
|---|---|
--entry <ENTRY> | Input file. Maps to Rolldown's --input. |
--out-dir <OUT_DIR> | Output directory. Maps to Rolldown's --dir. |
--config <CONFIG> | Explicit Rolldown configuration file. |
--format <FORMAT> | Output format: esm, cjs, or iife. |
--platform <PLATFORM> | Target platform: node, browser, or neutral. |
--minify | Minify the output. |
--sourcemap | Generate a source map. |
--all | Run in every workspace member. Conflicts with filters and --affected. |
--filter <FILTER> | Select members with a repeatable workspace filter. |
--filter-prod <FILTER_PROD> | Select members with production-only dependency closures. |
--affected | Select changed members and their affected dependents. |
--base <BASE> | Git base for --affected. Default: main. |
--changed-files-ignore-pattern <PATTERN> | Ignore matching changed paths. Repeatable. |
--test-pattern <PATTERN> | Treat matching changes as tests when calculating dependent selection. Repeatable. |
--fail-if-no-match | Fail when the workspace selection is empty. |
[ARGS]... | Arguments forwarded to Rolldown. Use -- to separate them from LPM CLI flags. |
See global flags for --json and other shared options.
See also
lpm pack— build libraries with tsdown.lpm check— check TypeScript types.lpm plugin— inspect and update managed tools.lpm use— install and select Node or Bun.