@moneko/core 3.19.1 → 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 +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)})};
@@ -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 o from"../utils/require.mjs";import{resolveProgram as s}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],o=t.alias||t.name,s=t.filename||"remote_entry.js";if(n[o]=`${t.name}@${t.host}/${s}`,Array.isArray(t.library))for(let e=0,r=t.library.length;e<r;e++)m[t.library[e]]=`${o}/${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()}`]=o.resolve(t.startsWith(".")?s(t):t):"[object Object]"===Object.prototype.toString.call(t)&&(l[`./${t.name}`]=o.resolve(t.path.startsWith(".")?s(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])})));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.1",
3
+ "version": "3.19.3",
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.5",
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",
@@ -49,7 +49,7 @@
49
49
  },
50
50
  "devDependencies": {
51
51
  "@moneko/css": "1.1.5",
52
- "@swc/cli": "0.3.14",
52
+ "@swc/cli": "0.4.0",
53
53
  "@types/babel__core": "7.20.5",
54
54
  "@types/express": "4.17.21",
55
55
  "@types/multer": "1.4.11",
@@ -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?: Record<string, any>;
161
+ env: Record<string, any>;
162
162
  /**
163
163
  * @default
164
164
  * 开发模式: 'cheap-module-source-map'