@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?: Record<string, string>;
4
+ exposes: Record<string, string>;
5
5
  }
6
6
  export declare class ModuleFederationExposesDeclarationPlugin {
7
7
  private name;
8
8
  private assetName;
9
- private options;
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 e}from"node:path";import{fileURLToPath as t}from"node:url";import{Worker as o}from"node:worker_threads";import r from"../commom/log.mjs";export class ModuleFederationExposesDeclarationPlugin{constructor(e){this.name="ModuleFederationExposesDeclarationPlugin",this.assetName="module-federation.d.ts",this.options=e}apply(s){s.hooks.done.tapPromise(this.name,async i=>{if(i.hasErrors())return;let n=s.outputFileSystem,a=s.options.output.path;if(!n||!a)return;let m=new o(t(new URL("../worker/dts.mjs",import.meta.url)));m.setMaxListeners(0);try{let t=await new Promise((e,t)=>{m.once("message",e),m.once("error",t),m.postMessage({options:this.options})});s.outputFileSystem?.writeFile(e(a,this.assetName),t,{encoding:"utf-8"},e=>{e&&r(e)})}catch(e){r(e)}m.terminate()})}}
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()})}}
@@ -1 +1 @@
1
- import{parentPort as e}from"node:worker_threads";import{bundleDts as s}from"../commom/bundle-dts.mjs";import{module_federation_schema as r}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 "${r}:${e}" { export * from "${e}"; }`)):(p.push(e),a.push(`declare module "${t}/${e}" { export * from "${e}"; }`))});let i=await s(p,`_${t}_`);a.unshift(i);let n=a.join("\n\n");e.postMessage(n)}catch{e.postMessage("")}});
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("")}});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moneko/core",
3
- "version": "4.8.6-beta.6",
3
+ "version": "4.8.6-beta.7",
4
4
  "description": "@moneko/core",
5
5
  "main": "lib/index.mjs",
6
6
  "type": "module",