Code Monkey home page Code Monkey logo

bundler's Introduction

Bundler

Bundler

About

Bundler is a zero configuration bundler with the web in mind.

Goals

  • 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

Features

Typescript and Javascript

  • handles static import and export statements
  • handles dynamic import() statements
  • handles fetch() statements
  • handles WebWorker imports
  • handles ServiceWorker imports

HTML

  • handles <link>, <script>, <style>, <source>, <img> and <video> tags
  • handles style attributes

CSS

  • handles css @import statements
  • supports postcss-preset-env stage 2 and nesting-rules by default

Smart-Splitting

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.

Dev tools

  • built in file watcher with --watch option
  • built in code optimization and minification with --optimize option
  • uses cache dir .bundler for faster reloads

Installation

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.

Usage

CLI

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.

Options

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

API

Example

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 });

Advanced Example

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);

Unstable

This module requires deno to run with the --unstable flag. It is likely to change in the future.

bundler's People

Contributors

timreichen avatar itays123 avatar voltrevo avatar deckchairlabs avatar marcomow avatar aaronwlee avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.