Created
October 12, 2022 08:24
-
-
Save zleight1/76dfb7b894ea2458d5f297c02380825f to your computer and use it in GitHub Desktop.
single-spa root config trying for on-demand bundle loading
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { | |
constructRoutes, | |
constructApplications, | |
constructLayoutEngine, | |
} from "single-spa-layout"; | |
import { registerApplication, start } from "single-spa"; | |
const routes = constructRoutes(document.querySelector("#single-spa-layout"), { | |
loaders: { | |
topNav: "<h1>Loading topnav</h1>", | |
}, | |
errors: { | |
topNav: "<h1>Failed to load topnav</h1>", | |
}, | |
}); | |
const applications = constructApplications({ | |
routes, | |
loadApp: ({ name }) => System.import(name), | |
}); | |
// Delay starting the layout engine until the styleguide CSS is loaded | |
const layoutEngine = constructLayoutEngine({ | |
routes, | |
applications, | |
active: false, | |
}); | |
applications.forEach(registerApplication); | |
System.import("@react-mf/styleguide").then(() => { | |
// start single-spa before the engine? | |
start(); | |
// Activate the layout engine once the styleguide CSS is loaded | |
layoutEngine.activate(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment