Export web_ui as a single module

Due to the way the imports and exports works with module fedderation
each require path needs it's own shared module in the plugin.  To avoid
having to specify every possible import in the module federation plugin
config, export all useful components to plugins in the browser
entrypoint for web_ui.

Note that for some reason the module wouldn't exist for import by
plugins unless some part of the build imported it.  Which is the reason
for the master index.jsx to import bootstrap via it.
This commit is contained in:
Hornwitser committed 2021-03-13 21:01:53 +01:00
1 parent a904a8fb9d
commit 579f6421e4
5 files changed
+25 -5

No files matched your search

+3 -1
View File
@@ -1 +1,3 @@
import("@clusterio/web_ui/src/bootstrap");
import("@clusterio/web_ui").then(webUi => {
return webUi.bootstrap();
}).catch(console.error);
-1
View File
@@ -29,7 +29,6 @@ module.exports = (env = {}) => merge(common(env), {
"@clusterio/lib/schema": { singleton: true },
"@clusterio/lib/users": { singleton: true },
"@clusterio/web_ui": { singleton: true },
"ajv": {},
"antd": { singleton: true },
"react": { singleton: true },
"react-dom": { singleton: true },
+1
View File
@@ -4,6 +4,7 @@
"author": "Hornwitser",
"license": "MIT",
"version": "2.0.0-alpha.4",
"browser": "src/index.jsx",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
+1 -3
View File
@@ -74,7 +74,7 @@ async function loadPlugins() {
return plugins;
}
async function load() {
export default async function bootstrap() {
logger.add(new ConsoleTransport({
level: "verbose",
format: new WebConsoleFormat(),
@@ -92,5 +92,3 @@ async function load() {
ReactDOM.render(<App control={control} plugins={plugins}/>, document.getElementById("root"));
}
load().catch((err) => logger.fatal(err.stack));
+20
View File
@@ -0,0 +1,20 @@
export { default as basename } from "./basename.jsx";
export { default as bootstrap } from "./bootstrap.jsx";
export { default as notify, notifyErrorHandler } from "./util/notify.jsx";
export * from "./model/instance.jsx";
export * from "./model/slave.jsx";
export { default as ControlContext } from "./components/ControlContext";
export { default as PluginsContext } from "./components/PluginsContext";
export { default as BaseConfigTree } from "./components/BaseConfigTree";
export { default as InstanceConfigTree } from "./components/InstanceConfigTree";
export { default as MasterConfigTree } from "./components/MasterConfigTree";
export { default as AssignInstanceModal } from "./components/AssignInstanceModal";
export { default as InstanceConsole } from "./components/InstanceConsole";
export { default as InstanceRcon } from "./components/InstanceRcon";
export { default as PageLayout } from "./components/PageLayout";