@moneko/core 3.19.2 → 3.19.3

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,4 +1,4 @@
1
- import { Compiler } from 'webpack';
1
+ import { type Compiler } from 'webpack';
2
2
  /** 需要拷贝的文件列表
3
3
  * @example
4
4
  * ```ts
@@ -21,6 +21,5 @@ export interface CopyPluginOption {
21
21
  export declare class CopyPlugin {
22
22
  private option;
23
23
  constructor(option: CopyPluginOption);
24
- private writeFile;
25
24
  apply(compiler: Compiler): void;
26
25
  }
@@ -1 +1 @@
1
- import{basename as t,resolve as i}from"path";import o from"../utils/log.mjs";import{loadFileSync as p,scanFolderSync as e}from"@moneko/utils";export class CopyPlugin{constructor(t){this.option=t}async writeFile(e,l){let r=l.compiler.outputFileSystem;if(r){let s=t(e),m=p(i(e));r.writeFile(i(l.outputOptions.path,s),m||"",t=>{t&&o(`Error copying file ${s} to output directory: ${t}`)})}}apply(t){t.hooks.emit.tapPromise({name:"CopyPlugin",stage:t.webpack.Compilation.PROCESS_ASSETS_STAGE_REPORT},async t=>{if(this.option&&t.compiler.outputFileSystem){let i=[...this.option.files||[],...this.option.dirs?.flatMap(t=>e(t))||[]];await Promise.all(i.map(i=>this.writeFile(i,t)))}})}}
1
+ import{resolve as o}from"path";import t from"webpack";import{loadFile as i,scanFolderSync as p}from"@moneko/utils";export class CopyPlugin{constructor(o){this.option=o}apply(s){this.option&&s.hooks.compilation.tap("CopyPlugin",s=>{Promise.all([...this.option.files||[],...this.option.dirs?.flatMap(o=>p(o))||[]].map(async p=>{let a=await i(o(p));s.emitAsset(p,new t.sources.RawSource(a||""))}))})}}
@@ -0,0 +1,11 @@
1
+ import { type Compiler } from 'webpack';
2
+ interface ModuleFederationExposesDeclarationPluginOptions {
3
+ name: string;
4
+ exposes: Record<string, string>;
5
+ }
6
+ export declare class ModuleFederationExposesDeclarationPlugin {
7
+ private option;
8
+ constructor(option: ModuleFederationExposesDeclarationPluginOptions);
9
+ apply(compiler: Compiler): void;
10
+ }
11
+ export {};
@@ -0,0 +1 @@
1
+ import o from"webpack";import{resolve as t,join as e}from"path";import{generateDeclaration as s}from"../utils/dts.mjs";import{loadFile as i}from"@moneko/utils";export class ModuleFederationExposesDeclarationPlugin{constructor(o){this.option=o}apply(a){a.hooks.compilation.tap("ModuleFederationExposesDeclarationPlugin",a=>{let{exposes:p}=this.option;Promise.all(Object.keys(p).map(async r=>{let l=s(await i(t(p[r]))||"",`${r}.ts`);a.emitAsset(e("types",this.option.name,`${r}.d.ts`),new o.sources.RawSource(l))}))})}}
@@ -1 +1 @@
1
- import e from"webpack";import r from"./external-remotes.mjs";import{CONFIG as t}from"../config.mjs";import s from"../utils/require.mjs";import{resolveProgram as o}from"../utils/index.mjs";let{NormalModuleReplacementPlugin:i,container:{ModuleFederationPlugin:a}}=e,m={},l={},n={},p=t.moduleFederation?.map(e=>{if(Array.isArray(e.remotes))for(let r=0,t=e.remotes.length;r<t;r++){let t=e.remotes[r],s=t.alias||t.name,o=t.filename||"remote_entry.js";if(n[s]=`${t.name}@${t.host}/${o}`,Array.isArray(t.library))for(let e=0,r=t.library.length;e<r;e++)m[t.library[e]]=`${s}/${t.library[e]}`}if(Array.isArray(e.exposes))for(let r=0,t=e.exposes.length;r<t;r++){let t=e.exposes[r];"string"==typeof t?l[`./${t.toString()}`]=s.resolve(t.startsWith(".")?o(t):t):"[object Object]"===Object.prototype.toString.call(t)&&(l[`./${t.name}`]=s.resolve(t.path.startsWith(".")?o(t.path):t.path))}return new a({filename:"remote_entry.js",...e,remotes:n,exposes:l})});p.length>0&&(p.push(new r),p.push(new i(/(.*)/,e=>{m[e.request]&&(e.request=m[e.request])}))),t.env.injectRemoteReactRefresh=Object.keys(m).includes("react-dom");export default p;
1
+ import e from"webpack";import r from"./external-remotes.mjs";import{CONFIG as t}from"../config.mjs";import s from"../utils/require.mjs";import{resolveProgram as o}from"../utils/index.mjs";import{ModuleFederationExposesDeclarationPlugin as a}from"./exposes-declararion.mjs";let{NormalModuleReplacementPlugin:m,container:{ModuleFederationPlugin:i}}=e,l={},n=[],p=t.moduleFederation?.map(e=>{let r={},t={},m={};if(Array.isArray(e.remotes))for(let r=0,s=e.remotes.length;r<s;r++){let s=e.remotes[r],o=s.alias||s.name,a=s.filename||"remote_entry.js";if(t[o]=`${s.name}@${s.host}/${a}`,Array.isArray(s.library))for(let e=0,r=s.library.length;e<r;e++)l[s.library[e]]=`${o}/${s.library[e]}`}if(Array.isArray(e.exposes)){for(let t=0,a=e.exposes.length;t<a;t++){let a=e.exposes[t];if("string"==typeof a){let e=a.startsWith(".");r[`./${a}`]=s.resolve(e?o(a):a),e&&(m[a]=r[`./${a}`])}else if("[object Object]"===Object.prototype.toString.call(a)){let e=a.path.startsWith(".");r[`./${a.name}`]=s.resolve(e?o(a.path):a.path),e&&(m[`./${a.name}`]=r[`./${a.name}`])}}e.exposes?.length&&n.push(new a({exposes:m,name:e.name}))}return new i({filename:"remote_entry.js",...e,remotes:t,exposes:r})});p.length>0&&(p.push(new r),p.push(new m(/(.*)/,e=>{l[e.request]&&(e.request=l[e.request])})),n.forEach(e=>p.push(e))),t.env.injectRemoteReactRefresh=Object.keys(l).includes("react-dom");export default p;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moneko/core",
3
- "version": "3.19.2",
3
+ "version": "3.19.3",
4
4
  "description": "core",
5
5
  "main": "lib/index.mjs",
6
6
  "type": "module",