@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.
package/lib/plugin/copy.d.mts
CHANGED
|
@@ -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
|
}
|
package/lib/plugin/copy.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
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:
|
|
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;
|