@moneko/core 4.8.6-beta.6 → 4.8.6-beta.7
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.
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
import { type Compiler } from 'webpack';
|
|
2
2
|
interface ModuleFederationExposesDeclarationPluginOptions {
|
|
3
3
|
name: string;
|
|
4
|
-
exposes
|
|
4
|
+
exposes: Record<string, string>;
|
|
5
5
|
}
|
|
6
6
|
export declare class ModuleFederationExposesDeclarationPlugin {
|
|
7
7
|
private name;
|
|
8
8
|
private assetName;
|
|
9
|
-
private
|
|
9
|
+
private dts;
|
|
10
|
+
private compiler;
|
|
11
|
+
private worker;
|
|
10
12
|
constructor(option: ModuleFederationExposesDeclarationPluginOptions);
|
|
13
|
+
final(err: NodeJS.ErrnoException | null): void;
|
|
14
|
+
writeDts(): void;
|
|
11
15
|
apply(compiler: Compiler): void;
|
|
12
16
|
}
|
|
13
17
|
export { };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{join as
|
|
1
|
+
import{join as t}from"node:path";import{fileURLToPath as e}from"node:url";import{Worker as s}from"node:worker_threads";import i from"../commom/log.mjs";export class ModuleFederationExposesDeclarationPlugin{constructor(t){this.name="ModuleFederationExposesDeclarationPlugin",this.assetName="module-federation.d.ts",this.dts="",this.compiler=null,this.worker=new s(e(new URL("../worker/dts.mjs",import.meta.url))),this.worker.setMaxListeners(0),this.worker.postMessage({options:t}),this.worker.once("message",t=>{this.dts=t,this.writeDts(),this.worker.terminate()})}final(t){t&&i(t)}writeDts(){let e=this.compiler?.options.output.path,s=this.compiler?.outputFileSystem;e&&s&&(s.mkdir(e,{recursive:!0},this.final),s.writeFile(t(e,this.assetName),this.dts,{encoding:"utf-8"},this.final))}apply(t){this.compiler=t,t.hooks.done.tap(this.name,t=>{t.hasErrors()||this.writeDts()})}}
|
package/lib/worker/dts.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{parentPort as e}from"node:worker_threads";import{bundleDts as
|
|
1
|
+
import{parentPort as e}from"node:worker_threads";import{bundleDts as r}from"../commom/bundle-dts.mjs";import{module_federation_schema as s}from"../process-env.mjs";if(!e)throw Error("This file must be run as a worker");e?.setMaxListeners(0),e.on("message",async({options:o})=>{try{let{name:t,exposes:m={}}=o,a=[],p=[];Object.keys(m).map(e=>{e.startsWith(t)?(p.push({[e]:m[e]}),a.push(`declare module "${s}:${e}" { export * from "${e}"; export { default } from "${e}"; }`)):(p.push(e),a.push(`declare module "${t}/${e}" { export * from "${e}"; export { default } from "${e}"; }`))});let f=await r(p,`_${t}_`);a.unshift(f);let u=a.join("\n\n");e.postMessage(u)}catch{e.postMessage("")}});
|