Skip to main content
Deno 2 is finally here 🎉️
Learn more

Asset bundler for Deno apps

deno-buckets logo
deno-buckets

deno doc GitHub License GitHub release (latest by date)

Buckets is a wrapper around the native Deno emit, it allows you to select source files, and then bundle their resolved default exports.

Example

data.ts:

// is-deno-bucket
export default Deno.readTextFileSync("./lorem.txt");

app.ts:

import data from "./data.ts";
console.log(data);

Then run: buckets app.ts > app.bundle.js:

// app.bundle.js
const __default = "Lorem ipsum dolor sit amet\n";
console.log(__default);

Usage

Add the comment // is-deno-bucket at the beginning of the files you want to resolve before bundling. Then, bundle your app with deno-buckets. Only the default export will be resolved.

CLI

Install:

deno install --allow-net --allow-read --allow-write --allow-env https://deno.land/x/buckets/buckets.ts

Run:

buckets <entry_path> [import_map_path] > out.js

Buckets will look for deno.json or deno.jsonc in the current folder. To use a different imports map, pass it’s path as the second argument

Alternatively, you can use it directly from the deno.land/x source:

deno run --allow-read --allow-write --allow-net --allow-env https://deno.land/x/buckets@v0.7.0/buckets.ts your_entry_file.ts > bundle.js

API

import { bundle } from "https://deno.land/x/buckets/mod.ts";

const content = await bundle("./app.ts", "deno.json");
Deno.writeTextFileSync("app.bundle.js", content);


© 2021 Jacobo Tabernero Rey - Released under MIT License