Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

svelte-dev-helper

ekhaled107.2kMIT1.1.9

Helper for svelte components to ease development

svelte, dev, helper

readme

svelte-dev-helper

Build Status

Helper for svelte components to ease development. Used under the hood by svelte-loader.

Usage

This is meant to be used under the hood for creating a build toolchain, or a dev helper based on Svelte components.

import {Registry, configure, createProxy} from 'svelte-dev-helper';
import Component from './Component.html'; //some svelte component

configure(configOptions);

const id = someUniqueID();

Registry.set(id, {
  rollback: null,
  component: Component,
  instances:[]
});

export createProxy(id);

The component returned by createProxy now has the following features:

  1. Adds a <!--<Component>--> comment marker in the DOM just above where the component's DOM starts
  2. You can access the component instance using $0.__component__ in devtools after higlighting the comment marker from above.
  3. You can access all rendered instances of a particular component using Registry.get(id).instances
  4. All instances have a _rerender method
  5. If you switch the component in the registry (using Registry.set(id, Registry.get(id).component = newComponent)) all future renders of the component will use the newly switched component.
  6. Following a switch as per above, you can switch all rendered components by first accessing the instances and then calling _rerender on them.
  7. The rollback property in any Registry item can be used to hold the last good version of a component. If there is an error instantiating a switched component, it will try to use the component version stored in rollback

    The Registry is also available at window.__SVELTE_REGISTRY__

changelog

Changelog

v1.1.9

  • fix forwarded events from child components not being re-bound on reload #10

v1.1.7

  • fix handling of computed props that depend on other computed props #8

v1.1.6

  • fix computed props are not re-computed on reload #6

v1.1.5

v1.1.4

  • fix forwarding of custom properties from proxied component

v1.1.3

  • fix bug with component destruction
  • add support for preload static method used by sapper

v1.1.2

  • fix forwarding of custom methods from proxied component

v1.1.1

  • bugfixes

v1.1.0

  • add automated tests and liniting

v1.0.0 (initial release)