Version: 5.x

single-spa-inspector

The single-spa-inspector is a Firefox/Chrome devtools extension to provide utilities for helping with single-spa applications. Github project.

Requires >= single-spa@4.1.

Note: you can also build and run this locally. See how to contribute.

  • List all registered applications (mounted at top)
  • Show all application statuses (statii)
  • Force mount and unmount an application
  • Show app overlays (see configuring app overlays to enable this feature)
  • Provides an interface for adding import-map overrides

App overlays allow you to hover over a mounted app’s name and have an “inspect element” type experience which shows where the app is in the DOM. This is especially useful for when multiple apps are mounted at the same time (e.g. in some places Canopy has upwards of 4 apps mounted on a single page/URL!).

To add app overlays, find the file where you export your lifecycle functions (e.g. bootstrap, mount, unmount) and add another exported object with the following shape:

  1. // must be called "devtools"
  2. export const devtools = {
  3. overlays: {
  4. // selectors is required for overlays to work
  5. selectors: [
  6. // an array of CSS selector strings, meant to be unique ways to identify the outermost container of your app
  7. // you can have more than one, for cases like parcels or different containers for differet views
  8. '#my-app',
  9. '.some-container .app',
  10. ],
  11. // options is optional
  12. options: {
  13. // these options allow you some control over how the overlay div looks/behaves
  14. // the listed values below are the defaults
  15. width: '100%',
  16. height: '100%',
  17. zIndex: 40,
  18. position: 'absolute',
  19. top: 0,
  20. left: 0,
  21. color: '#000', // the default for this is actually based on the app's name, so it's dynamic. can be a hex or a CSS color name
  22. background: '#000', // the default for this is actually based on the app's name, so it's dynamic. can be a hex or a CSS color name
  23. textBlocks: [
  24. // allows you to add additional text to the overlay. for example, you can add the name of the team/squad that owns this app
  25. // each string in this array will be in a new div
  26. // 'blue squad', 'is awesome'
  27. // turns into:
  28. // <div>blue squad</div><div>is awesome</div>
  29. ],
  30. },
  31. },
  32. };

If your environment uses import-maps, single-spa Inspector provides an interface for adding import-map overrides when utilizing the import-map-overrides library. Once the installation requirements for import-map-overrides are completed, you can add, remove, and refresh the page with your overrides.

Example of single-spa Inspector extension with import-maps overrides

Overview - 图2Edit this page