every-plugin 0.4.17 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-zltIcp7o.cjs → _virtual/rolldown_runtime.cjs} +3 -18
- package/dist/{chunk-QQAxy9l9.mjs → _virtual/rolldown_runtime.mjs} +1 -1
- package/dist/build/rspack/dev-server-middleware.cjs +201 -0
- package/dist/build/rspack/dev-server-middleware.cjs.map +1 -0
- package/dist/build/rspack/dev-server-middleware.mjs +200 -0
- package/dist/build/rspack/dev-server-middleware.mjs.map +1 -0
- package/dist/build/rspack/index.cjs +2 -362
- package/dist/build/rspack/index.d.cts +2 -20
- package/dist/build/rspack/index.d.mts +2 -20
- package/dist/build/rspack/index.mjs +2 -360
- package/dist/build/rspack/module-federation.cjs +47 -0
- package/dist/build/rspack/module-federation.cjs.map +1 -0
- package/dist/build/rspack/module-federation.mjs +47 -0
- package/dist/build/rspack/module-federation.mjs.map +1 -0
- package/dist/build/rspack/plugin.cjs +90 -0
- package/dist/build/rspack/plugin.cjs.map +1 -0
- package/dist/build/rspack/plugin.d.cts +20 -0
- package/dist/build/rspack/plugin.d.cts.map +1 -0
- package/dist/build/rspack/plugin.d.mts +20 -0
- package/dist/build/rspack/plugin.d.mts.map +1 -0
- package/dist/build/rspack/plugin.mjs +89 -0
- package/dist/build/rspack/plugin.mjs.map +1 -0
- package/dist/build/rspack/utils.cjs +41 -0
- package/dist/build/rspack/utils.cjs.map +1 -0
- package/dist/build/rspack/utils.mjs +38 -0
- package/dist/build/rspack/utils.mjs.map +1 -0
- package/dist/errors.cjs +62 -3
- package/dist/errors.cjs.map +1 -0
- package/dist/errors.d.cts +75 -3
- package/dist/errors.d.cts.map +1 -0
- package/dist/errors.d.mts +75 -3
- package/dist/errors.d.mts.map +1 -0
- package/dist/errors.mjs +62 -3
- package/dist/errors.mjs.map +1 -0
- package/dist/index.cjs +8 -55
- package/dist/index.d.cts +6 -5
- package/dist/index.d.mts +6 -5
- package/dist/index.mjs +5 -51
- package/dist/orpc.cjs +1 -1
- package/dist/{package-D4mbTFY1.cjs → package.cjs} +22 -7
- package/dist/package.cjs.map +1 -0
- package/dist/{package-B0vvsKXO.mjs → package.mjs} +22 -5
- package/dist/package.mjs.map +1 -0
- package/dist/plugin.cjs +48 -0
- package/dist/plugin.cjs.map +1 -0
- package/dist/plugin.d.cts +62 -0
- package/dist/plugin.d.cts.map +1 -0
- package/dist/plugin.d.mts +62 -0
- package/dist/plugin.d.mts.map +1 -0
- package/dist/plugin.mjs +47 -0
- package/dist/plugin.mjs.map +1 -0
- package/dist/runtime/errors.cjs +45 -0
- package/dist/runtime/errors.cjs.map +1 -0
- package/dist/runtime/errors.d.cts +27 -0
- package/dist/runtime/errors.d.cts.map +1 -0
- package/dist/runtime/errors.d.mts +27 -0
- package/dist/runtime/errors.d.mts.map +1 -0
- package/dist/runtime/errors.mjs +41 -0
- package/dist/runtime/errors.mjs.map +1 -0
- package/dist/runtime/index.cjs +157 -5
- package/dist/runtime/index.cjs.map +1 -0
- package/dist/runtime/index.d.cts +43 -5
- package/dist/runtime/index.d.cts.map +1 -0
- package/dist/runtime/index.d.mts +43 -5
- package/dist/runtime/index.d.mts.map +1 -0
- package/dist/runtime/index.mjs +155 -4
- package/dist/runtime/index.mjs.map +1 -0
- package/dist/runtime/services/module-federation.service.cjs +143 -0
- package/dist/runtime/services/module-federation.service.cjs.map +1 -0
- package/dist/runtime/services/module-federation.service.d.cts +15 -0
- package/dist/runtime/services/module-federation.service.d.cts.map +1 -0
- package/dist/runtime/services/module-federation.service.d.mts +15 -0
- package/dist/runtime/services/module-federation.service.d.mts.map +1 -0
- package/dist/runtime/services/module-federation.service.mjs +143 -0
- package/dist/runtime/services/module-federation.service.mjs.map +1 -0
- package/dist/runtime/services/normalize.cjs +22 -2
- package/dist/runtime/services/normalize.cjs.map +1 -0
- package/dist/runtime/services/normalize.d.cts +21 -2
- package/dist/runtime/services/normalize.d.cts.map +1 -0
- package/dist/runtime/services/normalize.d.mts +21 -2
- package/dist/runtime/services/normalize.d.mts.map +1 -0
- package/dist/runtime/services/normalize.mjs +21 -2
- package/dist/runtime/services/normalize.mjs.map +1 -0
- package/dist/runtime/services/plugin-lifecycle.service.cjs +33 -0
- package/dist/runtime/services/plugin-lifecycle.service.cjs.map +1 -0
- package/dist/runtime/services/plugin-lifecycle.service.d.cts +17 -0
- package/dist/runtime/services/plugin-lifecycle.service.d.cts.map +1 -0
- package/dist/runtime/services/plugin-lifecycle.service.d.mts +17 -0
- package/dist/runtime/services/plugin-lifecycle.service.d.mts.map +1 -0
- package/dist/runtime/services/plugin-lifecycle.service.mjs +32 -0
- package/dist/runtime/services/plugin-lifecycle.service.mjs.map +1 -0
- package/dist/runtime/services/plugin-loader.service.cjs +125 -0
- package/dist/runtime/services/plugin-loader.service.cjs.map +1 -0
- package/dist/runtime/services/plugin-loader.service.d.cts +54 -0
- package/dist/runtime/services/plugin-loader.service.d.cts.map +1 -0
- package/dist/runtime/services/plugin-loader.service.d.mts +54 -0
- package/dist/runtime/services/plugin-loader.service.d.mts.map +1 -0
- package/dist/runtime/services/plugin-loader.service.mjs +121 -0
- package/dist/runtime/services/plugin-loader.service.mjs.map +1 -0
- package/dist/runtime/services/plugin.service.cjs +33 -0
- package/dist/runtime/services/plugin.service.cjs.map +1 -0
- package/dist/runtime/services/plugin.service.d.cts +42 -0
- package/dist/runtime/services/plugin.service.d.cts.map +1 -0
- package/dist/runtime/services/plugin.service.d.mts +42 -0
- package/dist/runtime/services/plugin.service.d.mts.map +1 -0
- package/dist/runtime/services/plugin.service.mjs +32 -0
- package/dist/runtime/services/plugin.service.mjs.map +1 -0
- package/dist/runtime/services/secrets.service.cjs +50 -0
- package/dist/runtime/services/secrets.service.cjs.map +1 -0
- package/dist/runtime/services/secrets.service.d.cts +16 -0
- package/dist/runtime/services/secrets.service.d.cts.map +1 -0
- package/dist/runtime/services/secrets.service.d.mts +16 -0
- package/dist/runtime/services/secrets.service.d.mts.map +1 -0
- package/dist/runtime/services/secrets.service.mjs +48 -0
- package/dist/runtime/services/secrets.service.mjs.map +1 -0
- package/dist/runtime/validation.cjs +18 -0
- package/dist/runtime/validation.cjs.map +1 -0
- package/dist/runtime/validation.mjs +17 -0
- package/dist/runtime/validation.mjs.map +1 -0
- package/dist/testing/index.cjs +33 -55
- package/dist/testing/index.cjs.map +1 -1
- package/dist/testing/index.d.cts +28 -33
- package/dist/testing/index.d.cts.map +1 -1
- package/dist/testing/index.d.mts +28 -33
- package/dist/testing/index.d.mts.map +1 -1
- package/dist/testing/index.mjs +34 -54
- package/dist/testing/index.mjs.map +1 -1
- package/dist/types.cjs +0 -0
- package/dist/types.d.cts +261 -0
- package/dist/types.d.cts.map +1 -0
- package/dist/types.d.mts +261 -0
- package/dist/types.d.mts.map +1 -0
- package/dist/types.mjs +1 -0
- package/dist/zod-core.cjs +9 -0
- package/dist/zod-core.d.cts +1 -0
- package/dist/zod-core.d.mts +1 -0
- package/dist/zod-core.mjs +3 -0
- package/dist/zod.cjs +13 -1
- package/dist/zod.cjs.map +1 -0
- package/dist/zod.d.cts +8 -2
- package/dist/zod.d.cts.map +1 -0
- package/dist/zod.d.mts +8 -2
- package/dist/zod.d.mts.map +1 -0
- package/dist/zod.mjs +9 -2
- package/dist/zod.mjs.map +1 -0
- package/package.json +17 -2
- package/dist/build/rspack/index.cjs.map +0 -1
- package/dist/build/rspack/index.d.cts.map +0 -1
- package/dist/build/rspack/index.d.mts.map +0 -1
- package/dist/build/rspack/index.mjs.map +0 -1
- package/dist/errors-9sNpYLv5.d.mts +0 -75
- package/dist/errors-9sNpYLv5.d.mts.map +0 -1
- package/dist/errors-CVnoPl9v.cjs +0 -68
- package/dist/errors-CVnoPl9v.cjs.map +0 -1
- package/dist/errors-D7keKf7a.mjs +0 -63
- package/dist/errors-D7keKf7a.mjs.map +0 -1
- package/dist/errors-DKPPPYYT.d.cts +0 -75
- package/dist/errors-DKPPPYYT.d.cts.map +0 -1
- package/dist/fetch-8DauUFDh.mjs +0 -335
- package/dist/fetch-8DauUFDh.mjs.map +0 -1
- package/dist/fetch-CrBvwsZ4.cjs +0 -336
- package/dist/fetch-CrBvwsZ4.cjs.map +0 -1
- package/dist/index-Coz54d1B.d.mts +0 -387
- package/dist/index-Coz54d1B.d.mts.map +0 -1
- package/dist/index-G63gBZIY.d.cts +0 -386
- package/dist/index-G63gBZIY.d.cts.map +0 -1
- package/dist/index.cjs.map +0 -1
- package/dist/index.mjs.map +0 -1
- package/dist/normalize-BW7kk8Lk.d.cts +0 -21
- package/dist/normalize-BW7kk8Lk.d.cts.map +0 -1
- package/dist/normalize-D4Qh0wVk.cjs +0 -28
- package/dist/normalize-D4Qh0wVk.cjs.map +0 -1
- package/dist/normalize-D7nae0Hn.mjs +0 -22
- package/dist/normalize-D7nae0Hn.mjs.map +0 -1
- package/dist/normalize-eB_j86fm.d.mts +0 -21
- package/dist/normalize-eB_j86fm.d.mts.map +0 -1
- package/dist/package-B0vvsKXO.mjs.map +0 -1
- package/dist/package-D4mbTFY1.cjs.map +0 -1
- package/dist/plugins-C6MGKdD-.mjs +0 -790
- package/dist/plugins-C6MGKdD-.mjs.map +0 -1
- package/dist/plugins-DNaNtkG7.cjs +0 -791
- package/dist/plugins-DNaNtkG7.cjs.map +0 -1
- package/dist/runtime-BTFJzoBu.cjs +0 -541
- package/dist/runtime-BTFJzoBu.cjs.map +0 -1
- package/dist/runtime-BYDchBFq.mjs +0 -476
- package/dist/runtime-BYDchBFq.mjs.map +0 -1
- package/dist/standard-CkH8zNkx.mjs +0 -584
- package/dist/standard-CkH8zNkx.mjs.map +0 -1
- package/dist/standard-v75BC6Z5.cjs +0 -685
- package/dist/standard-v75BC6Z5.cjs.map +0 -1
- package/dist/zod-A7Pti5IV.d.cts +0 -4
- package/dist/zod-A7Pti5IV.d.cts.map +0 -1
- package/dist/zod-BVo51kgJ.mjs +0 -10
- package/dist/zod-BVo51kgJ.mjs.map +0 -1
- package/dist/zod-DYghWCz1.cjs +0 -14
- package/dist/zod-DYghWCz1.cjs.map +0 -1
- package/dist/zod-Zw8dlP3j.d.mts +0 -4
- package/dist/zod-Zw8dlP3j.d.mts.map +0 -1
|
@@ -1,361 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t as getNormalizedRemoteName } from "../../normalize-D7nae0Hn.mjs";
|
|
3
|
-
import { t as require_package } from "../../package-B0vvsKXO.mjs";
|
|
4
|
-
import { ModuleFederationPlugin } from "@module-federation/enhanced/rspack";
|
|
5
|
-
import path from "node:path";
|
|
6
|
-
import fs from "node:fs";
|
|
1
|
+
import { EveryPluginDevServer } from "./plugin.mjs";
|
|
7
2
|
|
|
8
|
-
|
|
9
|
-
const corsHeaders = {
|
|
10
|
-
"Access-Control-Allow-Origin": "*",
|
|
11
|
-
"Access-Control-Allow-Methods": "GET, POST, PUT, DELETE, PATCH, OPTIONS",
|
|
12
|
-
"Access-Control-Allow-Headers": "X-Requested-With, content-type, Authorization"
|
|
13
|
-
};
|
|
14
|
-
const applyCorsHeaders = (res) => {
|
|
15
|
-
Object.entries(corsHeaders).forEach(([key, value]) => {
|
|
16
|
-
res.setHeader(key, value);
|
|
17
|
-
});
|
|
18
|
-
};
|
|
19
|
-
const normalizePrefix = (prefix) => {
|
|
20
|
-
if (!prefix) return "";
|
|
21
|
-
const cleaned = prefix.replace(/^\/+|\/+$/g, "");
|
|
22
|
-
return cleaned ? `/${cleaned}` : "";
|
|
23
|
-
};
|
|
24
|
-
function setupPluginMiddleware(devServer, pluginInfo, devConfig, port) {
|
|
25
|
-
const rpcPrefix = normalizePrefix(devConfig?.prefix);
|
|
26
|
-
let handlers = {
|
|
27
|
-
rpc: null,
|
|
28
|
-
api: null
|
|
29
|
-
};
|
|
30
|
-
let cleanup = null;
|
|
31
|
-
const performCleanup = async () => {
|
|
32
|
-
if (cleanup) {
|
|
33
|
-
await cleanup();
|
|
34
|
-
cleanup = null;
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
(async () => {
|
|
38
|
-
await performCleanup();
|
|
39
|
-
try {
|
|
40
|
-
const { createPluginRuntime } = await import("../../index.mjs");
|
|
41
|
-
const { RPCHandler } = await import("@orpc/server/fetch");
|
|
42
|
-
const { onError } = await import("@orpc/server");
|
|
43
|
-
const { OpenAPIHandler } = await import("../../fetch-8DauUFDh.mjs");
|
|
44
|
-
const { OpenAPIReferencePlugin } = await import("../../plugins-C6MGKdD-.mjs");
|
|
45
|
-
const { ZodToJsonSchemaConverter } = await import("@orpc/zod/zod4");
|
|
46
|
-
const pluginId = devConfig?.pluginId || pluginInfo.normalizedName;
|
|
47
|
-
const runtime = createPluginRuntime({ registry: { [pluginId]: { remoteUrl: `http://localhost:${port}/remoteEntry.js` } } });
|
|
48
|
-
const loaded = await runtime.usePlugin(pluginId, devConfig?.config);
|
|
49
|
-
cleanup = async () => {
|
|
50
|
-
if (loaded && typeof loaded.dispose === "function") await loaded.dispose();
|
|
51
|
-
if (runtime && typeof runtime.cleanup === "function") await runtime.cleanup();
|
|
52
|
-
handlers.rpc = null;
|
|
53
|
-
handlers.api = null;
|
|
54
|
-
if (devServer.app.locals.handlers) devServer.app.locals.handlers = null;
|
|
55
|
-
};
|
|
56
|
-
const formatError = (error, context) => {
|
|
57
|
-
const lines = [`\n🔴 ${context} Error: ${error.message || "Unknown error"}`];
|
|
58
|
-
if (error.cause?.issues && Array.isArray(error.cause.issues)) {
|
|
59
|
-
lines.push("\n📋 Validation Issues:");
|
|
60
|
-
error.cause.issues.forEach((issue, index) => {
|
|
61
|
-
lines.push(` ${index + 1}. ${issue.path?.join(".") || "root"}`);
|
|
62
|
-
lines.push(` ├─ Code: ${issue.code || "unknown"}`);
|
|
63
|
-
lines.push(` ├─ Message: ${issue.message || "No message"}`);
|
|
64
|
-
if (issue.expected !== void 0) lines.push(` ├─ Expected: ${JSON.stringify(issue.expected)}`);
|
|
65
|
-
if (issue.received !== void 0) lines.push(` └─ Received: ${JSON.stringify(issue.received)}`);
|
|
66
|
-
else lines.push(` └─ (end)`);
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
if (error.data && typeof error.data === "object" && Object.keys(error.data).length > 0) {
|
|
70
|
-
lines.push("\n📊 Error Data:");
|
|
71
|
-
try {
|
|
72
|
-
JSON.stringify(error.data, null, 2).split("\n").forEach((line) => {
|
|
73
|
-
lines.push(` ${line}`);
|
|
74
|
-
});
|
|
75
|
-
} catch {
|
|
76
|
-
lines.push(` ${String(error.data)}`);
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
if (error.cause?.data) {
|
|
80
|
-
lines.push("\n📦 Request Data:");
|
|
81
|
-
try {
|
|
82
|
-
JSON.stringify(error.cause.data, null, 2).split("\n").forEach((line) => {
|
|
83
|
-
lines.push(` ${line}`);
|
|
84
|
-
});
|
|
85
|
-
} catch {
|
|
86
|
-
lines.push(` ${String(error.cause.data)}`);
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
if (error.code) lines.push(`\n⚠️ Error Code: ${error.code}`);
|
|
90
|
-
if (error.status) lines.push(`📍 Status: ${error.status}`);
|
|
91
|
-
lines.push("");
|
|
92
|
-
console.error(lines.join("\n"));
|
|
93
|
-
};
|
|
94
|
-
handlers.rpc = new RPCHandler(loaded.router, { interceptors: [onError((error) => {
|
|
95
|
-
formatError(error, "RPC");
|
|
96
|
-
})] });
|
|
97
|
-
handlers.api = new OpenAPIHandler(loaded.router, {
|
|
98
|
-
plugins: [new OpenAPIReferencePlugin({ schemaConverters: [new ZodToJsonSchemaConverter()] })],
|
|
99
|
-
interceptors: [onError((error) => {
|
|
100
|
-
formatError(error, "OpenAPI");
|
|
101
|
-
})]
|
|
102
|
-
});
|
|
103
|
-
console.log(`╭─────────────────────────────────────────────`);
|
|
104
|
-
console.log(`│ ✅ Plugin dev server ready: `);
|
|
105
|
-
console.log(`├─────────────────────────────────────────────`);
|
|
106
|
-
console.log(`│ 📡 RPC: http://localhost:${port}/api/rpc${rpcPrefix}`);
|
|
107
|
-
console.log(`│ 📖 Docs: http://localhost:${port}/api`);
|
|
108
|
-
console.log(`│ 💚 Health: http://localhost:${port}/`);
|
|
109
|
-
console.log(`╰─────────────────────────────────────────────`);
|
|
110
|
-
devServer.app.locals.handlers = handlers;
|
|
111
|
-
if (devServer.server) devServer.server.once("close", async () => {
|
|
112
|
-
await performCleanup();
|
|
113
|
-
});
|
|
114
|
-
} catch (error) {
|
|
115
|
-
console.error("❌ Failed to load plugin:", error);
|
|
116
|
-
await performCleanup();
|
|
117
|
-
}
|
|
118
|
-
})();
|
|
119
|
-
process.once("SIGINT", async () => {
|
|
120
|
-
await performCleanup();
|
|
121
|
-
});
|
|
122
|
-
process.once("SIGTERM", async () => {
|
|
123
|
-
await performCleanup();
|
|
124
|
-
});
|
|
125
|
-
devServer.app.options("*", (req, res) => {
|
|
126
|
-
applyCorsHeaders(res);
|
|
127
|
-
res.status(200).end();
|
|
128
|
-
});
|
|
129
|
-
devServer.app.get("/", (req, res) => {
|
|
130
|
-
applyCorsHeaders(res);
|
|
131
|
-
res.json({
|
|
132
|
-
ok: true,
|
|
133
|
-
plugin: pluginInfo.normalizedName,
|
|
134
|
-
version: pluginInfo.version,
|
|
135
|
-
status: devServer.app.locals.handlers?.rpc ? "ready" : "loading",
|
|
136
|
-
endpoints: {
|
|
137
|
-
health: "/",
|
|
138
|
-
docs: "/api",
|
|
139
|
-
rpc: `/api/rpc${rpcPrefix}`
|
|
140
|
-
}
|
|
141
|
-
});
|
|
142
|
-
});
|
|
143
|
-
const handleApiRequest = async (req, res) => {
|
|
144
|
-
applyCorsHeaders(res);
|
|
145
|
-
const apiHandler = devServer.app.locals.handlers?.api;
|
|
146
|
-
if (!apiHandler) return res.status(503).json({ error: "Plugin still loading..." });
|
|
147
|
-
try {
|
|
148
|
-
const url = `http://${req.headers.host}${req.url}`;
|
|
149
|
-
const webRequest = new Request(url, {
|
|
150
|
-
method: req.method,
|
|
151
|
-
headers: req.headers,
|
|
152
|
-
body: req.method !== "GET" && req.method !== "HEAD" ? req : void 0,
|
|
153
|
-
duplex: req.method !== "GET" && req.method !== "HEAD" ? "half" : void 0
|
|
154
|
-
});
|
|
155
|
-
const result = await apiHandler.handle(webRequest, {
|
|
156
|
-
prefix: "/api",
|
|
157
|
-
context: {}
|
|
158
|
-
});
|
|
159
|
-
if (result.response) {
|
|
160
|
-
res.status(result.response.status);
|
|
161
|
-
result.response.headers.forEach((value, key) => {
|
|
162
|
-
res.setHeader(key, value);
|
|
163
|
-
});
|
|
164
|
-
const text = await result.response.text();
|
|
165
|
-
res.send(text);
|
|
166
|
-
} else res.status(404).send("Not Found");
|
|
167
|
-
} catch (error) {
|
|
168
|
-
console.error("OpenAPI error:", error);
|
|
169
|
-
res.status(500).json({ error: error.message });
|
|
170
|
-
}
|
|
171
|
-
};
|
|
172
|
-
devServer.app.all("/api", handleApiRequest);
|
|
173
|
-
devServer.app.all("/api/*", handleApiRequest);
|
|
174
|
-
devServer.app.all(`/api/rpc${rpcPrefix}/*`, async (req, res) => {
|
|
175
|
-
applyCorsHeaders(res);
|
|
176
|
-
const rpcHandler = devServer.app.locals.handlers?.rpc;
|
|
177
|
-
if (!rpcHandler) return res.status(503).json({ error: "Plugin still loading..." });
|
|
178
|
-
try {
|
|
179
|
-
const url = `http://${req.headers.host}${req.url}`;
|
|
180
|
-
const webRequest = new Request(url, {
|
|
181
|
-
method: req.method,
|
|
182
|
-
headers: req.headers,
|
|
183
|
-
body: req.method !== "GET" && req.method !== "HEAD" ? req : void 0,
|
|
184
|
-
duplex: req.method !== "GET" && req.method !== "HEAD" ? "half" : void 0
|
|
185
|
-
});
|
|
186
|
-
const result = await rpcHandler.handle(webRequest, {
|
|
187
|
-
prefix: `/api/rpc${rpcPrefix}`,
|
|
188
|
-
context: {}
|
|
189
|
-
});
|
|
190
|
-
if (result.response) {
|
|
191
|
-
res.status(result.response.status);
|
|
192
|
-
result.response.headers.forEach((value, key) => {
|
|
193
|
-
res.setHeader(key, value);
|
|
194
|
-
});
|
|
195
|
-
const text = await result.response.text();
|
|
196
|
-
res.send(text);
|
|
197
|
-
} else res.status(404).send("Not Found");
|
|
198
|
-
} catch (error) {
|
|
199
|
-
console.error("RPC error:", error);
|
|
200
|
-
res.status(500).json({ error: error.message });
|
|
201
|
-
}
|
|
202
|
-
});
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
//#endregion
|
|
206
|
-
//#region src/build/rspack/module-federation.ts
|
|
207
|
-
function buildSharedDependencies(pluginInfo) {
|
|
208
|
-
const everyPluginPkg = require_package();
|
|
209
|
-
return {
|
|
210
|
-
"every-plugin": {
|
|
211
|
-
version: everyPluginPkg.version,
|
|
212
|
-
singleton: true,
|
|
213
|
-
requiredVersion: `${everyPluginPkg.version}`,
|
|
214
|
-
strictVersion: false,
|
|
215
|
-
eager: false
|
|
216
|
-
},
|
|
217
|
-
effect: {
|
|
218
|
-
version: everyPluginPkg.dependencies.effect,
|
|
219
|
-
singleton: true,
|
|
220
|
-
requiredVersion: `${everyPluginPkg.dependencies.effect}`,
|
|
221
|
-
strictVersion: false,
|
|
222
|
-
eager: false
|
|
223
|
-
},
|
|
224
|
-
zod: {
|
|
225
|
-
version: everyPluginPkg.dependencies.zod,
|
|
226
|
-
singleton: true,
|
|
227
|
-
requiredVersion: `${everyPluginPkg.dependencies.zod}`,
|
|
228
|
-
strictVersion: false,
|
|
229
|
-
eager: false
|
|
230
|
-
},
|
|
231
|
-
"@orpc/contract": {
|
|
232
|
-
version: everyPluginPkg.dependencies["@orpc/contract"],
|
|
233
|
-
singleton: true,
|
|
234
|
-
requiredVersion: `${everyPluginPkg.dependencies["@orpc/contract"]}`,
|
|
235
|
-
strictVersion: false,
|
|
236
|
-
eager: false
|
|
237
|
-
},
|
|
238
|
-
"@orpc/server": {
|
|
239
|
-
version: everyPluginPkg.dependencies["@orpc/server"],
|
|
240
|
-
singleton: true,
|
|
241
|
-
requiredVersion: `${everyPluginPkg.dependencies["@orpc/server"]}`,
|
|
242
|
-
strictVersion: false,
|
|
243
|
-
eager: false
|
|
244
|
-
}
|
|
245
|
-
};
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
//#endregion
|
|
249
|
-
//#region src/build/rspack/utils.ts
|
|
250
|
-
function getPluginInfo(context) {
|
|
251
|
-
const pkgPath = path.join(context, "package.json");
|
|
252
|
-
const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf-8"));
|
|
253
|
-
return {
|
|
254
|
-
name: pkg.name,
|
|
255
|
-
version: pkg.version,
|
|
256
|
-
normalizedName: getNormalizedRemoteName(pkg.name),
|
|
257
|
-
dependencies: pkg.dependencies || {},
|
|
258
|
-
peerDependencies: pkg.peerDependencies || {}
|
|
259
|
-
};
|
|
260
|
-
}
|
|
261
|
-
const loadedModules = /* @__PURE__ */ new Set();
|
|
262
|
-
function loadDevConfig(devConfigPath) {
|
|
263
|
-
try {
|
|
264
|
-
const fullPath = path.resolve(devConfigPath);
|
|
265
|
-
if (loadedModules.has(fullPath)) {
|
|
266
|
-
delete __require.cache[fullPath];
|
|
267
|
-
const dirPath = path.dirname(fullPath);
|
|
268
|
-
for (const key of Object.keys(__require.cache)) if (key.startsWith(dirPath) && key !== fullPath) delete __require.cache[key];
|
|
269
|
-
}
|
|
270
|
-
const module = __require(fullPath).default;
|
|
271
|
-
loadedModules.add(fullPath);
|
|
272
|
-
return module;
|
|
273
|
-
} catch (error) {
|
|
274
|
-
console.warn(`Could not load dev config from ${devConfigPath}:`, error.message);
|
|
275
|
-
return null;
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
//#endregion
|
|
280
|
-
//#region src/build/rspack/plugin.ts
|
|
281
|
-
var EveryPluginDevServer = class {
|
|
282
|
-
name = "EveryPluginDevServer";
|
|
283
|
-
constructor(options = {}) {
|
|
284
|
-
this.options = options;
|
|
285
|
-
}
|
|
286
|
-
apply(compiler) {
|
|
287
|
-
const pluginInfo = getPluginInfo(compiler.options.context || process.cwd());
|
|
288
|
-
const devConfig = loadDevConfig(this.options.devConfigPath || "./plugin.dev.ts");
|
|
289
|
-
const port = this.options.port || devConfig?.port || 3999;
|
|
290
|
-
this.configureDefaults(compiler, pluginInfo);
|
|
291
|
-
if (!compiler.options.devServer) compiler.options.devServer = {};
|
|
292
|
-
this.configureDevServer(compiler, pluginInfo, devConfig, port);
|
|
293
|
-
new ModuleFederationPlugin({
|
|
294
|
-
name: pluginInfo.normalizedName,
|
|
295
|
-
filename: "remoteEntry.js",
|
|
296
|
-
dts: false,
|
|
297
|
-
runtimePlugins: [__require.resolve("@module-federation/node/runtimePlugin")],
|
|
298
|
-
library: { type: "commonjs-module" },
|
|
299
|
-
exposes: { "./plugin": "./src/index.ts" },
|
|
300
|
-
shared: buildSharedDependencies(pluginInfo)
|
|
301
|
-
}).apply(compiler);
|
|
302
|
-
}
|
|
303
|
-
configureDefaults(compiler, pluginInfo) {
|
|
304
|
-
const context = compiler.options.context || process.cwd();
|
|
305
|
-
if (!compiler.options.output) compiler.options.output = {};
|
|
306
|
-
compiler.options.output.uniqueName = pluginInfo.normalizedName;
|
|
307
|
-
compiler.options.output.publicPath = "auto";
|
|
308
|
-
compiler.options.output.path = path.resolve(context, "dist");
|
|
309
|
-
compiler.options.output.clean = true;
|
|
310
|
-
compiler.options.output.library = { type: "commonjs-module" };
|
|
311
|
-
if (!compiler.options.target) compiler.options.target = "async-node";
|
|
312
|
-
if (!compiler.options.mode) compiler.options.mode = process.env.NODE_ENV === "development" ? "development" : "production";
|
|
313
|
-
if (!compiler.options.devtool) compiler.options.devtool = "source-map";
|
|
314
|
-
if (!compiler.options.infrastructureLogging) compiler.options.infrastructureLogging = { level: "warn" };
|
|
315
|
-
this.ensureTypeScriptLoader(compiler);
|
|
316
|
-
if (!compiler.options.resolve) compiler.options.resolve = {};
|
|
317
|
-
compiler.options.resolve.extensions = [
|
|
318
|
-
"...",
|
|
319
|
-
".tsx",
|
|
320
|
-
".ts"
|
|
321
|
-
];
|
|
322
|
-
}
|
|
323
|
-
ensureTypeScriptLoader(compiler) {
|
|
324
|
-
if (!compiler.options.module) compiler.options.module = { rules: [] };
|
|
325
|
-
if (!compiler.options.module.rules) compiler.options.module.rules = [];
|
|
326
|
-
if (!compiler.options.module.rules.some((rule) => typeof rule === "object" && rule !== null && "test" in rule && rule.test instanceof RegExp && rule.test.test(".ts"))) compiler.options.module.rules.push({
|
|
327
|
-
test: /\.tsx?$/,
|
|
328
|
-
use: "builtin:swc-loader",
|
|
329
|
-
exclude: /node_modules/
|
|
330
|
-
});
|
|
331
|
-
}
|
|
332
|
-
configureDevServer(compiler, pluginInfo, devConfig, port) {
|
|
333
|
-
if (!compiler.options.devServer) return;
|
|
334
|
-
const context = compiler.options.context || process.cwd();
|
|
335
|
-
const originalSetup = compiler.options.devServer.setupMiddlewares;
|
|
336
|
-
compiler.options.devServer.port = port;
|
|
337
|
-
compiler.options.devServer.static = path.join(context, "dist");
|
|
338
|
-
compiler.options.devServer.hot = true;
|
|
339
|
-
compiler.options.devServer.devMiddleware = { writeToDisk: true };
|
|
340
|
-
compiler.options.devServer.headers = {
|
|
341
|
-
"Access-Control-Allow-Origin": "*",
|
|
342
|
-
"Access-Control-Allow-Methods": "GET, POST, PUT, DELETE, PATCH, OPTIONS",
|
|
343
|
-
"Access-Control-Allow-Headers": "X-Requested-With, content-type, Authorization"
|
|
344
|
-
};
|
|
345
|
-
compiler.options.devServer.client = {
|
|
346
|
-
logging: "warn",
|
|
347
|
-
overlay: {
|
|
348
|
-
warnings: false,
|
|
349
|
-
errors: true
|
|
350
|
-
}
|
|
351
|
-
};
|
|
352
|
-
compiler.options.devServer.setupMiddlewares = (middlewares, devServer) => {
|
|
353
|
-
setupPluginMiddleware(devServer, pluginInfo, devConfig, port);
|
|
354
|
-
return originalSetup ? originalSetup(middlewares, devServer) : middlewares;
|
|
355
|
-
};
|
|
356
|
-
}
|
|
357
|
-
};
|
|
358
|
-
|
|
359
|
-
//#endregion
|
|
360
|
-
export { EveryPluginDevServer };
|
|
361
|
-
//# sourceMappingURL=index.mjs.map
|
|
3
|
+
export { EveryPluginDevServer };
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
const require_package$1 = require('../../package.cjs');
|
|
2
|
+
|
|
3
|
+
//#region src/build/rspack/module-federation.ts
|
|
4
|
+
function buildSharedDependencies(pluginInfo) {
|
|
5
|
+
const everyPluginPkg = require_package$1.default();
|
|
6
|
+
return {
|
|
7
|
+
"every-plugin": {
|
|
8
|
+
version: everyPluginPkg.version,
|
|
9
|
+
singleton: true,
|
|
10
|
+
requiredVersion: `${everyPluginPkg.version}`,
|
|
11
|
+
strictVersion: false,
|
|
12
|
+
eager: false
|
|
13
|
+
},
|
|
14
|
+
effect: {
|
|
15
|
+
version: everyPluginPkg.dependencies.effect,
|
|
16
|
+
singleton: true,
|
|
17
|
+
requiredVersion: `${everyPluginPkg.dependencies.effect}`,
|
|
18
|
+
strictVersion: false,
|
|
19
|
+
eager: false
|
|
20
|
+
},
|
|
21
|
+
zod: {
|
|
22
|
+
version: everyPluginPkg.dependencies.zod,
|
|
23
|
+
singleton: true,
|
|
24
|
+
requiredVersion: `${everyPluginPkg.dependencies.zod}`,
|
|
25
|
+
strictVersion: false,
|
|
26
|
+
eager: false
|
|
27
|
+
},
|
|
28
|
+
"@orpc/contract": {
|
|
29
|
+
version: everyPluginPkg.dependencies["@orpc/contract"],
|
|
30
|
+
singleton: true,
|
|
31
|
+
requiredVersion: `${everyPluginPkg.dependencies["@orpc/contract"]}`,
|
|
32
|
+
strictVersion: false,
|
|
33
|
+
eager: false
|
|
34
|
+
},
|
|
35
|
+
"@orpc/server": {
|
|
36
|
+
version: everyPluginPkg.dependencies["@orpc/server"],
|
|
37
|
+
singleton: true,
|
|
38
|
+
requiredVersion: `${everyPluginPkg.dependencies["@orpc/server"]}`,
|
|
39
|
+
strictVersion: false,
|
|
40
|
+
eager: false
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
//#endregion
|
|
46
|
+
exports.buildSharedDependencies = buildSharedDependencies;
|
|
47
|
+
//# sourceMappingURL=module-federation.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"module-federation.cjs","names":[],"sources":["../../../src/build/rspack/module-federation.ts"],"sourcesContent":["import type { PluginInfo } from './utils';\n\nexport function buildSharedDependencies(pluginInfo: PluginInfo) {\n // Get every-plugin package info for version constraints\n const everyPluginPkg = require('every-plugin/package.json');\n\n return {\n 'every-plugin': {\n version: everyPluginPkg.version,\n singleton: true,\n requiredVersion: `${everyPluginPkg.version}`,\n strictVersion: false,\n eager: false,\n },\n effect: {\n version: everyPluginPkg.dependencies.effect,\n singleton: true,\n requiredVersion: `${everyPluginPkg.dependencies.effect}`,\n strictVersion: false,\n eager: false,\n },\n zod: {\n version: everyPluginPkg.dependencies.zod,\n singleton: true,\n requiredVersion: `${everyPluginPkg.dependencies.zod}`,\n strictVersion: false,\n eager: false,\n },\n '@orpc/contract': {\n version: everyPluginPkg.dependencies['@orpc/contract'],\n singleton: true,\n requiredVersion: `${everyPluginPkg.dependencies['@orpc/contract']}`,\n strictVersion: false,\n eager: false,\n },\n '@orpc/server': {\n version: everyPluginPkg.dependencies['@orpc/server'],\n singleton: true,\n requiredVersion: `${everyPluginPkg.dependencies['@orpc/server']}`,\n strictVersion: false,\n eager: false,\n },\n };\n}\n"],"mappings":";;;AAEA,SAAgB,wBAAwB,YAAwB;CAE9D,MAAM;AAEN,QAAO;EACL,gBAAgB;GACd,SAAS,eAAe;GACxB,WAAW;GACX,iBAAiB,GAAG,eAAe;GACnC,eAAe;GACf,OAAO;GACR;EACD,QAAQ;GACN,SAAS,eAAe,aAAa;GACrC,WAAW;GACX,iBAAiB,GAAG,eAAe,aAAa;GAChD,eAAe;GACf,OAAO;GACR;EACD,KAAK;GACH,SAAS,eAAe,aAAa;GACrC,WAAW;GACX,iBAAiB,GAAG,eAAe,aAAa;GAChD,eAAe;GACf,OAAO;GACR;EACD,kBAAkB;GAChB,SAAS,eAAe,aAAa;GACrC,WAAW;GACX,iBAAiB,GAAG,eAAe,aAAa;GAChD,eAAe;GACf,OAAO;GACR;EACD,gBAAgB;GACd,SAAS,eAAe,aAAa;GACrC,WAAW;GACX,iBAAiB,GAAG,eAAe,aAAa;GAChD,eAAe;GACf,OAAO;GACR;EACF"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { require_package } from "../../package.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/build/rspack/module-federation.ts
|
|
4
|
+
function buildSharedDependencies(pluginInfo) {
|
|
5
|
+
const everyPluginPkg = require_package();
|
|
6
|
+
return {
|
|
7
|
+
"every-plugin": {
|
|
8
|
+
version: everyPluginPkg.version,
|
|
9
|
+
singleton: true,
|
|
10
|
+
requiredVersion: `${everyPluginPkg.version}`,
|
|
11
|
+
strictVersion: false,
|
|
12
|
+
eager: false
|
|
13
|
+
},
|
|
14
|
+
effect: {
|
|
15
|
+
version: everyPluginPkg.dependencies.effect,
|
|
16
|
+
singleton: true,
|
|
17
|
+
requiredVersion: `${everyPluginPkg.dependencies.effect}`,
|
|
18
|
+
strictVersion: false,
|
|
19
|
+
eager: false
|
|
20
|
+
},
|
|
21
|
+
zod: {
|
|
22
|
+
version: everyPluginPkg.dependencies.zod,
|
|
23
|
+
singleton: true,
|
|
24
|
+
requiredVersion: `${everyPluginPkg.dependencies.zod}`,
|
|
25
|
+
strictVersion: false,
|
|
26
|
+
eager: false
|
|
27
|
+
},
|
|
28
|
+
"@orpc/contract": {
|
|
29
|
+
version: everyPluginPkg.dependencies["@orpc/contract"],
|
|
30
|
+
singleton: true,
|
|
31
|
+
requiredVersion: `${everyPluginPkg.dependencies["@orpc/contract"]}`,
|
|
32
|
+
strictVersion: false,
|
|
33
|
+
eager: false
|
|
34
|
+
},
|
|
35
|
+
"@orpc/server": {
|
|
36
|
+
version: everyPluginPkg.dependencies["@orpc/server"],
|
|
37
|
+
singleton: true,
|
|
38
|
+
requiredVersion: `${everyPluginPkg.dependencies["@orpc/server"]}`,
|
|
39
|
+
strictVersion: false,
|
|
40
|
+
eager: false
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
//#endregion
|
|
46
|
+
export { buildSharedDependencies };
|
|
47
|
+
//# sourceMappingURL=module-federation.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"module-federation.mjs","names":[],"sources":["../../../src/build/rspack/module-federation.ts"],"sourcesContent":["import type { PluginInfo } from './utils';\n\nexport function buildSharedDependencies(pluginInfo: PluginInfo) {\n // Get every-plugin package info for version constraints\n const everyPluginPkg = require('every-plugin/package.json');\n\n return {\n 'every-plugin': {\n version: everyPluginPkg.version,\n singleton: true,\n requiredVersion: `${everyPluginPkg.version}`,\n strictVersion: false,\n eager: false,\n },\n effect: {\n version: everyPluginPkg.dependencies.effect,\n singleton: true,\n requiredVersion: `${everyPluginPkg.dependencies.effect}`,\n strictVersion: false,\n eager: false,\n },\n zod: {\n version: everyPluginPkg.dependencies.zod,\n singleton: true,\n requiredVersion: `${everyPluginPkg.dependencies.zod}`,\n strictVersion: false,\n eager: false,\n },\n '@orpc/contract': {\n version: everyPluginPkg.dependencies['@orpc/contract'],\n singleton: true,\n requiredVersion: `${everyPluginPkg.dependencies['@orpc/contract']}`,\n strictVersion: false,\n eager: false,\n },\n '@orpc/server': {\n version: everyPluginPkg.dependencies['@orpc/server'],\n singleton: true,\n requiredVersion: `${everyPluginPkg.dependencies['@orpc/server']}`,\n strictVersion: false,\n eager: false,\n },\n };\n}\n"],"mappings":";;;AAEA,SAAgB,wBAAwB,YAAwB;CAE9D,MAAM;AAEN,QAAO;EACL,gBAAgB;GACd,SAAS,eAAe;GACxB,WAAW;GACX,iBAAiB,GAAG,eAAe;GACnC,eAAe;GACf,OAAO;GACR;EACD,QAAQ;GACN,SAAS,eAAe,aAAa;GACrC,WAAW;GACX,iBAAiB,GAAG,eAAe,aAAa;GAChD,eAAe;GACf,OAAO;GACR;EACD,KAAK;GACH,SAAS,eAAe,aAAa;GACrC,WAAW;GACX,iBAAiB,GAAG,eAAe,aAAa;GAChD,eAAe;GACf,OAAO;GACR;EACD,kBAAkB;GAChB,SAAS,eAAe,aAAa;GACrC,WAAW;GACX,iBAAiB,GAAG,eAAe,aAAa;GAChD,eAAe;GACf,OAAO;GACR;EACD,gBAAgB;GACd,SAAS,eAAe,aAAa;GACrC,WAAW;GACX,iBAAiB,GAAG,eAAe,aAAa;GAChD,eAAe;GACf,OAAO;GACR;EACF"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
const require_dev_server_middleware = require('./dev-server-middleware.cjs');
|
|
3
|
+
const require_module_federation = require('./module-federation.cjs');
|
|
4
|
+
const require_utils = require('./utils.cjs');
|
|
5
|
+
let __module_federation_enhanced_rspack = require("@module-federation/enhanced/rspack");
|
|
6
|
+
let node_path = require("node:path");
|
|
7
|
+
node_path = require_rolldown_runtime.__toESM(node_path);
|
|
8
|
+
|
|
9
|
+
//#region src/build/rspack/plugin.ts
|
|
10
|
+
var EveryPluginDevServer = class {
|
|
11
|
+
name = "EveryPluginDevServer";
|
|
12
|
+
constructor(options = {}) {
|
|
13
|
+
this.options = options;
|
|
14
|
+
}
|
|
15
|
+
apply(compiler) {
|
|
16
|
+
const pluginInfo = require_utils.getPluginInfo(compiler.options.context || process.cwd());
|
|
17
|
+
const devConfig = require_utils.loadDevConfig(this.options.devConfigPath || "./plugin.dev.ts");
|
|
18
|
+
const port = this.options.port || devConfig?.port || 3999;
|
|
19
|
+
this.configureDefaults(compiler, pluginInfo);
|
|
20
|
+
if (!compiler.options.devServer) compiler.options.devServer = {};
|
|
21
|
+
this.configureDevServer(compiler, pluginInfo, devConfig, port);
|
|
22
|
+
new __module_federation_enhanced_rspack.ModuleFederationPlugin({
|
|
23
|
+
name: pluginInfo.normalizedName,
|
|
24
|
+
filename: "remoteEntry.js",
|
|
25
|
+
dts: false,
|
|
26
|
+
runtimePlugins: [require.resolve("@module-federation/node/runtimePlugin")],
|
|
27
|
+
library: { type: "commonjs-module" },
|
|
28
|
+
exposes: { "./plugin": "./src/index.ts" },
|
|
29
|
+
shared: require_module_federation.buildSharedDependencies(pluginInfo)
|
|
30
|
+
}).apply(compiler);
|
|
31
|
+
}
|
|
32
|
+
configureDefaults(compiler, pluginInfo) {
|
|
33
|
+
const context = compiler.options.context || process.cwd();
|
|
34
|
+
if (!compiler.options.output) compiler.options.output = {};
|
|
35
|
+
compiler.options.output.uniqueName = pluginInfo.normalizedName;
|
|
36
|
+
compiler.options.output.publicPath = "auto";
|
|
37
|
+
compiler.options.output.path = node_path.default.resolve(context, "dist");
|
|
38
|
+
compiler.options.output.clean = true;
|
|
39
|
+
compiler.options.output.library = { type: "commonjs-module" };
|
|
40
|
+
if (!compiler.options.target) compiler.options.target = "async-node";
|
|
41
|
+
if (!compiler.options.mode) compiler.options.mode = process.env.NODE_ENV === "development" ? "development" : "production";
|
|
42
|
+
if (!compiler.options.devtool) compiler.options.devtool = "source-map";
|
|
43
|
+
if (!compiler.options.infrastructureLogging) compiler.options.infrastructureLogging = { level: "warn" };
|
|
44
|
+
this.ensureTypeScriptLoader(compiler);
|
|
45
|
+
if (!compiler.options.resolve) compiler.options.resolve = {};
|
|
46
|
+
compiler.options.resolve.extensions = [
|
|
47
|
+
"...",
|
|
48
|
+
".tsx",
|
|
49
|
+
".ts"
|
|
50
|
+
];
|
|
51
|
+
}
|
|
52
|
+
ensureTypeScriptLoader(compiler) {
|
|
53
|
+
if (!compiler.options.module) compiler.options.module = { rules: [] };
|
|
54
|
+
if (!compiler.options.module.rules) compiler.options.module.rules = [];
|
|
55
|
+
if (!compiler.options.module.rules.some((rule) => typeof rule === "object" && rule !== null && "test" in rule && rule.test instanceof RegExp && rule.test.test(".ts"))) compiler.options.module.rules.push({
|
|
56
|
+
test: /\.tsx?$/,
|
|
57
|
+
use: "builtin:swc-loader",
|
|
58
|
+
exclude: /node_modules/
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
configureDevServer(compiler, pluginInfo, devConfig, port) {
|
|
62
|
+
if (!compiler.options.devServer) return;
|
|
63
|
+
const context = compiler.options.context || process.cwd();
|
|
64
|
+
const originalSetup = compiler.options.devServer.setupMiddlewares;
|
|
65
|
+
compiler.options.devServer.port = port;
|
|
66
|
+
compiler.options.devServer.static = node_path.default.join(context, "dist");
|
|
67
|
+
compiler.options.devServer.hot = true;
|
|
68
|
+
compiler.options.devServer.devMiddleware = { writeToDisk: true };
|
|
69
|
+
compiler.options.devServer.headers = {
|
|
70
|
+
"Access-Control-Allow-Origin": "*",
|
|
71
|
+
"Access-Control-Allow-Methods": "GET, POST, PUT, DELETE, PATCH, OPTIONS",
|
|
72
|
+
"Access-Control-Allow-Headers": "X-Requested-With, content-type, Authorization"
|
|
73
|
+
};
|
|
74
|
+
compiler.options.devServer.client = {
|
|
75
|
+
logging: "warn",
|
|
76
|
+
overlay: {
|
|
77
|
+
warnings: false,
|
|
78
|
+
errors: true
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
compiler.options.devServer.setupMiddlewares = (middlewares, devServer) => {
|
|
82
|
+
require_dev_server_middleware.setupPluginMiddleware(devServer, pluginInfo, devConfig, port);
|
|
83
|
+
return originalSetup ? originalSetup(middlewares, devServer) : middlewares;
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
//#endregion
|
|
89
|
+
exports.EveryPluginDevServer = EveryPluginDevServer;
|
|
90
|
+
//# sourceMappingURL=plugin.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.cjs","names":["options: EveryPluginOptions","getPluginInfo","loadDevConfig","ModuleFederationPlugin","buildSharedDependencies","path"],"sources":["../../../src/build/rspack/plugin.ts"],"sourcesContent":["import { ModuleFederationPlugin } from '@module-federation/enhanced/rspack';\nimport type { Compiler, RspackPluginInstance } from '@rspack/core';\nimport path from 'node:path';\nimport { setupPluginMiddleware } from './dev-server-middleware';\nimport { buildSharedDependencies } from './module-federation';\nimport { getPluginInfo, loadDevConfig } from './utils';\n\n\nexport interface EveryPluginOptions {\n devConfigPath?: string; // defaults to './plugin.dev.ts'\n port?: number; // override plugin.dev.ts port\n pluginId?: string; // override auto-detected\n}\n\nexport class EveryPluginDevServer implements RspackPluginInstance {\n name = 'EveryPluginDevServer';\n\n constructor(private options: EveryPluginOptions = {}) { }\n\n apply(compiler: Compiler) {\n // Load configuration\n const pluginInfo = getPluginInfo(compiler.options.context || process.cwd());\n const devConfig = loadDevConfig(this.options.devConfigPath || './plugin.dev.ts');\n const port = this.options.port || devConfig?.port || 3999;\n\n // Configure defaults immediately (no hooks needed)\n this.configureDefaults(compiler, pluginInfo);\n\n // Initialize devServer if it doesn't exist\n if (!compiler.options.devServer) {\n compiler.options.devServer = {};\n }\n\n // Configure dev server\n this.configureDevServer(compiler, pluginInfo, devConfig, port);\n\n // Apply Module Federation plugin\n new ModuleFederationPlugin({\n name: pluginInfo.normalizedName,\n filename: 'remoteEntry.js',\n // manifest: true, // Enable MF 2.0 manifest generation\n dts: false,\n runtimePlugins: [\n require.resolve('@module-federation/node/runtimePlugin'),\n ],\n library: { type: 'commonjs-module' },\n exposes: {\n './plugin': './src/index.ts',\n },\n shared: buildSharedDependencies(pluginInfo),\n }).apply(compiler);\n }\n\n private configureDefaults(compiler: Compiler, pluginInfo: any) {\n const context = compiler.options.context || process.cwd();\n\n // Configure output defaults\n if (!compiler.options.output) {\n compiler.options.output = {};\n }\n compiler.options.output.uniqueName = pluginInfo.normalizedName;\n compiler.options.output.publicPath = 'auto';\n compiler.options.output.path = path.resolve(context, 'dist');\n compiler.options.output.clean = true;\n compiler.options.output.library = { type: 'commonjs-module' };\n\n // Configure target and mode defaults\n if (!compiler.options.target) {\n compiler.options.target = 'async-node';\n }\n\n if (!compiler.options.mode) {\n compiler.options.mode = process.env.NODE_ENV === 'development' ? 'development' : 'production';\n }\n\n // Configure devtool\n if (!compiler.options.devtool) {\n compiler.options.devtool = 'source-map';\n }\n\n // Suppress verbose infrastructure logging\n if (!compiler.options.infrastructureLogging) {\n compiler.options.infrastructureLogging = {\n level: 'warn', // Only show warnings and errors\n };\n }\n\n // Configure module rules - ensure TypeScript loader is present\n this.ensureTypeScriptLoader(compiler);\n\n // Configure resolve extensions\n if (!compiler.options.resolve) {\n compiler.options.resolve = {};\n }\n compiler.options.resolve.extensions = ['...', '.tsx', '.ts'];\n }\n\n private ensureTypeScriptLoader(compiler: Compiler) {\n if (!compiler.options.module) {\n compiler.options.module = { rules: [] } as any;\n }\n\n if (!compiler.options.module.rules) {\n compiler.options.module.rules = [];\n }\n\n // Check if TypeScript loader is already configured\n const hasTsLoader = compiler.options.module.rules.some((rule: any) =>\n typeof rule === 'object' &&\n rule !== null &&\n 'test' in rule &&\n rule.test instanceof RegExp &&\n rule.test.test('.ts')\n );\n\n // Add TypeScript loader if not present\n if (!hasTsLoader) {\n compiler.options.module.rules.push({\n test: /\\.tsx?$/,\n use: 'builtin:swc-loader',\n exclude: /node_modules/,\n });\n }\n }\n\n private configureDevServer(compiler: Compiler, pluginInfo: any, devConfig: any, port: number) {\n if (!compiler.options.devServer) {\n return; // Should never happen due to check in apply()\n }\n\n const context = compiler.options.context || process.cwd();\n const originalSetup = compiler.options.devServer.setupMiddlewares;\n\n compiler.options.devServer.port = port;\n compiler.options.devServer.static = path.join(context, 'dist');\n compiler.options.devServer.hot = true;\n compiler.options.devServer.devMiddleware = { writeToDisk: true };\n compiler.options.devServer.headers = {\n 'Access-Control-Allow-Origin': '*',\n 'Access-Control-Allow-Methods': 'GET, POST, PUT, DELETE, PATCH, OPTIONS',\n 'Access-Control-Allow-Headers': 'X-Requested-With, content-type, Authorization',\n };\n\n // Suppress verbose logging\n compiler.options.devServer.client = {\n logging: 'warn', // Only show warnings and errors\n overlay: {\n warnings: false, // Don't show warning overlay\n errors: true, // Still show errors\n },\n };\n\n compiler.options.devServer.setupMiddlewares = (middlewares, devServer) => {\n setupPluginMiddleware(devServer, pluginInfo, devConfig, port);\n return originalSetup ? originalSetup(middlewares, devServer) : middlewares;\n };\n }\n}\n"],"mappings":"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"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Compiler, RspackPluginInstance } from "@rspack/core";
|
|
2
|
+
|
|
3
|
+
//#region src/build/rspack/plugin.d.ts
|
|
4
|
+
interface EveryPluginOptions {
|
|
5
|
+
devConfigPath?: string;
|
|
6
|
+
port?: number;
|
|
7
|
+
pluginId?: string;
|
|
8
|
+
}
|
|
9
|
+
declare class EveryPluginDevServer implements RspackPluginInstance {
|
|
10
|
+
private options;
|
|
11
|
+
name: string;
|
|
12
|
+
constructor(options?: EveryPluginOptions);
|
|
13
|
+
apply(compiler: Compiler): void;
|
|
14
|
+
private configureDefaults;
|
|
15
|
+
private ensureTypeScriptLoader;
|
|
16
|
+
private configureDevServer;
|
|
17
|
+
}
|
|
18
|
+
//#endregion
|
|
19
|
+
export { EveryPluginDevServer, EveryPluginOptions };
|
|
20
|
+
//# sourceMappingURL=plugin.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.d.cts","names":[],"sources":["../../../src/build/rspack/plugin.ts"],"sourcesContent":[],"mappings":";;;UAQiB,kBAAA;;EAAA,IAAA,CAAA,EAAA,MAAA;EAMJ,QAAA,CAAA,EAAA,MAAA;;AAKK,cALL,oBAAA,YAAgC,oBAK3B,CAAA;EAL2B,QAAA,OAAA;EAAoB,IAAA,EAAA,MAAA;wBAGlC;kBAEb"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Compiler, RspackPluginInstance } from "@rspack/core";
|
|
2
|
+
|
|
3
|
+
//#region src/build/rspack/plugin.d.ts
|
|
4
|
+
interface EveryPluginOptions {
|
|
5
|
+
devConfigPath?: string;
|
|
6
|
+
port?: number;
|
|
7
|
+
pluginId?: string;
|
|
8
|
+
}
|
|
9
|
+
declare class EveryPluginDevServer implements RspackPluginInstance {
|
|
10
|
+
private options;
|
|
11
|
+
name: string;
|
|
12
|
+
constructor(options?: EveryPluginOptions);
|
|
13
|
+
apply(compiler: Compiler): void;
|
|
14
|
+
private configureDefaults;
|
|
15
|
+
private ensureTypeScriptLoader;
|
|
16
|
+
private configureDevServer;
|
|
17
|
+
}
|
|
18
|
+
//#endregion
|
|
19
|
+
export { EveryPluginDevServer, EveryPluginOptions };
|
|
20
|
+
//# sourceMappingURL=plugin.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.d.mts","names":[],"sources":["../../../src/build/rspack/plugin.ts"],"sourcesContent":[],"mappings":";;;UAQiB,kBAAA;;EAAA,IAAA,CAAA,EAAA,MAAA;EAMJ,QAAA,CAAA,EAAA,MAAA;;AAKK,cALL,oBAAA,YAAgC,oBAK3B,CAAA;EAL2B,QAAA,OAAA;EAAoB,IAAA,EAAA,MAAA;wBAGlC;kBAEb"}
|