Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// // app2: The URL "/app2/..." is being redirected to "http://localhost:9002/..." this is done by the webpack proxy (webpack.config.js)
// loadingPromises.push(loadApp('app2', '/app2', '/app2/singleSpaEntry.js', '/app2/store.js', globalEventDistributor));
// // app3: The URL "/app3/..." is being redirected to "http://localhost:9003/..." this is done by the webpack proxy (webpack.config.js)
// loadingPromises.push(loadApp('app3', '/app3', '/app3/singleSpaEntry.js', null, null)); // does not have a store, so we pass null
// // app3: The URL "/app4/..." is being redirected to "http://localhost:9004/..." this is done by the webpack proxy (webpack.config.js)
// loadingPromises.push(loadApp('app4', '/app4', '/app4/singleSpaEntry.js', null, null)); // does not have a store, so we pass null
// // app5: The URL "/app5/..." is being redirected to "http://localhost:9005/..." this is done by the webpack proxy (webpack.config.js)
// loadingPromises.push(loadApp('app5', '/app5', '/app5/singleSpaEntry.js', '/app5/store.js', globalEventDistributor));
// wait until all stores are loaded and all apps are registered with singleSpa
await Promise.all(loadingPromises);
singleSpa.start();
}
// app1: The URL "/app1/..." is being redirected to "http://localhost:9001/..." this is done by the webpack proxy (webpack.config.js)
await loadApp('app1', '/app1', '/app1/singleSpaEntry.js', '/app1/store.js', globalEventDistributor);
// app2: The URL "/app2/..." is being redirected to "http://localhost:9002/..." this is done by the webpack proxy (webpack.config.js)
await loadApp('app2', '/app2', '/app2/singleSpaEntry.js', '/app2/store.js', globalEventDistributor);
// app3: The URL "/app3/..." is being redirected to "http://localhost:9003/..." this is done by the webpack proxy (webpack.config.js)
await loadApp('app3', '/app3', '/app3/singleSpaEntry.js', null, null); // does not have a store, so we pass null
// app3: The URL "/app4/..." is being redirected to "http://localhost:9004/..." this is done by the webpack proxy (webpack.config.js)
await loadApp('app4', '/app4', '/app4/singleSpaEntry.js', null, null); // does not have a store, so we pass null
// app5: The URL "/app5/..." is being redirected to "http://localhost:9005/..." this is done by the webpack proxy (webpack.config.js)
await loadApp('app5', '/app5', '/app5/singleSpaEntry.js', '/app5/store.js', globalEventDistributor);
singleSpa.start();
}
if (!auth.getAuthTokenAsBearer()) {
singleSpa.navigateToUrl('#' + routing.signInRoute)
}
}
})
window.addEventListener('single-spa:before-routing-event', () => {})
window.addEventListener('single-spa:routing-event', () => {
telemetry.mixpanel.register({
$current_url: routing.getPathInLocationHash(),
})
telemetry.mixpanel.track('PageChange')
})
singleSpa.start()
}
singleSpa.navigateToUrl('#' + registry.getDefaultRouter())
}
window.addEventListener('single-spa:app-change', () => {
if (!routing.isSignInPage()) {
if (!auth.getAuthTokenAsBearer()) {
singleSpa.navigateToUrl('#' + routing.signInRoute)
}
}
})
window.addEventListener('single-spa:first-mount', () => {
removeSpinner()
})
singleSpa.start()
}
async function bootstrap() {
let projectConfig = await SystemJS.import('/project.config.js' )
projectConfig.projects.forEach( element => {
registerApp({
name: element.name,
main: element.main,
url: element.prefix,
store:element.store,
base: element.base,
path: element.path
});
});
singleSpa.start();
}
prefetchAll(microApps, fetch);
break;
default:
break;
}
if (jsSandbox) {
useJsSandbox = jsSandbox;
}
if (singular) {
singularMode = singular;
}
startSpa();
frameworkStartedDefer.resolve();
}
function startApp() {
registerApplication(
'app1',
async () => await window.SystemJS.import('/app1/app1.js'),
(location) => location.pathname.startsWith('/ex1'),
{ sampleProp: 'just some random string' },
);
start();
}
startApp();