Bundler is a zero configuration bundler with the web in mind.
- Webplatform and Deno are the source of truth
- Embrace the future (no legacy feature support)
- No configuration setup
- Allow flexible and modular usage of bundler API and CLI
- handles static
import
andexport
statements - handles dynamic
import()
statements - handles
fetch()
statements - handles
WebWorker
imports - handles
ServiceWorker
imports
- handles
<link>
,<script>
,<style>
,<source>
,<img>
and<video>
tags - handles
style
attributes
- handles
css
@import
statements - supports postcss-preset-env stage 2 and nesting-rules by default
Bundler automatically analyzes the dependency graph and splits dependencies into separate files, if it is used on multiple occasions. This prevents code duplication and allows multiple bundle files to share code.
- built in file watcher with
--watch
option - built in code optimization and minification with
--optimize
option - uses cache dir
.bundler
for faster reloads
deno install --unstable --allow-read --allow-write --allow-net --allow-env --name bundler https://deno.land/x/bundler/cli.ts
Info: You might need to specify --root /usr/local
.
bundler bundle index.html=index.html
This will analyze the entry file index.html
and its dependencies, generate
bundles and write the output files into an directory.
Option | Description | Default |
---|---|---|
-c, --config <FILE> | The configuration file can be used to configure different aspects of deno including TypeScript, linting, and code formatting. Typically the configuration file will be called deno.json or deno.jsonc and automatically detected; in that case this flag is not necessary. See https://deno.land/[email protected]/getting_started/configuration_file |
{} |
--out-dir <DIR> | Name of out_dir | "dist" |
-h, --help | Prints help information | |
--import-map <FILE> | Load import map file from local file or remote URL. Docs: https://deno.land/[email protected]/linking_to_external_code/import_maps Specification: https://wicg.github.io/import-maps/ Examples: https://github.com/WICG/import-maps#the-import-mapfile |
{} |
--optimize | Optimize source code | false |
-L, --log-level | Set log level [possible values: debug, info] | debug |
-q, --quiet | Suppress diagnostic output | false |
--watch | Watch files and re-bundle on change | false |
import { bundle } from "https://deno.land/x/bundler/mod.ts";
const input = "src/index.html";
const inputs = [input];
const outputMap = { [input]: "index.html" };
const { bundles } = await bundle(inputs, { outputMap });
import {
Bundler,
HTMLPlugin,
TypescriptPlugin,
} from "https://deno.land/x/bundler/mod.ts";
const input = "src/index.html";
const inputs = [input];
const outputMap = { [input]: "index.html" };
const plugins = [
new HTMLPlugin(),
new TypescriptPlugin(),
];
const bundler = new Bundler({ plugins });
const assets = await bundler.createAssets(inputs);
const chunks = await bundler.createChunks(inputs, assets, { outputMap });
const bundles = await bundler.createBundles(chunks);
This module requires deno to run with the --unstable
flag. It is likely to
change in the future.