npm single-spa 5.3.0
v5.3.0

latest releases: 7.0.0-beta.1, 7.0.0-beta.0, 6.0.3...
4 years ago

Features

  • single-spa can now run in NodeJS (#494).
  • The registerApplication API now accepts an object, as an alternative to multiple arguments (#482 from @Sauloxd)
  • The registerApplication API now accepts strings as activity functions, when using object registration. Strings are presumed to be route prefixes, and may contain dynamic params (#497 from @Sauloxd)
  • The registerApplication API now accepts an array of activity functions, when using object registration. When multiple activity functions are provided, the application will be active when any of the activity functions returns a truthy value
// Parts of single-spa now work in NodeJS
const { registerApplication, checkActivityFunctions } = require('single-spa');

registerApplication('app1', () => System.import('thing'), location => location.pathname.startsWith('/app1'));
console.log(checkActivityFunctions({pathname: '/app1'})) // ['app1']
console.log(checkActivityFunctions({pathname: '/other'})) // []
// registerApplication can now be called with an object
registerApplication({
  name: 'app1',
  app: () => System.import('app1'),
  activeWhen: location => location.pathname.startsWith('/app1')
})

// A string passed to activeWhen is a prefix
registerApplication({
  name: 'app2',
  app: () => System.import('app2'),
  activeWhen: '/app1'
})

// You can specify route params in the strings
registerApplication({
  name: 'app3',
  app: () => System.import('app3'),
  activeWhen: '/users/:userId/'
})

// Multiple activity functions are now supported
registerApplication({
  name: 'app4',
  app: () => System.import('app4'),
  activeWhen: [
    '/app4',
    location => location.pathname.startsWith('/other'),
    '/users/:userId'
  ]
})

Maintenance

Don't miss a new single-spa release

NewReleases is sending notifications on new releases.