📦 Zero-configuration bundler for tiny modules.

Overview

microbundle

Microbundle npm travis

The zero-configuration bundler for tiny modules, powered by Rollup.


Guide → SetupFormatsModern ModeUsage & ConfigurationAll Options


Features

  • One dependency to bundle your library using only a package.json
  • Support for ESnext & async/await (via Babel & async-to-promises)
  • Produces tiny, optimized code for all inputs
  • Supports multiple entry modules (cli.js + index.js, etc)
  • Creates multiple output formats for each entry (CJS, UMD & ESM)
  • 0 configuration TypeScript support
  • Built-in Terser compression & gzipped bundle size tracking

🔧 Installation & Setup

1️⃣ Install by running: npm i -D microbundle

2️⃣ Set up your package.json:

{
  "name": "foo",                   // your package name
  "source": "src/foo.js",          // your source code
  "main": "dist/foo.js",           // where to generate the CommonJS/Node bundle
  "exports": "./dist/foo.modern.js", // path to the modern output (see below)
  "module": "dist/foo.module.js",  // where to generate the ESM bundle
  "unpkg": "dist/foo.umd.js",      // where to generate the UMD bundle (also aliased as "umd:main")
  "scripts": {
    "build": "microbundle",        // compiles "source" to "main"/"module"/"unpkg"
    "dev": "microbundle watch"     // re-build when source files change
  }
}

3️⃣ Try it out by running npm run build.

💽 Output Formats

Microbundle produces esm, cjs, umd bundles with your code compiled to syntax that works pretty much everywhere. While it's possible to customize the browser or Node versions you wish to support using a browserslist configuration, the default setting is optimal and strongly recommended.

🤖 Modern Mode

In addition to the above formats, Microbundle also outputs a modern bundle specially designed to work in all modern browsers. This bundle preserves most modern JS features when compiling your code, but ensures the result runs in 95% of web browsers without needing to be transpiled. Specifically, it uses preset-modules to target the set of browsers that support <script type="module"> - that allows syntax like async/await, tagged templates, arrow functions, destructured and rest parameters, etc. The result is generally smaller and faster to execute than the esm bundle:

// Our source, "src/make-dom.js":
export default async function makeDom(tag, props, children) {
	let el = document.createElement(tag);
	el.append(...(await children));
	return Object.assign(el, props);
}

Compiling the above using Microbundle produces the following modern and esm bundles:

make-dom.modern.js (117b) make-dom.module.js (194b)
export default async function (e, t, a) {
	let n = document.createElement(e);
	n.append(...(await a));
	return Object.assign(n, t);
}
export default function (e, t, r) {
	try {
		var n = document.createElement(e);
		return Promise.resolve(r).then(function (e) {
			return n.append.apply(n, e), Object.assign(n, t);
		});
	} catch (e) {
		return Promise.reject(e);
	}
}

This is enabled by default. All you have to do is add an "exports" field to your package.json:

{
	"main": "./dist/foo.umd.js", // legacy UMD output (for Node & CDN use)
	"module": "./dist/foo.module.js", // legacy ES Modules output (for bundlers)
	"exports": "./dist/foo.modern.js", // modern ES2017 output
	"scripts": {
		"build": "microbundle src/foo.js"
	}
}

The "exports" field can also be an object for packages with multiple entry modules:

{
	"name": "foo",
	"exports": {
		".": "./dist/foo.modern.js", // import "foo" (the default)
		"./lite": "./dist/lite.modern.js", // import "foo/lite"
		"./full": "./dist/full.modern.js" // import "foo"
	},
	"scripts": {
		"build": "microbundle src/*.js" // build foo.js, lite.js and full.js
	}
}

📦 Usage & Configuration

Microbundle includes two commands - build (the default) and watch. Neither require any options, but you can tailor things to suit your needs a bit if you like.

ℹ️ Microbundle automatically determines which dependencies to inline into bundles based on your package.json.

Read more about How Microbundle decides which dependencies to bundle, including some example configurations.

microbundle / microbundle build

Unless overridden via the command line, microbundle uses the source property in your package.json to locate the input file, and the main property for the output:

{
  "source": "src/index.js",      // input
  "main": "dist/my-library.js",  // output
  "scripts": {
    "build": "microbundle"
  }
}

For UMD builds, microbundle will use a camelCase version of the name field in your package.json as export name. This can be customized using an "amdName" key in your package.json or the --name command line argument.

microbundle watch

Acts just like microbundle build, but watches your source files and rebuilds on any change.

Using with TypeScript

Just point the input to a .ts file through either the cli or the source key in your package.json and you’re done.

Microbundle will generally respect your TypeScript config defined in a tsconfig.json file with notable exceptions being the "target" and "module" settings. To ensure your TypeScript configuration matches the configuration that Microbundle uses internally it's strongly recommended that you set "module": "ESNext" and "target": "ESNext" in your tsconfig.json.

If you're using TypeScript with CSS Modules, you will want to set "include": ["node_modules/microbundle/index.d.ts"] in your tsconfig.json to tell TypeScript how to handle your CSS Module imports.

CSS and CSS Modules

Importing CSS files is supported via import "./foo.css". By default, generated CSS output is written to disk. The --css inline command line option will inline generated CSS into your bundles as a string, returning the CSS string from the import:

// with the default external CSS:
import './foo.css';  // generates a minified .css file in the output directory

// with `microbundle --css inline`:
import css from './foo.css';
console.log(css);  // the generated minified stylesheet

CSS Modules: CSS files with names ending in .module.css are treated as a CSS Modules. To instead treat imported .css files as modules, run Microbundle with --css-modules true. To disable CSS Modules for your project, pass --no-css-modules or --css-modules false.

The default scope name for CSS Modules is_[name]__[local]__[hash:base64:5] in watch mode, and _[hash:base64:5] for production builds. This can be customized by passing the command line argument --css-modules "[name]_[hash:base64:7]", using these fields and naming conventions.

flag import is css module?
null import './my-file.css';
null import './my-file.module.css';
false import './my-file.css';
false import './my-file.module.css';
true import './my-file.css';
true import './my-file.module.css';

Specifying builds in package.json

Microbundle uses the fields from your package.json to figure out where it should place each generated bundle:

{
  "main": "dist/foo.js",            // CommonJS bundle
  "umd:main": "dist/foo.umd.js",    // UMD bundle
  "module": "dist/foo.m.js",        // ES Modules bundle
  "esmodule": "dist/foo.modern.js", // Modern bundle
  "types": "dist/foo.d.ts"          // TypeScript typings directory
}

Building a single bundle with a fixed output name

By default Microbundle outputs multiple bundles, one bundle per format. A single bundle with a fixed output name can be built like this:

microbundle -i lib/main.js -o dist/bundle.js --no-pkg-main -f umd

Mangling Properties

To achieve the smallest possible bundle size, libraries often wish to rename internal object properties or class members to smaller names - transforming this._internalIdValue to this._i. Microbundle doesn't do this by default, however it can be enabled by creating a mangle.json file (or a "mangle" property in your package.json). Within that file, you can specify a regular expression pattern to control which properties should be mangled. For example: to mangle all property names beginning an underscore:

{
	"mangle": {
		"regex": "^_"
	}
}

It's also possible to configure repeatable short names for each mangled property, so that every build of your library has the same output. See the wiki for a complete guide to property mangling in Microbundle.

Defining build-time constants

The --define option can be used to inject or replace build-time constants when bundling. In addition to injecting string or number constants, prefixing the define name with @ allows injecting JavaScript expressions.

Build command Source code Output
microbundle --define VERSION=2 console.log(VERSION) console.log(2)
microbundle --define API_KEY='abc123' console.log(API_KEY) console.log("abc123")
microbundle --define @assign=Object.assign assign(a, b) Object.assign(a, b)

All CLI Options

Usage
	$ microbundle <command> [options]

Available Commands
	build    Build once and exit
	watch    Rebuilds on any change

For more info, run any command with the `--help` flag
	$ microbundle build --help
	$ microbundle watch --help

Options
	-v, --version      Displays current version
	-i, --entry        Entry module(s)
	-o, --output       Directory to place build files into
	-f, --format       Only build specified formats (any of modern,es,cjs,umd or iife) (default modern,es,cjs,umd)
	-w, --watch        Rebuilds on any change  (default false)
	--pkg-main         Outputs files analog to package.json main entries  (default true)
	--target           Specify your target environment (node or web)  (default web)
	--external         Specify external dependencies, or 'none' (default peerDependencies and dependencies in package.json)
	--globals          Specify globals dependencies, or 'none'
	--define           Replace constants with hard-coded values (use @key=exp to replace an expression)
	--alias            Map imports to different modules
	--compress         Compress output using Terser
	--no-compress      Disable output compressing
	--strict           Enforce undefined global context and add "use strict"
	--name             Specify name exposed in UMD and IIFE builds
	--cwd              Use an alternative working directory  (default .)
	--sourcemap        Generate source map  (default true)
	--raw              Show raw byte size  (default false)
	--jsx              A custom JSX pragma like React.createElement (default: h)
	--jsxImportSource  Specify the automatic import source for JSX like preact
	--tsconfig         Specify the path to a custom tsconfig.json
	--css              Where to output CSS: "inline" or "external" (default: "external")
	--css-modules      Configures .css to be treated as modules (default: null)
	-h, --help         Displays this message

Examples
	$ microbundle build --globals react=React,jquery=$
	$ microbundle build --define API_KEY=1234
	$ microbundle build --alias react=preact/compat
	$ microbundle watch --no-sourcemap # don't generate sourcemaps
	$ microbundle build --tsconfig tsconfig.build.json

🛣 Roadmap

Here's what's coming up for Microbundle:

🔨 Built with Microbundle

  • Preact Fast 3kB React alternative with the same modern API. Components & Virtual DOM.
  • Stockroom Offload your store management to a worker easily.
  • Microenvi Bundle, serve, and hot reload with one command.
  • Theme UI Build consistent, themeable React apps based on constraint-based design principles.
  • react-recomponent Reason-style reducer components for React using ES6 classes.
  • brazilian-utils Utils library for specific Brazilian businesses.
  • react-hooks-lib A set of reusable react hooks.
  • mdx-deck-live-code A library for mdx-deck to do live React and JS coding directly in slides.
  • react-router-ext An Extended react-router-dom with simple usage.
  • routex.js A dynamic routing library for Next.js.
  • hooked-form A lightweight form-management library for React.
  • goober Less than 1KB css-in-js alternative with a familiar API.
  • react-model The next generation state management library for React

🥂 License

MIT

Comments
  • --compress true - is it a good default?

    --compress true - is it a good default?

    IMHO it makes debugging harder, its not easy to look into source code of libraries in node_modules (built by microbundle) nor it is easy to debug microbundle itself because its built by itself with --compress true (default).

    I guess the question is what is a primary goal & target of this tool? If producing micro libraries then I think files should be left unminified by default, minifying can be done later by subsequent tools - bundlers etc.

    opened by Andarist 33
  • How to get unbundled cjs/es modules as in version 0.4.4?

    How to get unbundled cjs/es modules as in version 0.4.4?

    First of all I would like to thank for the excellent tool!

    Before version 0.5.0, building with cjs and es format produced unbundled modules with required/imported dependencies (i.e. output of entry modules didn’t contain code of its dependencies). Is it possible to get the same result in the current version (0.11.0)?

    question :grey_question: needs more info has-fix 
    opened by gamtiq 28
  • [wip] Babel support

    [wip] Babel support

    Just a starter - need to figure out what else needs to be done to support this within your vision's frame 😉 any particular requirements come to your mind?

    fixes #25

    opened by Andarist 26
  • All CSS-files are treated as CSS Modules

    All CSS-files are treated as CSS Modules

    Regardless --css-modules flag, it is impossible to use CSS and CSS Modules in the same project. It seems that null option works incorrectly and Rollup treats all CSS files as modules.

    To reproduce, you could try to build this simple example:

    import React from 'react';
    
    import './index.css'
    import styles from './index.module.css';
    
    const App = () => (
      <div>
        <div className={styles.moduleClass}>CSS module class</div>
        <div className="local-no-module-class">No-module class</div>
      </div>
    );
    
    export default App;
    

    Building with microbundle ./index.jsx makes the following index.css file:

    ._1fWqO{color:#00f}
    ._3umtn{color:red}
    

    However, the expected result is:

    ._1fWqO{color:#00f}
    .local-no-module-class{color:red}
    
    upstream has-fix CSS 
    opened by artemtam 23
  • Invalid hook call. Hooks can only be called inside of the body of a function component

    Invalid hook call. Hooks can only be called inside of the body of a function component

    I receive the error Invalid hook call. Hooks can only be called inside of the body of a function component when attempting to use my Microbundled module in Create-React-App. Essentially, there are two versions of React. See Dan's comment.

    I ran into this issue previously but was able to solve it by adding --globals react=react1, which felt like a hacky solution. However, I just re-ran yarn install and the issue came back.

    Is there a known solution here?

    Here's my module's package.json file.

    {
      "dependencies": {
        "nanoid": "^2.1.8",
        "normalizr": "^3.4.1",
        "react": "^16.12.0",
        "react-dom": "^16.12.0",
        "react-redux": "^7.1.3",
        "redux": "^4.0.5",
        "redux-logger": "^3.0.6",
        "redux-thunk": "^2.3.0",
        "styled": "^1.0.0"
      },
      "devDependencies": {
        "babel-eslint": "^10.0.3",
        "eslint": "^6.8.0",
        "eslint-plugin-react": "^7.17.0",
        "eslint-plugin-react-hooks": "^1.7.0",
        "prop-types": "^15.7.2"
      },
      "license": "UNLICENSED",
      "main": "dist/index.js",
      "module": "dist/index.es.js",
      "name": "tk-ux",
      "peerDependencies": {
        "prop-types": "^15.7.2"
      },
      "repository": "github:pBread/tk-ux.git",
      "scripts": {
        "build": "microbundle build   --alias API=src/Modules/API/index.js,Constants=src/Constants/index.js,Containers=src/Containers/index.js,Modules=src/Modules/index.js,Utilities=src/Utilities/index.js    --globals react=React     --jsx React.createElement",
        "dev": "yarn link && cd example && yarn link 'tk-ux' && yarn start",
        "serve": "microbundle watch   --alias API=src/Modules/API/index.js,Constants=src/Constants/index.js,Containers=src/Containers/index.js,Modules=src/Modules/index.js,Utilities=src/Utilities/index.js    --globals react=React     --jsx React.createElement"
      },
      "source": "./src/index.js",
      "umd:main": "dist/index.umd.js",
      "version": "1.0.0"
    }
    
    question :grey_question: needs more info 
    opened by pBread 22
  • Replace bublé with babel

    Replace bublé with babel

    Hello 👋

    First of all - thank you so much for this project, it makes following best practices when packaging libraries for npm really easy!

    I saw the PR at #39 and thought I should help out by merging in the latest code from master and getting it up to date. However, a lot seems to have changed since #39 was created, so it was actually a lot easier to start from scratch. So that's what I did, and in this branch it now works with babel 7.

    Reading the discussion in #39, I interpreted @developit's comment as intent to replace bublé with babel, so that's what this PR does.

    as long as we can get a default babel config that is as optimized as Bublé, we can just default to Babel

    The generated configuration uses a default babel config consisting of preset-env and preset-react, alongside the existing plugins for async/await support. If a babel config file is detected, it uses a clean slate. I hope this is a sensible starting point; free to suggest changes or improvements.

    I kept the custom shebang plugin even though it references bublé because the build fails without it.

    The tests are currently failing due to increased output sizes. I wanted to get some feedback before I update the snapshots. Should we look into reducing them before going forward with this?

    A lot of inspiration in this PR was taken from @Andarist in #39. Thanks a lot for the pointers on where to look! Hope it's okay with you that I did it this way.

    Fixes #25

    opened by esphen 20
  • TypeScript 3.7.x: Optional chaining and nullish coalescing is broken

    TypeScript 3.7.x: Optional chaining and nullish coalescing is broken

    The latest version of TypeScript (3.7.x) is broken if using optional chaining and nullish coalescing. It fails with the following error:

    SyntaxError: /path/to/file.ts: Support for the experimental syntax 'optionalChaining' isn't currently enabled
    
    ...
    
    Add @babel/plugin-proposal-optional-chaining (https://git.io/vb4Sk) to the 'plugins' section of your Babel config to enable transformation.
    

    The simple fix (I think) is to update the TypeScript dependency in microbundle. However... my preference would be for microbundle to detect if I have another version of TypeScript already registered in my package.json and use that version as the default (falling back to the included dependency if required).

    opened by smithki 19
  • RFC: option for modern bundling.

    RFC: option for modern bundling.

    It's 2019 and browsers have caught up, 85% of browsers support classes and async/await. This makes me think that transpiling down to es5 won't benefit everyone since not everyone has to support older browsers.

    Historically the responsibility as to how far transpiled down a bundle was has always been the choiche of the author. I wanted to "feel the water" in something also suggested by Henry Zhu (author of babel) where authors would publish their module field as an ES6/ES2015 package and give the option to the developer to transpile this down if the need for IE11/... is needed.

    In essence this shouldn't pose an issue, adding a package to your babel-loader or tsconfig. I do think that it would be the responsibility of microbundle to document this option well enough so library authors are made aware of the possible implications for their consumers.

    I also made a small POC showing the difference in size. this is a shippable build that will fallback to a legacy bundle when need be.

    So in essence, the developer working with this could choose to transpile down library x and y for their legacy bundle and not for the modern one.

    To sum up and clarify the whole point, I would not say all module builds should be es6. I would suggest an option for the library author to build a more modern bundle.

    Thank you all for reading!

    Sources class async Deploying ES6 babel ES6

    enhancement :rocket: question :grey_question: 
    opened by JoviDeCroock 19
  • feat: add support for Babel macros

    feat: add support for Babel macros

    I think it'd be very useful to support Babel macros out of the box, they allow to use Babel without additional configuration so they can improve a lot the developer experience without adding extra configuration to Microbundle.

    Zero config tools such as create-react-app already support it.

    enhancement :rocket: 
    opened by FezVrasta 19
  • Breaks when trying to import typescript outside of directory

    Breaks when trying to import typescript outside of directory

    I'm working in a typescript monorepo structured sort of like this

    .
    ├── backend
    ├── frontend
    ├── shared
    └── package
       ├── package.json
       └── tsconfig.json
    

    I'm getting weird errors whenever in my package code I try to import a typescript module from outside the package directory. It's like microbundle doesn't know that it's a typescript file.

    For example, I import some typescript types that are generated by graphql-code-generator and live in the top level shared directory. When I import the file and run my build script I get this error message:

    (babel plugin) SyntaxError: /absolute/path/to/generated-types.ts: Support for the experimental syntax 'flow' isn't currently enabled (2:8):
    
      1 | import { GraphQLResolveInfo, GraphQLScalarType, GraphQLScalarTypeConfig } from 'graphql';
    > 2 | export type Maybe<T> = T | null;
        |        ^
      3 | export type Exact<T extends { [key: string]: unknown }> = { [K in keyof T]: T[K] };
      4 | export type MakeOptional<T, K extends keyof T> = Omit<T, K> & { [SubKey in K]?: Maybe<T[SubKey]> };
      5 | export type MakeMaybe<T, K extends keyof T> = Omit<T, K> & { [SubKey in K]: Maybe<T[SubKey]> };
    
    Add @babel/preset-flow (https://git.io/JfeDn) to the 'presets' section of your Babel config to enable transformation.
    If you want to leave it as-is, add @babel/plugin-syntax-flow (https://git.io/vb4yb) to the 'plugins' section to enable parsing.
    
    at undefined:2:7
    

    It looks like microbundle doesn't know this is typescript and thinks it's flow...

    However, when I copy the contents of that file into the package directory and import that instead, it builds just fine. Same with a symlink to that file from within the package.

    Just to be certain, I explicitly added the relative path to the include array in the packages/tsconfig.json, and got the same error.

    Why is microbundle unable to understand imports of files outside of the package directory? Or am I missing some configuration or something like that?

    upstream TypeScript 
    opened by n8jadams 17
  • An in-range update of rollup is breaking the build 🚨

    An in-range update of rollup is breaking the build 🚨

    The dependency rollup was updated from 1.12.3 to 1.12.4.

    🚨 View failing branch.

    This version is covered by your current version range and after updating it in your project the build failed.

    rollup is a direct dependency of this project, and it is very likely causing it to break. If other packages depend on yours, this update is probably also breaking those in turn.

    Status Details
    • continuous-integration/travis-ci/push: The Travis CI build failed (Details).

    Release Notes for v1.12.4

    2019-05-27

    Bug Fixes

    • Show correct error stack trace for errors throw in "load" hooks (#2871)

    Pull Requests

    Commits

    The new version differs by 4 commits.

    See the full diff

    FAQ and help

    There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


    Your Greenkeeper Bot :palm_tree:

    greenkeeper 
    opened by greenkeeper[bot] 17
  • transpiling jsx which includes Array().map or Array.keys

    transpiling jsx which includes Array().map or Array.keys

    Seems similiar to https://github.com/developit/microbundle/issues/820 I have converted my library from [email protected] to [email protected] and my build and start scripts from

    "scripts": {
        "build": "microbundle-crl --no-compress --no-css-modules --no-sourcemap --format modern,cjs",
        "start": "microbundle-crl watch --no-compress --no-css-modules --no-sourcemap --format modern,cjs",
      },
    

    to

    "scripts": {
        "build": "microbundle --no-compress --no-css-modules --no-sourcemap --format modern,cjs --jsx React.createElement --jsxFragment React.Fragment",
        "start": "microbundle watch --no-compress --no-css-modules --no-sourcemap --format modern,cjs --jsx React.createElement --jsxFragment React.Fragment",
      },
    

    But i have a problem with javascript Array since [...new Array(nLines).keys()] does not return an array of increasing numbers but returns an empty object [{}] and [...new Array(nLines)].map((_, index) => console.log(index)) prints nothing on console, but both codes works in the browser's dev tools console and in a project builded with react-scripts.

    I could use Array.from({ length: nLines }, (_, i) => ( <div key={i} className="line" /> )) which works, but i would prefer to know if i can change some build options to fix it and avoid future similiar occurances (maybe some globals?).

    I made a repo with my case https://github.com/AlbertoPravisano/microbundle-test

    opened by AlbertoPravisano 0
  • How to set file names for chunk bundles

    How to set file names for chunk bundles

    Chunk file is suffixed with random string. Is it possible to set fixed file name for chunk files?

    > microbundle --format=esm
    
    Build "foo" to dist:
             67 B: foo.esm.js.gz
             51 B: foo.esm.js.br
          12.3 kB: index-5d50c813.js.gz
          10.9 kB: index-5d50c813.js.br
          26.4 kB: core-9b3f477a.js.gz
          23.3 kB: core-9b3f477a.js.br
    
    Feature Request 
    opened by jalagari 1
  • fix: disable tree-shaking via PURE annotations when compression is disabled

    fix: disable tree-shaking via PURE annotations when compression is disabled

    When building a library, "pure" comments are often added to various bits and pieces to ensure tree-shaking works properly in the destination bundle. Compression via terser will automatically drop these hints in some cases, so disabling compression serves the purpose of leaving total minification up to the destination bundler.

    At the moment, rollup takes these pure comments into account as well when bundling which can lead to early-dropping of statements that are meant to be dropped later in the destination bundler. We should disable "pure" comment-related treeshaking in microbundle when compression is turned off to ensure this use case works as expected.

    For example, here's a use case which involves setting displayName on a component in a way that if the component is tree-shaken, the displayName goes away as well:

    export const Foo = (props) => <div {...props} />
    
    /*#​__PURE__*/Object.assign(Foo, { displayName: 'Foo' });
    
    opened by probablyup 2
  • No name was provided for external module for global packages

    No name was provided for external module for global packages

        Encountering this issue I have been wondering why with scoped npm packages this warning appears and  with non-scoped npm packages not.
    

    I found that scoped packages don't pass the following check: https://github.com/developit/microbundle/blob/fa3eac6f491288ff3b8cfd2812eecd350c7a2316/src/index.js#L337

    Curious if this is intented.

    Originally posted by @namjul in https://github.com/developit/microbundle/issues/223#issuecomment-788889113

    opened by schettn 1
  • Add `to` option to `rollup-plugin-postcss`

    Add `to` option to `rollup-plugin-postcss`

    I'm trying to use the postcss-url plugin to copy fonts that are imported by my CSS into the build directory. In order for it to work properly it requires the to option for rollup-plugin-postcss to be set.

    I was able to get it working locally by setting to: absMain.replace(EXTENSION, '.css') here: https://github.com/developit/microbundle/blob/22187fba8a2d404a9f3dc5db357e243cd45e8479/src/index.js#L495-L498

    This is the postcss.config.js I'm trying to use:

    module.exports = {
      plugins: {
        'postcss-url': {
          url: 'copy',
          basePath: '.',
          assetsPath: '',
          useHash: false,
        },
      },
    };
    

    Happy to provide more details, and thanks for your efforts on this great project!

    CSS 
    opened by mgburns 0
  • [Transpiling] Rest parameters with async bug

    [Transpiling] Rest parameters with async bug

    Minimal test case:

    export const brokenArgsRest = async (...props) => {
      await someAsyncFunction(async () => {  
          console.log(props)
      })
    }
    
    export const someAsyncFunction = async callback => {
      await callback()
    }
    

    generates

    var brokenArgsRest = function brokenArgsRest() {
      return Promise.resolve(someAsyncFunction(function () {
        try {
          var _arguments2 = arguments;
          console.log([].slice.call(_arguments2));
          return Promise.resolve();
        } catch (e) {
          return Promise.reject(e);
        }
      })).then(function () {});
    };
    var someAsyncFunction = function someAsyncFunction(callback) {
      try {
        return Promise.resolve(callback()).then(function () {});
      } catch (e) {
        return Promise.reject(e);
      }
    };
    

    var _arguments2 = arguments; should be one more level up

    Context: We hit this bug on fcl-js lib : https://github.com/onflow/flow-js-testing/issues/182

    PS: my js knowledge is limited, but seems related to inlining somehow.

    opened by bluesign 0
Releases(v0.15.1)
  • v0.15.1(Aug 12, 2022)

    Patch Changes

    • cebafa1 #961 Thanks @zyrong! - Fix for when multiple entries reference different CSS, only the CSS referenced by the first entry will be packaged

    • 9a4e2b2 #954 Thanks @rschristian! - Bumps Node target to v12

    • 4ad4b76 #967 Thanks @agilgur5! - deps: upgrade rpt2 to latest v0.32.0 to fix monorepos

    • 6018e58 #956 Thanks @rschristian! - Silences warnings when using Node builtins with the 'node:...' protocol on imports. Warnings related to bare usage of these builtins were already silenced.

    • 88241dd #968 Thanks @PeterBurner! - deps: upgrade babel-plugin-transform-async-to-promises to latest v0.8.18 to fix #565

    • e72377a #964 Thanks @rschristian! - Fixes filename generation for es & modern outputs. Both 'jsnext:main' and 'esmodule' were incorrectly ignored.

    Source code(tar.gz)
    Source code(zip)
  • v0.15.0(Apr 26, 2022)

    Minor Changes

    Patch Changes

    Source code(tar.gz)
    Source code(zip)
  • v0.14.2(Nov 18, 2021)

  • v0.14.1(Oct 14, 2021)

  • v0.14.0(Oct 6, 2021)

    Minor Changes

    Patch Changes

    Source code(tar.gz)
    Source code(zip)
  • v0.13.3(Jun 11, 2021)

  • v0.13.2(Jun 7, 2021)

  • v0.13.1(May 27, 2021)

    Patch Changes

    • 54402ac #830 Thanks @JounQin! - fix: add generateTypes cli option, check false value correctly

    • edcd777 #823 Thanks @rschristian! - Ensures ambient type declaration for CSS Modules is included in the published bundle

    • d87a5dc Thanks @developit! - - Fix --sourcemap=false to match --no-sourcemap and actually turn sourcemaps off.

    • 6f1a20f #777 Thanks @rschristian! - Fixing a bug that would cause a CSS file to be generated to match each JS build output

    • 25b73d2 #834 Thanks @cometkim! - Add support for configuration overrides using the publishConfig package.json field.

    • a7f7265 #802 Thanks @aheissenberger! - fix default extension to cjs for package.json "type":"module"

    • 4f7fbc4 Thanks @developit! - Fix transform-fast-rest to support referencing ...rest params from within closures.

    • 0c91795 #841 Thanks @rschristian! - Ensures JS format is not included in CSS filename output

    Source code(tar.gz)
    Source code(zip)
  • v0.13.0(Dec 21, 2020)

    Minor Changes

    • bd5d15e #738 Thanks @wardpeet! - Upgrade rollup to version latest and upgrade all its dependencies

    • 967f8d5 #769 Thanks @developit! - Add --css inline option. The default CSS output for all formats is now external files (as it was supposed to be).

    • 8142704 #741 Thanks @whitetrefoil! - Use user's typescript first, fallback to bundled

    Patch Changes

    Source code(tar.gz)
    Source code(zip)
  • v0.12.4(Sep 28, 2020)

    Patch Changes

    Source code(tar.gz)
    Source code(zip)
  • 0.12.3(Jul 14, 2020)

    Features & Improvements

    • New onStart, onError callbacks for programmatic Microbundle usage! (#668, thanks @katywings!)
    • allow multi-file output and code splitting (#674, thanks @katywings!)
    • Strip comments from output (#548)

    Bug Fixes

    • don't mark --alias modules as externals (#671, thanks @katywings!)
    Source code(tar.gz)
    Source code(zip)
  • 0.12.2(Jun 20, 2020)

    • Updated Babel and preset-env to 7.10 (#660)
    • Fixed an version conflict caused by multiple copies of Babel (#664)
    • Fixed globals generation when --external values include dashes (#667, thanks @katywings!)
    Source code(tar.gz)
    Source code(zip)
  • 0.12.1(Jun 15, 2020)

    Features

    • New --no-pkg-main option for disabling filename inference (#658, thanks @katywings)
    • Allow the use of import.meta (#627, thanks @developit)

    Bugfixes

    • Fix non-alphanumeric values for --external (#650, thanks @katywings)
    • Preserve comments when --no-compress is enabled (#648, thanks @developit)
    • Fix TypeScript issue when "module" is set to "CommonJS" (#638, thanks @marvinhagemeister)
    • Fix TypeScript declaration emit target (#629, thanks @marvinhagemeister)
    • Fix TypeScript declarationDir option so it respects the cwd (#643) (#646, thanks @katywings)
    • Fix TypeScript Fragments breaking when jsxFactory is set (#623, thanks @marvinhagemeister)

    General Improvements

    • Dependency updates (#634 #616, thanks @teodragovic, @merceyz)
    • Documentation updates for 0.12 and --externals (#636 #628 #625 #609 #611 #614, thanks @gtrufitt, @developit, @SeanBannister, @adrienpoly & @i-like-robots)
    Source code(tar.gz)
    Source code(zip)
  • 0.12.0(May 8, 2020)

    • Output modern JavaScript with --format modern (#413, thanks @JoviDeCroock & @marvinhagemeister)
    • --define can now replace expressions (#348, thanks @jviide)
    • a new --css-modules option controls whether .css files are modular by default (#370, thanks @maraisr)
    • the "source" package.json field can now be an Array (#372, thanks @maraisr)
    • no more warnings about deprecations or built-ins
    • moved to Rollup 2 (#361, thanks @ForsakenHarmony)
    • switched from Bublé to Babel (#362, thanks @wardpeet & @ForsakenHarmony)
    • added support for babel-macros (#268, thanks @FezVrasta & @ForsakenHarmony)
    • Add support for customizing the mangle.json file path (#432, thanks @andrewiggins & @ForsakenHarmony)
    • Improvements and corrections for generated TypeScript filenames and definitions (#587 etc)

    Breaking Changes

    • .babelrc is now detected and supported - it was previously ignored.
    • Microbundle now requires Node 10+
    Source code(tar.gz)
    Source code(zip)
  • 0.12.0-next.9(May 1, 2020)

    • Fix accidental bundle size increase due to core-js version (#550)
    • Use preset-modules for modern output (#557, thanks @JoviDeCroock)
    • Add --css-modules option for *.css files in addition to *.module.css (#370, thanks @maraisr)
    • Fix a bug that caused modern output to be not modern (#570)
    • Add support for --define @expression=replacement (#588)
    • Silence a bunch of unnecessary warnings
    • Reduce bundle size when using async/await, in particular for await () (#596)
    • Fix output filename generation when using .ts entry modules (#587)
    Source code(tar.gz)
    Source code(zip)
  • 0.11.0(Mar 4, 2019)

    New mangle.json / package.json configuration for Terser!

    {
      // "minify" for Terser (https://github.com/terser-js/terser#minify-options-structure)
      // Note: works as a key in both package.json or mangle.json
      "minify": {
        // Legacy/convenient way to set mangle.properties.{regex,reserved}:
        "properties": "^_",
        "reserved": ["_dom", "_constructor"],
    
        // Optionally specify Terser compress configuration.
        // Supported values: https://github.com/terser-js/terser#compress-options
        "compress": {
          "hoist_vars": true,
          "reduce_funcs": false
        },
    
        // Optionally specify Terser mangle configuration
        // Supported values: https://github.com/terser-js/terser#mangle-options
        "mangle": {}
      }
    }
    
    Source code(tar.gz)
    Source code(zip)
  • 0.10.1(Feb 22, 2019)

    🐧 new --define option! Inlines constants (great for Dead Code Elimination):

    microbundle --define process.env.NODE_ENV=production,DEBUG=false
    

    🐺 new --alias option! Remap imports from one module to another:

    microbundle --alias react=preact,react-dom=preact
    

    🦊 Lovely refactoring from @MatiasOlivera and @ForsakenHarmony :)

    🦑We turned minification up to 11!! (#321, thanks @jviide)

    Source code(tar.gz)
    Source code(zip)
  • 0.9.0(Dec 18, 2018)

  • 0.8.4(Dec 17, 2018)

    Patches

    • Fix importing superagent: #245 (thx @luisrudge ❤️, sorry for not releasing a minor)
    • Fix tests and async not being transpiled in Typescript: #262 & #269 (thx @marvinhagemeister ❤️)
    • Fix hoisted packages: #271 (thx @FezVrasta ❤️)
    • Update snapshots to fix tests and add cross-env for windows: 🙃
    Source code(tar.gz)
    Source code(zip)
  • 0.8.2(Dec 3, 2018)

  • 0.8.1(Dec 1, 2018)

  • 0.8.0(Nov 30, 2018)

    Features

    • Fix the jsx error that's been haunting us for some time: #252 (thx @marvinhagemeister ❤️)

    Patches

    • Fix linting error that caused ci to fail: #248 (thx @marvinhagemeister ❤️)
    Source code(tar.gz)
    Source code(zip)
  • 0.7.0(Oct 26, 2018)

    Possibly breaking

    • Change default target to web & Don't minify by default for target == "node": #234 (me)
    • Change "module" field from .m.js to .mjs: #213 (thx @Loilo ❤️)

    Features

    • Add --jsx as a cli option to specify the pragma: #163 (thx @luxp ❤️)
    • Add --raw option to display the raw byte count: #174 (thx @andrewiggins ❤️)
    • Brotli sizes: #180 (thx @kristoferbaxter ❤️)
    • Supports --globals config (rename global dependencies): #186 (thx @Ayc0 ❤️)
    • Support TypeScript 3: #192 (thx @texastoland ❤️)
    • Migrate to terser from uglify-js: #137 (thx @Andarist and @chocolateboy ❤️)
    • Support for TypeScript sourcemaps: #227 (thx @alexbenic ❤️)

    Bugfixes / Patches

    • Fix issue when using cwd and package.source: #176 (thx @gribnoysup ❤️)

    • Switch jest environment to node to fix tests: #179 (thx @gribnoysup ❤️)

    • Use async version of brotli-size (0.0.3): #182 (thx @developit ❤️)

    • Add cache folder for each format in typescript to fix a cache issue: (thx @alexbenic ❤️)

    • Don't compress microbundle dist: #231 (me)

    • Updates for dependencies (thx @greenkeeper[bot] 🙃 and @joelgallant ❤️)

    Source code(tar.gz)
    Source code(zip)
  • 0.6.0(Jul 19, 2018)

    • Microbundle now uses the .mjs file extension for JS Module files, and will auto-detect them as source code.
    • Update to the latest and greatest Rollup.

    Source code(tar.gz)
    Source code(zip)
  • 0.5.1(Jul 5, 2018)

    Special thanks to @Andarist and @ForsakenHarmony for their awesome work keeping Microbundle moving forward! 🙇‍♂️

    • Breaking Change: --external all is now the default. Modules listed in your package.json's "dependencies" and "peerDependencies" will be linked as imports/require statements (thanks @Andarist)
    • Importing subdirectories from packages now treats them as external (#83, thanks @Andarist)
    • When builds fail, actually output some useful information (#120, thanks @jesstelford)
    • Output much more helpful Rollup errors (#128, thanks @gribnoysup)
    • Fix error reporting in watch mode and make fatal watch errors exit with an error code (#153, thanks @mattdesl)
    • Minify CSS assets with cssnano (#121, thanks @nicksrandall)
    • Add .tsx support! (thanks @jaredpalmer)
    • Updated to Rollup 0.60+
    • watch mode can now also be activated via a --watch flag (thanks @ngryman)
    Source code(tar.gz)
    Source code(zip)
  • 0.4.4(Feb 21, 2018)

    • New API: options.onBuild. You supply a function, it gets called on each build in watch mode (thanks @fwilkerson)
    • Switch to rollup-plugin-typescript2 🔥 (thanks @freeman)
    • Add --source-map option (use --no-source-map to disable them, thanks @cristianbote)
    Source code(tar.gz)
    Source code(zip)
  • 0.4.3(Jan 26, 2018)

    Changes & Features

    • Switch to the latest typescript & fix issue with importHelpers (#69, thanks @tymondesigns)
    • Switch to uglify-es by default for better compression!

    Bugs Fixed

    • Fix flowtype issue "Cannot read property 'code' of undefined" (#64, thanks @tlvince)
    • Fix "Unknown plugin 'jsx'" (workaround until oligot/rollup-plugin-nodent#6 is merged)
    Source code(tar.gz)
    Source code(zip)
  • 0.4.2(Jan 24, 2018)

  • 0.4.1(Jan 24, 2018)

  • 0.4.0(Jan 23, 2018)

    • Support for TypeScript! (#16, thanks @tymondesigns!!)
    • Support for scoped packages (#51, thanks @Andarist!)
    • Simpler warnings for missing/erroneous package.json
    • Fix acorn-jsx issue (we hope!)
    Source code(tar.gz)
    Source code(zip)
Owner
Jason Miller
Making the web faster at @google. Creator of @preactjs.
Jason Miller
📦🚀 Blazing fast, zero configuration web application bundler

Features ?? Blazing fast bundle times - multicore compilation, and a filesystem cache for fast rebuilds even after a restart. ?? Out of the box suppor

Parcel 41.8k Jan 4, 2023
Next-generation ES module bundler

Rollup Overview Rollup is a module bundler for JavaScript which compiles small pieces of code into something larger and more complex, such as a librar

Rollup 22.7k Jan 4, 2023
A blazing fast js bundler/loader with a comprehensive API :fire:

A bundler that does it right FuseBox on slack FUSEBOX v4 is out! Install: npm install fuse-box --save-dev import { fusebox } from 'fuse-box'; fusebox

null 4k Dec 30, 2022
on-demand module bundler thingy

lurantis An HTTP server that bundles and serves packages from NPM; "bundler as a service." Usage Run the server: npx lurantis --port 8080 Then, send G

Lily Scott 6 Feb 21, 2022
📦🚀 Blazing fast, zero configuration web application bundler

Features ?? Blazing fast bundle times - multicore compilation, and a filesystem cache for fast rebuilds even after a restart. ?? Out of the box suppor

Parcel 41.8k Jan 4, 2023
📦🚀 Blazing fast, zero configuration web application bundler

Features ?? Blazing fast bundle times - multicore compilation, and a filesystem cache for fast rebuilds even after a restart. ?? Out of the box suppor

Parcel 41.8k Jan 4, 2023
Grupprojekt för kurserna 'Javascript med Ramverk' och 'Agil Utveckling'

JavaScript-med-Ramverk-Laboration-3 Grupprojektet för kurserna Javascript med Ramverk och Agil Utveckling. Utvecklingsguide För information om hur utv

Svante Jonsson IT-Högskolan 3 May 18, 2022
Hemsida för personer i Sverige som kan och vill erbjuda boende till människor på flykt

Getting Started with Create React App This project was bootstrapped with Create React App. Available Scripts In the project directory, you can run: np

null 4 May 3, 2022
Kurs-repo för kursen Webbserver och Databaser

Webbserver och databaser This repository is meant for CME students to access exercises and codealongs that happen throughout the course. I hope you wi

null 14 Jan 3, 2023
⚡A zero-config bundler for JavaScript applications.

Poi is a bundler built on the top of webpack, trying to make developing and bundling apps with webpack as easy as possible. The Poi project is support

Eren Bets 5.3k Jan 4, 2023
📦 🍣 Zero-config JS bundler for ESM, CommonJS, and .d.ts outputs

pkgroll Write your code in ESM & TypeScript and bundle it to get ESM, CommonJS, and type declaration outputs with a single command! Features Zero conf

hiroki osame 153 Dec 23, 2022
📦 🍣 Zero-config JS bundler for ESM, CommonJS, and .d.ts outputs. (Forked from pkgroll)

?? ?? puild (A fork of pkgroll) Write your code in ESM & TypeScript and bundle it to get ESM, CommonJS, and type declaration outputs with a single com

ʀᴀʏ 6 Sep 6, 2022
a simple zero-configuration command-line http server

http-server: a command-line http server http-server is a simple, zero-configuration command-line http server. It is powerful enough for production usa

http ... PARTY! 12.4k Jan 4, 2023
A template to create a React Library. Zero configuration, just use!

React lib template ?? A simple React lib template based on Parcel and Jest. Usage use this template for your next React lib, modify it and run npm run

Raí Siqueira 15 Aug 22, 2022
Minimal, zero-configuration and fast solution for static site generation in any front-end framework.

Staticit - Introduction Whether you want to increase performance of your web application or improve SEO. Generally you have 2 options, use SSR (Server

Engineerhub 4 Jun 11, 2022
Compile Master CSS ahead of time with zero-configuration integration with build tools

CSS Compiler Compile Master CSS ahead of time with zero-configuration integration with build tools On this page Usage webpack.config.js vite.config.js

Master 5 Oct 31, 2022
A toolkit for React, Preact, Inferno & vanilla JS apps, React libraries and other npm modules for the web, with no configuration (until you need it)

nwb nwb is a toolkit for: Quick Development with React, Inferno, Preact or vanilla JavaScript Developing: React Apps Preact Apps Inferno Apps Vanilla

Jonny Buchanan 5.5k Jan 3, 2023
Zero Two Bot,A fully Modular Whatsapp Bot to do everything possible in WhatsApp by Team Zero Two

?? ???????? ?????? ???? ?? A Moduler WhatsApp Bot designed for both PM and Groups - To take your boring WhatsApp usage into a whole different level. T

Sam Pandey 69 Dec 25, 2022