A Deno bundler wrapper that provides external package resolution and string replacements.
A powerful Deno bundler wrapper that provides external package resolution and
string replacements for seamless module bundling.
npm:, jsr:, https:)deno add jsr:@sandros94/deno-bundler
import { build } from "@sandros94/deno-bundler";
const result = await build({
entrypoints: ["./main.ts"],
external: ["h3", "rendu"],
minify: true,
});
console.log(`Bundled in ${result.duration}ms`);
console.log(`Output files: ${result.outputFiles.join(", ")}`);
Use the replace option to perform string replacements on the bundled output.
This is useful for adapting code to different runtimes:
import { build } from "@sandros94/deno-bundler";
await build({
entrypoints: ["./main.ts"],
replace: {
"Deno.serve": "Bunny.v1.serve",
"Deno.env": "Bun.env",
},
});
| Option | Type | Default | Description |
|---|---|---|---|
entrypoints |
string[] |
["./main.ts"] |
Entry point files to bundle |
external |
string[] |
[] |
Packages to mark as external (won’t be bundled) |
outputDir |
string |
"dist" |
Output directory for bundled files |
outputPath |
string |
- | Output path for single file bundle |
minify |
boolean |
true |
Whether to minify the output |
replace |
Record<string, string> |
{} |
String replacements to apply to bundled output |
Run the bundler directly from JSR:
deno run -A jsr:@sandros94/deno-bundler
| Flag | Alias | Description |
|---|---|---|
--entrypoints |
-i |
Entry point files (comma-separated) |
--external |
-e |
External packages (comma-separated) |
--outputDir |
-o |
Output directory |
--outputPath |
Output path for single file | |
--minify |
-m |
Enable minification (default: true) |
--no-minify |
Disable minification | |
--replace |
-r |
String replacement in key=value format |
# Basic usage with defaults
deno run -A jsr:@sandros94/deno-bundler
# Specify entrypoints and external packages
deno run -A jsr:@sandros94/deno-bundler \
--entrypoints="./main.ts" \
--external="h3,rendu"
# Multiple external packages (alternative syntax)
deno run -A jsr:@sandros94/deno-bundler \
-e h3 \
-e rendu \
-i ./main.ts
# With string replacements
deno run -A jsr:@sandros94/deno-bundler \
--replace="Deno.serve=Bunny.v1.serve" \
--replace="Deno.env=Bun.env"
# Disable minification
deno run -A jsr:@sandros94/deno-bundler --no-minify
# Custom output directory
deno run -A jsr:@sandros94/deno-bundler --outputDir=build
Deno.bundle() API to bundle your@deno/loader to"h3") to their resolved Deno specifiers (like"jsr:@hono/h3@1.0.0")Deno.bundle() API (unstable)The Deno.bundle() API requires the unstable bundle feature. Add this to your
deno.json:
{
"unstable": ["bundle"]
}
Or run with the --unstable-bundle flag:
deno run -A --unstable-bundle jsr:@sandros94/deno-bundler
MIT
We use cookies
We use cookies to analyze traffic and improve your experience. You can accept or reject analytics cookies.