@kirei/hmr-api

@kirei/hmr-api ==========================

Usage no npm install needed!

<script type="module">
  import kireiHmrApi from 'https://cdn.skypack.dev/@kirei/hmr-api';
</script>

README

@kirei/hmr-api

GitHub Workflow Status Codecov Codacy grade Codacy coverage npm (scoped) npm bundle size (scoped) npm bundle size (scoped)

Hot Module Replacement API for Kirei Component. This only includes the API and does not offer any automatic instrumentation. Consider using the babel plugin instead (babel-plugin-kirei).

Installation

npm i @kirei/hmr-api

or if you use yarn

yarn add @kirei/hmr-api

API

import * as hmr from '@kirei/hmr-api';

hmr.create( filename, opts )

Solely creates a new component, if component already exists, it will return its constructor.

Returns: Component constructor

Parameters:

  • filename {string} - Filename where component was defined
  • opts {ComponentOptions} - Options to define component with

hmr.update( filename, opts )

Updates element options and all of its instances.

Returns: Component constructor

Parameters:

  • filename {string} - Filename where component was defined
  • opts {ComponentOptions} - Options to update component with

hmr.createOrUpdate( filename, opts )

Stores a component to cache or updates it and all of its active instances

Returns: Component constructor

Parameters:

  • filename {string} - Filename where component was defined
  • opts {ComponentOptions} - Options to update

hmr.has( filename, opts )

Checks if HMR already has component with the same id stored.

Returns: True if instance is already in the cache.

Parameters:

  • filename {string} - Filename where component was defined
  • opts {ComponentOptions} - Component options

License

MIT