Version: 5.x

single-spa-dojo

Build Status

single-spa-dojo is a helper library that helps implement single-spa registered application lifecycle functions (bootstrap, mount and unmount) for use with Dojo. Check out the single-spa-dojo github.

  1. npm install --save single-spa-dojo
  2. # or
  3. yarn add single-spa-dojo

Your bundler’s “entry file” should look like this, which allows your application to be downloaded as an in-browser ES module.

  1. import { renderer } from '@dojo/framework/core/vdom';
  2. import { v, w } from '@dojo/framework/widget-core/d';
  3. import singleSpaDojo from 'single-spa-dojo';
  4. import App from './app';
  5. const dojoLifecycles = singleSpaDojo({
  6. // required
  7. renderer,
  8. // required
  9. v,
  10. // required
  11. w,
  12. // required
  13. appComponent: App,
  14. // optional - see https://dojo.io/learn/creating-widgets/rendering-widgets#mountoptions-properties
  15. mountOptions: {
  16. // optional
  17. registry: myRegistry,
  18. // optional - one will be provided by single-spa automatically
  19. domNode: document.getElementById('myContainer'),
  20. // optional
  21. sync: true
  22. }
  23. });
  24. export const bootstrap = dojoLifecycles.bootstrap;
  25. export const mount = dojoLifecycles.mount;
  26. export const unmount = dojoLifecycles.unmount;

All options are passed to single-spa-dojo via the opts parameter when calling singleSpaDojo(opts). The following options are available:

  • renderer (required): The renderer function imported from Dojo. See https://dojo.io/learn/creating-widgets/rendering-widgets#rendering-to-the-dom.
  • v (required): The function used to render dom elements in Dojo. Often JSX hides this function from you, but it can be found at import { v } from '@dojo/framework/widget-core/d'.
  • w (required): The function used to render dom elements in Dojo. Often JSX hides this function from you, but it can be found at import { w } from '@dojo/framework/widget-core/d'.
  • appComponent (required): The class or function for your root Dojo component.
  • mountOptions (optional): An object of Dojo MountOptions. Note that a domNode will be provided by single-spa-dojo, if one is not provided.

Dojo - 图2Edit this page