@moneko/core 3.19.1 → 3.19.3-beta.0
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/options/js-minify.mjs +1 -1
- package/lib/plugin/copy.d.mts +1 -2
- package/lib/plugin/copy.mjs +1 -1
- package/lib/plugin/exposes-declararion.d.mts +11 -0
- package/lib/plugin/exposes-declararion.mjs +2 -0
- package/lib/plugin/module-federation.mjs +1 -1
- package/package.json +4 -3
- package/typings/global.d.ts +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"terser-webpack-plugin";import{merge as o}from"webpack-merge";let r={drop_console:!0,drop_debugger:!0,global_defs:{"@alert":"console.log"},pure_funcs:["console.log","console.warn","console.error","console.info"]},s={ecma:2015,toplevel:!1,module:!1,ie8:!1,keep_classnames:void 0,keep_fnames:!1};export const minify={terser:{minify:e.terserMinify,terserOptions:{compress:r,...s,mangle:!0,format:{comments:!1},safari10:!1,parse:{}},extractComments:!1},swc:{minify:e.swcMinify,terserOptions:{compress:{...r,...s,top_retain:[],keep_infinity:!0},mangle:!0}}};export const getMinifyOption=(e="swc",r={})=>{let s=minify[e];return Object.assign(s,{terserOptions:o(s.terserOptions,r)})};
|
|
1
|
+
import e from"terser-webpack-plugin";import{merge as o}from"webpack-merge";let r={drop_console:!0,drop_debugger:!0,global_defs:{"@alert":"console.log"},pure_funcs:["console.log","console.warn","console.error","console.info"]},s={ecma:2015,toplevel:!1,module:!1,ie8:!1,keep_classnames:void 0,keep_fnames:!1};export const minify={terser:{minify:e.terserMinify,terserOptions:{compress:r,...s,mangle:!0,format:{comments:!1},safari10:!1,parse:{}},extractComments:!1},swc:{minify:e.swcMinify,terserOptions:{format:{comments:!1},compress:{...r,...s,top_retain:[],keep_infinity:!0},mangle:!0}}};export const getMinifyOption=(e="swc",r={})=>{let s=minify[e];return Object.assign(s,{terserOptions:o(s.terserOptions,r)})};
|
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,2 @@
|
|
|
1
|
+
import e from"webpack";import{ModuleDeclarationKind as t,Project as o,SyntaxKind as s}from"ts-morph";import{resolve as a,join as r}from"path";import{generateDeclaration as i}from"../utils/dts.mjs";import{loadFile as n}from"@moneko/utils";let m=e=>{let a=new o,r=[];return e.forEach(e=>{let o=a.addSourceFileAtPath(e.path);o.forEachDescendant(e=>{e.getKind()===s.DeclareKeyword&&e.replaceWithText(e.isFirstNodeOnLine()?"export":"")});let i=o.getStructure().statements;o.getStatements().forEach(e=>e.remove()),o.addModule({name:`'${e.moduleName}'`,declarationKind:t.Module,hasDeclareKeyword:!0,statements:i}),o.formatText(),r.push(`// module name: ${e.moduleName}
|
|
2
|
+
`),r.push(o.getText())}),r.join("\n")};export class ModuleFederationExposesDeclarationPlugin{constructor(e){this.option=e}apply(t){t.hooks.compilation.tap("ModuleFederationExposesDeclarationPlugin",t=>{let{exposes:o}=this.option;Promise.all(Object.keys(o).map(async s=>{let m=i(await n(a(o[s]))||"",`${s}.ts`),l=r("types",this.option.name,`${s}.d.ts`);return t.emitAsset(l,new e.sources.RawSource(m)),{path:l,moduleName:s}})).then(o=>{let s=m(o);t.emitAsset("exposes.d.ts",new e.sources.RawSource(s))})})}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"webpack";import r from"./external-remotes.mjs";import{CONFIG as t}from"../config.mjs";import
|
|
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.
|
|
3
|
+
"version": "3.19.3-beta.0",
|
|
4
4
|
"description": "core",
|
|
5
5
|
"main": "lib/index.mjs",
|
|
6
6
|
"type": "module",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"@moneko/mdx": "0.1.39",
|
|
17
17
|
"@moneko/transform-imports": "0.6.0",
|
|
18
18
|
"@moneko/utils": "0.1.5",
|
|
19
|
-
"@swc/core": "1.6.
|
|
19
|
+
"@swc/core": "1.6.6",
|
|
20
20
|
"@typescript/vfs": "1.5.3",
|
|
21
21
|
"browserslist": "4.23.1",
|
|
22
22
|
"chalk": "5.3.0",
|
|
@@ -38,6 +38,7 @@
|
|
|
38
38
|
"style-loader": "4.0.0",
|
|
39
39
|
"swc-loader": "0.2.6",
|
|
40
40
|
"terser-webpack-plugin": "5.3.10",
|
|
41
|
+
"ts-morph": "^23.0.0",
|
|
41
42
|
"typescript": "5.5.2",
|
|
42
43
|
"webpack": "5.92.1",
|
|
43
44
|
"webpack-bundle-analyzer": "4.10.2",
|
|
@@ -49,7 +50,7 @@
|
|
|
49
50
|
},
|
|
50
51
|
"devDependencies": {
|
|
51
52
|
"@moneko/css": "1.1.5",
|
|
52
|
-
"@swc/cli": "0.
|
|
53
|
+
"@swc/cli": "0.4.0",
|
|
53
54
|
"@types/babel__core": "7.20.5",
|
|
54
55
|
"@types/express": "4.17.21",
|
|
55
56
|
"@types/multer": "1.4.11",
|
package/typings/global.d.ts
CHANGED
|
@@ -158,7 +158,7 @@ export declare type ConfigType = {
|
|
|
158
158
|
| false;
|
|
159
159
|
/** 环境变量, 可通过 process.env 获取 */
|
|
160
160
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
161
|
-
env
|
|
161
|
+
env: Record<string, any>;
|
|
162
162
|
/**
|
|
163
163
|
* @default
|
|
164
164
|
* 开发模式: 'cheap-module-source-map'
|