Skip to content

bcomnes/uhtml-isomorphic

Repository files navigation

uhtml-isomorphic

Actions Status

Isomorphic exports of uhtml

npm install uhtml-isomorphic

Usage

Use uhtml or uhtml-ssr from a single import identifier depending on then environment you are running.

import {render, html, svg} from 'uhtml-isomorphic';
// const {render, html, svg} = require('uhtml');

render(document.body, html`<h1>Hello 👋 µhtml</h1>`);

How

While @webreflection recomends require-overrides in the offical documentation, that requires special flags or transforms to work.

uhtml-isomorphic works by utilizing environment specific exports fields so that you can have dependency injection at the built-in module resolver layer. It supports the following export fields:

  • main (cjs node)
  • browser (cjs browser)
  • exports.import (esm node)
  • exports.reqire (cjs node)
  • exports.browser (esm browser)

License

MIT