up bootstrap

This commit is contained in:
Andrey Vlasov
2020-02-29 16:47:16 +03:00
parent 3e2695801d
commit 88a38bc75e
19 changed files with 300 additions and 1614 deletions
+46
View File
@@ -0,0 +1,46 @@
import "systemjs/dist/s";
import "systemjs/dist/extras/amd";
import "systemjs/dist/extras/named-register";
import "systemjs/dist/extras/named-exports";
import "systemjs/dist/extras/transform";
import { createBrowserHistory } from 'history'
declare var System: {
import(string): Promise<any>
}
const systemJSImport = async (requestUrl: string) => {
const { default: component, mount, unmount } = await System.import(
requestUrl
)
return { component, mount, unmount }
}
const getApp = (apps, path) => {
const searchKey = path.substr(1)
return `./${searchKey}/${apps[searchKey].version}/index.js`
}
export default async ({ apps, navigations, config }) => {
const history = createBrowserHistory()
let prevPathname = window.location.pathname
/* tslint:disable-next-line */
__webpack_public_path__ = `/static${__webpack_public_path__}`
const app = getApp(apps, history.location.pathname)
const { component, mount, unmount } = await systemJSImport(app);
mount(component.default);
history.listen((location) => {
if (location.pathname !== prevPathname) {
prevPathname = location.pathname
unmount()
}
})
};