All Projects → edoardocavazza → unchained

edoardocavazza / unchained

Licence: MIT license
🚀 ES6 modules in browsers without bundlers.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to unchained

Browserify
browser-side require() the node.js way
Stars: ✭ 13,929 (+23115%)
Mutual labels:  bundler
adonis-bundler
Blazing fast, zero configuration assets bundler for AdonisJS
Stars: ✭ 19 (-68.33%)
Mutual labels:  bundler
firefighter-demo
🚨 Demo to improve an existing firefighter app by making it queue tasks offline
Stars: ✭ 68 (+13.33%)
Mutual labels:  service-workers
Bundler
Bundler support for Capistrano 3.x
Stars: ✭ 216 (+260%)
Mutual labels:  bundler
wparcel
A webpack-based parcel-like web application bundler
Stars: ✭ 45 (-25%)
Mutual labels:  bundler
fjb
fast javascript bundler 📦
Stars: ✭ 103 (+71.67%)
Mutual labels:  bundler
Bundler
🎁 Android Intent & Bundle extensions that insert and retrieve values elegantly.
Stars: ✭ 195 (+225%)
Mutual labels:  bundler
muleify
Muleify - Static Site Generator | Website Bundler | Asset Compiler | Templating | Preproccessor
Stars: ✭ 16 (-73.33%)
Mutual labels:  bundler
awesome-esbuild
A curated list of awesome esbuild resources
Stars: ✭ 195 (+225%)
Mutual labels:  bundler
fliphub
the easiest app builder
Stars: ✭ 30 (-50%)
Mutual labels:  bundler
Pax
The fastest JavaScript bundler in the galaxy.
Stars: ✭ 2,626 (+4276.67%)
Mutual labels:  bundler
effectiveweb.training
Repository for Effective Web Online Course / airhacks.io
Stars: ✭ 17 (-71.67%)
Mutual labels:  service-workers
ws
scripts for building web projects
Stars: ✭ 13 (-78.33%)
Mutual labels:  bundler
Gem updater
Update gems in your Gemfile and fetch their changelogs
Stars: ✭ 206 (+243.33%)
Mutual labels:  bundler
minipack-kr
📦 자바스크립트 모듈 번들러를 만드는 간단한 예제입니다.
Stars: ✭ 105 (+75%)
Mutual labels:  bundler
Fastpack
Pack JS code fast & easy
Stars: ✭ 2,278 (+3696.67%)
Mutual labels:  bundler
requirex
A different kind of module loader 📦🦖
Stars: ✭ 20 (-66.67%)
Mutual labels:  bundler
unpack
Create Web apps without a bundler
Stars: ✭ 39 (-35%)
Mutual labels:  bundler
pansy
🛠️ A zero configuration library bundler.
Stars: ✭ 14 (-76.67%)
Mutual labels:  bundler
cdk-esbuild
CDK constructs for esbuild, an extremely fast JavaScript bundler
Stars: ✭ 44 (-26.67%)
Mutual labels:  bundler

Unchained

npm

Unchained takes advantage from browsers support for ES6 modules and Service Workers in order to load a full web application without using a bundler like Webpack or Rollup.

☢️ This project is just a research about web technologies.

DO NOT use it in production.

Why

  • Since Safari, Firefox and Chrome started to support ES6 modules syntax, I started to look for a good practise to load my applications.

  • Bundlers are great, and I will continue to use them for working/production environments, but I felt nostalgic about the times where I used to build application without installing ~1000 node modules just to start.

Read more on Medium: https://medium.com/@edoardo.cavazza/a-study-about-how-to-improve-frontend-dev-experience-without-a-bundler-1b4c3a461a35

How it works

Native ES6 modules syntax accepts relative paths only (so, support for dependencies installed by NPM/Yarn is missing). Also, it doesn't work with other source formats rather than javascript (JSON, texts, styles...) or syntaxes (like JSX).

Today, those issues are resolved on dev environment side by bundlers (Webpack, Rollup, Browserify) and transpilers (Babel, Traceur).

The idea is to intercept import calls and transform the source in a ServiceWorker context, using the magninificent Babel standalone distribution to manipulate sources and resolve NPM dependencies.

Unchained concept

Usage

Install from NPM:

$ npm install unchained-js
# OR
$ yarn add unchained-js

Use the Unchained client helper to register a ServiceWorker and to import the main application file.

index.html

<script src="node_modules/unchained-js/dist/unchained.client.js"></script>
<script>
UnchainedClient
    .register('./sw.js', { scope: '/' })
    .then(() => UnchainedClient.import('index.js'))
    .then(() => console.log('🚀'));
</script>

sw.js

// import Unchained core and plugins
self.importScripts('node_modules/unchained-js/dist/unchained.sw.js');

index.js

import { Component, h, render } from 'preact';

class App extends Component {
    render() {
        return <h1>Hello world!</h1>;
    }
}

render(document.body, <App />);

Configuration

The Unchained object can be configured with a set of plugins, through the Unchained.resolve method.

Plugins

An array of Plugin constructors or Plugin instances or Plugin names.

{
    plugins: [
        // constrcutor
        Unchained.TextPlugin,
        // instance
        new Unchained.ResolvePlugin(),
        // name
        'env',
        // constructor|instance|name with options
        ['jsx', { pragram: 'h' }]
    ]
}

The Plugin name may be registered via the Unchained.registerPlugin(name, constructor) method.

A list of available plugins can be found here.

Via querystring

You may also configure Unchained via querystring in the service worker registration url:

navigator.serviceWorker.register(`sw.js?unchained={"plugins":["env", "text"]}`);

The equivalent can be written using the third parameter of the Unchained.register helper method:

Unchained.register('sw.js', { scope: '/' }, {
    plugins: ['env', 'text'],
});

Browsers support ☢️

Support for Service Workers, ES6 syntax and ES6 modules is required.

Manually tested on Chrome v63.0.3239.84.

Resources

ES6 modules

Service Workers

Babel Standalone

Development

See the wiki.

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].