every-plugin 2.4.0 → 2.4.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/build/rspack/plugin.cjs +1 -1
- package/dist/build/rspack/plugin.cjs.map +1 -1
- package/dist/build/rspack/plugin.mjs +1 -1
- package/dist/build/rspack/plugin.mjs.map +1 -1
- package/dist/build/shared-deps.cjs +16 -0
- package/dist/build/shared-deps.cjs.map +1 -1
- package/dist/build/shared-deps.d.cts +28 -0
- package/dist/build/shared-deps.d.cts.map +1 -1
- package/dist/build/shared-deps.d.mts +28 -0
- package/dist/build/shared-deps.d.mts.map +1 -1
- package/dist/build/shared-deps.mjs +16 -0
- package/dist/build/shared-deps.mjs.map +1 -1
- package/dist/runtime/mf-config.cjs +17 -1
- package/dist/runtime/mf-config.cjs.map +1 -1
- package/dist/runtime/mf-config.d.cts +36 -0
- package/dist/runtime/mf-config.d.cts.map +1 -1
- package/dist/runtime/mf-config.d.mts +36 -0
- package/dist/runtime/mf-config.d.mts.map +1 -1
- package/dist/runtime/mf-config.mjs +17 -1
- package/dist/runtime/mf-config.mjs.map +1 -1
- package/dist/runtime/services/module-federation.service.cjs +19 -11
- package/dist/runtime/services/module-federation.service.cjs.map +1 -1
- package/dist/runtime/services/module-federation.service.d.cts.map +1 -1
- package/dist/runtime/services/module-federation.service.d.mts.map +1 -1
- package/dist/runtime/services/module-federation.service.mjs +19 -11
- package/dist/runtime/services/module-federation.service.mjs.map +1 -1
- package/package.json +7 -3
- package/skills/plugin-development/SKILL.md +208 -0
- package/skills/plugin-testing/SKILL.md +152 -0
- package/src/build/rspack/plugin.ts +1 -1
- package/src/build/shared-deps.ts +16 -0
- package/src/runtime/mf-config.ts +16 -0
- package/src/runtime/services/module-federation.service.ts +37 -24
|
@@ -12,38 +12,49 @@ const sharedModuleLoaders = {
|
|
|
12
12
|
"every-plugin": () => import("every-plugin"),
|
|
13
13
|
effect: () => import("effect"),
|
|
14
14
|
zod: () => import("zod"),
|
|
15
|
+
"better-auth": () => import("better-auth"),
|
|
16
|
+
"drizzle-orm": () => import("drizzle-orm"),
|
|
17
|
+
"@orpc/contract": () => import("@orpc/contract"),
|
|
18
|
+
"@orpc/server": () => import("@orpc/server"),
|
|
15
19
|
} satisfies Record<SharedDepName, () => Promise<unknown>>;
|
|
16
20
|
|
|
21
|
+
function buildSharedConfig(): Record<
|
|
22
|
+
string,
|
|
23
|
+
{
|
|
24
|
+
version: string;
|
|
25
|
+
get: () => Promise<() => unknown>;
|
|
26
|
+
shareConfig: (typeof MF_SHARED_DEPS)[SharedDepName]["shareConfig"];
|
|
27
|
+
}
|
|
28
|
+
> {
|
|
29
|
+
return Object.fromEntries(
|
|
30
|
+
(
|
|
31
|
+
Object.entries(MF_SHARED_DEPS) as [SharedDepName, (typeof MF_SHARED_DEPS)[SharedDepName]][]
|
|
32
|
+
).map(([name, config]) => {
|
|
33
|
+
const load = sharedModuleLoaders[name];
|
|
34
|
+
|
|
35
|
+
if (!load) {
|
|
36
|
+
throw new Error(`Missing shared module loader for ${name}`);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return [
|
|
40
|
+
name,
|
|
41
|
+
{
|
|
42
|
+
version: config.version,
|
|
43
|
+
get: () => load().then((mod) => () => mod),
|
|
44
|
+
shareConfig: config.shareConfig,
|
|
45
|
+
},
|
|
46
|
+
];
|
|
47
|
+
}),
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
|
|
17
51
|
const createModuleFederationInstance = Effect.cached(
|
|
18
52
|
Effect.sync(() => {
|
|
19
53
|
try {
|
|
54
|
+
const shared = buildSharedConfig();
|
|
20
55
|
let instance = getInstance();
|
|
21
56
|
|
|
22
57
|
if (!instance) {
|
|
23
|
-
const shared = Object.fromEntries(
|
|
24
|
-
(
|
|
25
|
-
Object.entries(MF_SHARED_DEPS) as [
|
|
26
|
-
SharedDepName,
|
|
27
|
-
(typeof MF_SHARED_DEPS)[SharedDepName],
|
|
28
|
-
][]
|
|
29
|
-
).map(([name, config]) => {
|
|
30
|
-
const load = sharedModuleLoaders[name];
|
|
31
|
-
|
|
32
|
-
if (!load) {
|
|
33
|
-
throw new Error(`Missing shared module loader for ${name}`);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
return [
|
|
37
|
-
name,
|
|
38
|
-
{
|
|
39
|
-
version: config.version,
|
|
40
|
-
get: () => load().then((mod) => () => mod),
|
|
41
|
-
shareConfig: config.shareConfig,
|
|
42
|
-
},
|
|
43
|
-
];
|
|
44
|
-
}),
|
|
45
|
-
);
|
|
46
|
-
|
|
47
58
|
instance = createInstance({
|
|
48
59
|
name: "host",
|
|
49
60
|
remotes: [],
|
|
@@ -51,6 +62,8 @@ const createModuleFederationInstance = Effect.cached(
|
|
|
51
62
|
});
|
|
52
63
|
|
|
53
64
|
setGlobalFederationInstance(instance);
|
|
65
|
+
} else {
|
|
66
|
+
instance.registerShared(shared);
|
|
54
67
|
}
|
|
55
68
|
|
|
56
69
|
return instance;
|