@moderno/web-modules

1.0.3 • Public • Published

logo

The purpose of this library is to create ESM micro bundles to be served during development. Similar to esinstall from which I took a LOT of inspiration the goal is to make let the browser consume node_modules today.

Installation

npm install @moderno/web-modules

Javascript/Typescript API

import {useWebModules} from "exnext-web-modules";

let {bundleWebModule} = useWebModules(options);

await bundleWebModule("react");  // bundles react into /web_modules/react.js

await bundleWebModule("lit-html");  // bundles lit-html into /web_modules/lit-html.js
                                    // because of the esm entry proxy this micro-bundle 
                                    // will include all the files in lib

await bundleWebModule("lit-html/directives/repeat.js");  // bundles lit-html/directives/repeat into 
                                                         // /web_modules/lit-html/directives/repeat.js
                                                         // NOTE: directives are not part of 
                                                         // lit-hmtl micro-bundle

Comman Line Interface

It wouldbe a nice have to be able to create web_modules from the command line but I don't have the time to invest in this effort.

A big thank you to Rich Harris for the amazing Rollup.js, Guy Bedford for cjs-module-lexer and es-module-lexer without which this PoC couldn't be possible and Fred K. Schott because Snowpack has been a great source of inspiration.

Readme

Keywords

none

Package Sidebar

Install

npm i @moderno/web-modules

Weekly Downloads

1

Version

1.0.3

License

MIT

Unpacked Size

79.8 kB

Total Files

36

Last publish

Collaborators

  • glromeo