Giter Club home page Giter Club logo

rollup-web's Introduction

Rollup in Browser!

Documents

Rate this package

Simply use rollup to bundle esm or commonjs or typescript code in browser!

Like Vite in Nodejs! We want to create a brand new bundle environment in browser!

We have made a Compiler System in browser, using plugins to compile Ts, Tsx, Vue SFC, Babel ... to vanilla JS run in browser!

We already create some website just bundling in browser!

Target

  1. Native Function

    • SystemJS module
    • Dynamic Import
    • Compiler Worker and Environment Worker
    • Plugin Loader (dynamic import plugin easier)
    • Iframe Sandbox
    • Unified Cache System ( indexedDB now, File System Access later)
    • Fetcher Adapter (anyway you like to load source code)
    • Config File Loader
  2. Plugin Provide

    1. Vanilla JS and TS Part
      • Babel-Core Support
      • Babel-plugins Support ( use esm.sh! )
      • SWC Support ( SWC is huge in package size! /(ㄒ o ㄒ)/~~ )
    2. Style Part
      • Postcss Support
      • CSS Support
      • Less Support
      • Sass Support
      • Tailwindcss Support (Partial)
    3. Framework Part
      • Vue SFC Support
      • Solidjs Support
      • React Support
      • Svelte Support
      • StoryBook Support
    4. Special File Part
      • HTML Support
      • json Support
      • MDX Support
      • WASM Support (Vite and ESM Integration)
      • Dedicated Worker Support
        • classic type worker
        • module type worker (recommend)
      • Shared Worker
    5. Polyfill
      • Node Builtins Polyfill

Get Start

Normal Bundle

import {
    Compiler,
    Evaluator,
} from "https://fastly.jsdelivr.net/npm/rollup-web@4";

// We use Rollup to compile Code!
const RollupConfig = {
    plugins: [
        // 1. Rollup Plugins used in Nodejs sometimes throw a error
        // 2. But we have browser version of them! Keep Reading!
    ],
};

const compiler = new Compiler(RollupConfig, {
    // Provide a web root to resolve relative path in your code
    root: "https://localhost:8080/",

    // 1. When we use Nodejs to resolve module, you can ignore the extension of file.
    // 2. But we actually need a extension to fetch remote file.
    // 3. So Compiler will join the origin path with extension in `extensions` each.
    // 4. And try to Download them!
    extensions: [".tsx", ".ts", ".js", ".json", ".css"],

    // If you want to see which file load,it could be helpful.
    log(url) {
        console.log("%c Download ==> " + url, "color:green");
    },
});

// This step will create an Environment to run source code!
const Eval = new Evaluator();
await Eval.createEnv({
    Compiler: compiler,
});

// evaluate the code just use url!
await Eval.evaluate("./public/mdx/index.jsx");

Bug Fixing

  • Vue reactive Image src cause error ( use assets plugin to import! )
  • Postcss System Import

License

Apache-2.0

rollup-web's People

Contributors

konghayao avatar

Stargazers

Roman avatar

Watchers

James Cloos 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.