Helper for svelte components to ease development. Used under the hood by svelte-loader.
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:
<!--<Component>--> comment marker in the DOM just above where the component's DOM starts$0.__component__ in devtools after higlighting the comment marker from above.Registry.get(id).instances_rerender methodcomponent in the registry (using Registry.set(id, Registry.get(id).component = newComponent)) all future renders of the component will use the newly switched component._rerender on them.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__