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
importandexportstatements - handles dynamic
import()statements - handles
fetch()statements - handles
WebWorkerimports - handles
ServiceWorkerimports
- handles
<link>,<script>,<style>,<source>and<img>tags - handles
styleattributes - handles
webmanifestfiles
- handles
css@importstatements - 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
--watchoption - built in code optimization and minification with
--optimizeoption - uses cache dir
.bundlerfor faster reloads
deno install --unstable --allow-read --allow-write --allow-net --allow-env --name bundler https://deno.land/x/bundler/cli.tsInfo: You might need to specify --root /usr/local.
bundler bundle index.html=index.htmlThis 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.jsoncand 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.