mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-16 23:30:41 +09:00
Build the web interface and plugins with Vite
Replace webpack and Module Federation with Vite 8. The controller build emits one entry per shared module (lib, web_ui, typebox, antd, react, react-dom, react-router) and lists them in manifest.json. The controller turns that into an import map in index.html, and plugins are built as ES modules that import the shared modules by name and are loaded with import(). The shared Vite setup lives in @clusterio/web_ui/vite.mjs. Plugins use clusterioPlugin(), which exposes index, package.json and web/index under the same keys the webpack template used. The --dev and --dev-plugin flags now run the Vite dev server in middleware mode with hot module replacement. Browser polyfills move from web_ui to lib, which is the code that needs them, and lib sets the process and Buffer globals itself. Refs #1127 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
35125a28ab
commit
3227179613
57 files changed
+616
-620
No files matched your search
@@ -181,7 +181,10 @@ describe("controller/src/Controller", function() {
|
||||
before(async function() {
|
||||
const app = express();
|
||||
app.locals.controller = { config: { get: () => "Test Cluster" } };
|
||||
app.locals.mainBundle = "static/main.abc.js";
|
||||
app.locals.webBundle = {
|
||||
main: "static/main.abc.js",
|
||||
imports: { "react": "static/shared-react.abc.js" },
|
||||
};
|
||||
for (let route of ["/", "/instances/:id/view"]) {
|
||||
app.get(route, Controller.serveWeb(route));
|
||||
}
|
||||
@@ -199,12 +202,14 @@ describe("controller/src/Controller", function() {
|
||||
assert(html.includes("src=\"./static/main.abc.js\""));
|
||||
assert(html.includes("new URL(\"./\", document.location)"));
|
||||
assert(html.includes("new URL(\"./static/\", document.location)"));
|
||||
assert(html.includes('{"imports":{"react":"./static/shared-react.abc.js"}}'));
|
||||
});
|
||||
it("should use relative roots for nested routes", async function() {
|
||||
let html = await (await fetch(`http://localhost:${port}/instances/1/view`)).text();
|
||||
assert(html.includes("src=\"../../static/main.abc.js\""));
|
||||
assert(html.includes("new URL(\"../../\", document.location)"));
|
||||
assert(html.includes("new URL(\"../../static/\", document.location)"));
|
||||
assert(html.includes('{"imports":{"react":"../../static/shared-react.abc.js"}}'));
|
||||
html = await (await fetch(`http://localhost:${port}/instances/1/view/`)).text();
|
||||
assert(html.includes("src=\"../../../static/main.abc.js\""));
|
||||
assert(html.includes("new URL(\"../../../static/\", document.location)"));
|
||||
|
||||
Reference in new issue
Block a user