Coder Social home page Coder Social logo

nollup's Introduction

Nollup

Build Status NPM Version License

Rollup compatible bundler, designed to be used in development, while Rollup is used to generate a production build.

Motivation

  • Rollup is excellent, but during development it can be a bit slow as it's performing unnecessary build steps (tree-shaking).
  • When making changes to files, Rollup has to recompile the entire bundle due to the tree-shaking optimisations. This can lead to slow rebuild times.
  • Wanted something similar to Webpack development flow, but with the simplicity of the Rollup configuration and plugin ecosystem.
  • To give developers a foundation for implementing Hot Module Replacement when using Rollup.
  • While Rollup does have watching functionality, it writes to disk and isn't intended to be used in-memory.

What does this do?

  • Nollup doesn't attempt to do any optimisations, it simple concatenates all of the modules together with simple function wrappers.
  • ES6 import and export statements are detected and replaced with an internal module loader.
  • Each module is wrapped in an eval call with source maps.
  • Compatible with Rollup plugins, so you can use one single Rollup configuration for both development and production. Make sure the plugin uses emitAsset instead of writing to disk.
  • Detects changed files, and performs a rebuild and has support for Hot Module Replacement.

Examples

See examples directory on how to use.

CLI

Nollup provides a dev server which can be used as a CLI command.

    "scripts": {
        "start": "nollup -c"
    }

See "Nollup Options" for list of available flags.

.nolluprc

Configuration file that can be used to pass configuration instead of as flags through the CLI.

{
    "hot": true,
    "contentBase": "./public"
}

A JavaScript file called .nolluprc.js can be used instead.

module.exports = {
    hot: true,
    contentBase: './public'
};

See "Nollup Options" for list of available options.

Nollup Options

  • String config | -c | --config [file] - Pass a configuration file. By default it will look for rollup.config.js but can be specified otherwise.
  • String contentBase | --content-base [folder] - Folder to serve static content from. By default it will be looking in './.
  • Boolean historyApiFallback | --history-api-fallback - If set, it will fallback to index.html if accessing a route that doesn't exist.
  • Boolean hot | --hot - Enable Hot Module Replacement.
  • Number port | --port [value] - Port number to run server on. Default is 8080.
  • Boolean verbose | --verbose - If set, there's verbose logging.
  • Object proxy - Object keys are paths to match. Value is domain to redirect to. "/api": "http://localhost:8080" will have a request such as /api/todos redirect to http://localhost:8080/api/todos
  • String hmrHost | --hmr-host [host] - Host to connect to for HMR. Default is window.location.host.
  • Function before - Receives Express app as argument. Allows for middleware before internally used middleware.
  • Function after - Receives Express app as argument. Allows for middleware after internally used middleware.

API

See API for information on how to use the JavaScript API.

Rollup Plugins with Nollup Enhancements

Caveats

  • Not all Rollup configuration options are supported yet.
  • Not all Rollup plugin hooks are implemented yet.
  • Sourcemaps aren't perfect yet, depends on plugin usage.
  • Does not attempt to parse "require" calls anywhere.
  • No support for live-bindings, but circular dependencies are supported.

Contributions are welcome.

nollup's People

Contributors

codewitchbella avatar mike-dax avatar pepsryuu avatar rixo avatar vzaidman avatar

Stargazers

 avatar

Watchers

 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.