@moneko/core 3.8.4 → 3.8.5-beta.1

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"external-remotes-plugin";import r from"webpack";import t from"webpack/lib/container/ModuleFederationPlugin.js";import{CONFIG as o}from"./config.js";import{realResolve as l}from"./utils.js";let i=r.NormalModuleReplacementPlugin,a={},n={},s={};export const moduleFederation=o.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,l=t.filename||"remote_entry.js";if(s[o]=`${t.name}@${t.host}/${l}`,Array.isArray(t.library))for(let e=0,r=t.library.length;e<r;e++)a[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?n[`./${t}`]=l(t):"[object Object]"===Object.prototype.toString.call(t)&&(n[`./${t.name}`]=l(t.path))}return new t({filename:"remote_entry.js",...e,remotes:s,exposes:n})});moduleFederation.length&&(moduleFederation.push(new e),moduleFederation.push(new i(/(.*)/,e=>{a[e.request]&&(e.request=a[e.request])})));
1
+ import e from"webpack";import r from"webpack/lib/container/ModuleFederationPlugin.js";import{CONFIG as t}from"./config.js";import o from"./plugin/external-remotes.js";import{realResolve as l}from"./utils.js";let i=e.NormalModuleReplacementPlugin,a={},n={},s={};export const moduleFederation=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,l=t.filename||"remote_entry.js";if(s[o]=`${t.name}@${t.host}/${l}`,Array.isArray(t.library))for(let e=0,r=t.library.length;e<r;e++)a[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?n[`./${t}`]=l(t):"[object Object]"===Object.prototype.toString.call(t)&&(n[`./${t.name}`]=l(t.path))}return new r({filename:"remote_entry.js",...e,remotes:s,exposes:n})});moduleFederation.length&&(moduleFederation.push(new o),moduleFederation.push(new i(/(.*)/,e=>{a[e.request]&&(e.request=a[e.request])})));
@@ -6,4 +6,5 @@ declare class DoneWebpackPlugin {
6
6
  });
7
7
  apply(compiler: Compiler): void;
8
8
  }
9
+ export type DonePluginOption = ConstructorParameters<typeof DoneWebpackPlugin>[0]['done'];
9
10
  export default DoneWebpackPlugin;
@@ -1 +1 @@
1
- import{isDev as o}from"../process-env.js";import{vmWriteing as e}from"../reactive-object.js";export default class{constructor(o){this.options=Object.assign({},o)}apply(n){o||n.hooks.compilation.tap("DoneWebpackPlugin",o=>{e.setData("DoneDonePlugin",!0),o.compiler.hooks.done.tap("DoneDonePlugin",()=>{e.setData("DoneDonePlugin",!1)})}),n.hooks.done.tap("DoneWebpackPlugin",o=>{this.options.done(o)})}}
1
+ import{isDev as o}from"../process-env.js";import{vmWriteing as e}from"../reactive-object.js";let t="DoneWebpackPlugin";export default class{constructor(o){this.options=Object.assign({},o)}apply(n){o||n.hooks.compilation.tap(t,o=>{e.setData("DoneDonePlugin",!0),o.compiler.hooks.done.tap("DoneDonePlugin",()=>{e.setData("DoneDonePlugin",!1)})}),n.hooks.done.tap(t,o=>{this.options.done(o)})}}
@@ -0,0 +1,5 @@
1
+ import { type Compiler } from 'webpack';
2
+ declare class ExternalTemplateRemotesPlugin {
3
+ apply(compiler: Compiler): void;
4
+ }
5
+ export default ExternalTemplateRemotesPlugin;
@@ -0,0 +1 @@
1
+ import e from"webpack";import t from"webpack/lib/util/extractUrlAndGlobal.js";let{Compilation:s,sources:l}=e,o="ExternalRemotesPlugin";export default class{apply(e){e.hooks.make.tap(o,e=>{let r=[];e.hooks.buildModule.tap(o,e=>{"ExternalModule"===e.constructor.name&&"script"===e.externalType&&r.push(e)}),e.hooks.processAssets.tap({name:o,stage:s.PROCESS_ASSETS_STAGE_ADDITIONS},()=>{r.forEach(s=>{let o=t(s.request)[0],r=function(e){let t=[],s=[],l=!1,o=!1;for(let r of e)if("["===r){if(l){o=!0;break}l=!0,s.length&&(t.push(`"${s.join("")}"`),s.length=0)}else if("]"===r){if(!l){o=!0;break}l=!1,s.length&&(t.push(`${s.join("")}`),s.length=0),s.length=0}else s.push(r);if(l||o)throw Error(`Invalid template URL "${e}"`);return s.length&&t.push(`"${s.join("")}"`),t.join(" + ")}(o),a=e.getAsset(s.userRequest)?.source,n=new l.RawSource(a?.source().replace(`"${o}"`,r));e.updateAsset(s.userRequest,n)})})})}}
@@ -1 +1 @@
1
- import{existsSync as e}from"fs";import{relative as t}from"path";import r from"../paths.js";export default class{constructor(e){this.options=e}apply(i){let{override:a,original:s}=this.options;if(a&&s){let o=`./${t(r.programPath,s)}`,l=`./${t(r.programPath,a)}`;i.getHook("existing-file").tapAsync("OverrideResolverPlugin",(t,r,p)=>{let n=t.request||t.path;if(n&&n.startsWith(s)&&t.relativePath){let h=n.replace(s,a);if(e(h)){let e=t.relativePath.replace(o,l);return Object.assign(t,{path:h,relativePath:e,__innerRequest_relativePath:e,__innerRequest:e}),i.doResolve("resolved",t,`OverrideResolverPlugin 使用目标模块${a}`,r,p)}}return p()})}}}
1
+ import{existsSync as t}from"fs";import{relative as e}from"path";import r from"../paths.js";let a="OverrideResolverPlugin";export default class{constructor(t){this.options=t}apply(i){let{override:s,original:o}=this.options;if(s&&o){let l=`./${e(r.programPath,o)}`,p=`./${e(r.programPath,s)}`;i.getHook("existing-file").tapAsync(a,(e,r,h)=>{let n=e.request||e.path;if(n&&n.startsWith(o)&&e.relativePath){let f=n.replace(o,s);if(t(f)){let t=e.relativePath.replace(l,p);return Object.assign(e,{path:f,relativePath:t,__innerRequest_relativePath:t,__innerRequest:t}),i.doResolve("resolved",e,`${a} 使用目标模块${s}`,r,h)}}return h()})}}}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moneko/core",
3
- "version": "3.8.4",
3
+ "version": "3.8.5-beta.1",
4
4
  "description": "core",
5
5
  "main": "lib/index.js",
6
6
  "type": "module",
@@ -17,14 +17,12 @@
17
17
  "@swc/css": "0.0.28",
18
18
  "@swc/helpers": "0.5.3",
19
19
  "@teamsupercell/typings-for-css-modules-loader": "2.5.2",
20
- "@types/webpack-bundle-analyzer": "4.6.2",
21
20
  "add-asset-html-webpack-plugin": "6.0.0",
22
21
  "core-js": "3.33.3",
23
22
  "core-js-compat": "3.33.3",
24
23
  "cross-env": "7.0.3",
25
24
  "css-loader": "6.8.1",
26
25
  "css-minimizer-webpack-plugin": "5.0.1",
27
- "external-remotes-plugin": "1.0.0",
28
26
  "html-webpack-plugin": "5.5.3",
29
27
  "less": "4.2.0",
30
28
  "less-loader": "11.1.3",
@@ -37,14 +35,14 @@
37
35
  "swc-loader": "0.2.3",
38
36
  "swc-plugin-another-transform-imports": "0.2.7",
39
37
  "ts-import-plugin": "3.0.0",
40
- "ts-loader": "9.5.0",
38
+ "ts-loader": "9.5.1",
41
39
  "typescript": "5.2.2",
42
40
  "webpack": "5.77.0",
43
- "webpack-bundle-analyzer": "4.9.1",
41
+ "webpack-bundle-analyzer": "4.10.1",
44
42
  "webpack-cli": "5.1.4",
45
43
  "webpack-dev-server": "4.15.1",
46
44
  "webpack-merge": "5.10.0",
47
- "webpack-virtual-modules": "0.6.0",
45
+ "webpack-virtual-modules": "0.6.1",
48
46
  "webpackbar": "5.0.2",
49
47
  "xml2js": "0.6.2"
50
48
  },
@@ -1,12 +1,12 @@
1
- import { Options as AssetHtmlOptions } from 'add-asset-html-webpack-plugin';
2
- import { Options as HtmlWebpackPluginOptions } from 'html-webpack-plugin';
3
- import { BundleAnalyzerPlugin } from 'webpack-bundle-analyzer';
4
1
  import WebpackBar from 'webpackbar';
5
- import DoneWebpackPlugin from '../lib/plugin/done';
2
+ import type { BundleAnalyzerOption } from './bundle-analyzer.d';
6
3
  import type { OverrideResolverOption } from '../lib/index';
4
+ import type { DonePluginOption } from '../lib/plugin/done';
7
5
  import type { MdxOptions } from '@moneko/mdx';
8
6
  import type { JsMinifyOptions, Config as SwcConfig } from '@swc/core';
7
+ import type { Options as AssetHtmlOptions } from 'add-asset-html-webpack-plugin';
9
8
  import type { CssNanoOptionsExtended } from 'css-minimizer-webpack-plugin';
9
+ import type { Options as HtmlWebpackPluginOptions } from 'html-webpack-plugin';
10
10
  import type { MinifyOptions } from 'terser';
11
11
  import type { Options } from 'ts-import-plugin';
12
12
  import type {
@@ -280,7 +280,7 @@ export declare type ConfigType<T extends 'tsc' | 'swc' = 'swc'> = {
280
280
  * openAnalyzer: false,
281
281
  * }
282
282
  */
283
- bundleAnalyzer: BundleAnalyzerPlugin.Options | false;
283
+ bundleAnalyzer: BundleAnalyzerOption | false;
284
284
  /** seo优化
285
285
  * @default false
286
286
  */
@@ -299,7 +299,7 @@ export declare type ConfigType<T extends 'tsc' | 'swc' = 'swc'> = {
299
299
  }
300
300
  | false;
301
301
  /** 📦 打包完成 */
302
- done?: ConstructorParameters<typeof DoneWebpackPlugin>[0]['done'];
302
+ done?: DonePluginOption;
303
303
  mdx?: Omit<MdxOptions, 'value' | 'filepath'>;
304
304
  jsxDomExpressions?: {
305
305
  moduleName?: string;