passing-notes-ui

A middleware for delivering code to the browser during development

Usage no npm install needed!

<script type="module">
  import passingNotesUi from 'https://cdn.skypack.dev/passing-notes-ui';
</script>

README

passing-notes-ui

npm CI Status dependencies Status devDependencies Status

A middleware for delivering code to the browser during development

It leverages native support for ES modules to avoid the overhead in writing large bundles. npm packages are compiled to separate, standalone ESM files and cached by the browser. Application code is built and bundled incrementally.

It uses esbuild under the hood and has limited support for non-standard JavaScript features.

Usage

Install passing-notes-ui by running:

yarn add passing-notes-ui

Given a directory (say, ./ui) containing HTML, CSS, and JS files, we provide several ways to serve them over HTTP.

To quickly start a server that does nothing aside from serving those files:

yarn serve-ui ./ui

To add this functionality as a middleware to an existing app:

import {compose, Logger} from 'passing-notes'
import serveUi from 'passing-notes-ui'

const logger = new Logger()

export default compose(
  serveUi({path: './ui', logger}),
  () => () => ({status: 404})
)

serveUi will compile any JavaScript (.js) files requested by the browser, also compiling npm packages as needed. Other files are served as static files.

Currently, serveUi compiles as needed on each request. In the future, it may instead compile only when files change.