The router for easy microfrontends
StartOpts
type (https://github.com/single-spa/single-spa/pull/501 via @kuitos)// 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'
]
})
start(opts)
(https://github.com/single-spa/single-spa/pull/493 @krzyswiatkowski)urlRerouteOnly
configuration option, passed to start()
(https://github.com/single-spa/single-spa/pull/487). This is beneficial to performance (avoids unnecessary re-renders and single-spa code execution) and will not break things in most applications. It means that history.replaceState(newState, 'title')
will no longer cause a popstate event (and re-render).singleSpa.start({
urlRerouteOnly: true
})
single-spa@5 is focused on performance and developer experience. The bundle size for single-spa has gone down from ~25kb to ~15kb ungzipped (6kb to 5kb gzipped). We have created new error pages which give in-depth information about console errors, and link to those pages in both development and production builds. We now publish single-spa.dev.js files for easier debugging of single-spa itself. And we have removed all of our deprecated APIs (that have been deprecated and not documented for about two years).
99% of single-spa users can simply upgrade to [email protected] without any changes to their code and everything will work exactly as it was before. You'll just benefit from a smaller bundle size and better DX for errors. See the breaking changes below for the few breaking changes that exist.