tonic-universal

1.0.0 • Public • Published

tonic-universal

Actions Status

Isomorphic exports of @socketsupply/tonic

npm install tonic-universal

Usage

Use @socketsupply/tonic or tonic-ssr from a single import identifier depending on then environment you are running.

// Shared codepaths between node and the browser.
import Tonic from 'tonic-universal'

class MyGreeting extends Tonic {
  render () {
    return this.html`<div>Hello, World.</div>`
  }
}

Tonic.add(MyGreeting, 'my-greeting')

How

tonic-universal 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) TODO: Release a dual pacakge @socketsupply/tonic to suppor this.
  • exports.import (esm node)
  • exports.reqire (cjs node)
  • exports.browser (esm browser)

License

MIT

Readme

Keywords

none

Package Sidebar

Install

npm i tonic-universal

Weekly Downloads

2

Version

1.0.0

License

MIT

Unpacked Size

13.9 kB

Total Files

23

Last publish

Collaborators

  • bret