@moneko/core 3.0.0-beta.90 → 3.0.0-beta.91

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 webpack from 'webpack';
2
2
  /**
3
3
  * 向 html-webpack-plugin 导出的 HTML 模板 script 添加属性
4
4
  * ```javascript
@@ -12,6 +12,6 @@ import { Compiler } from 'webpack';
12
12
  declare class AddEntryAttributeWebpackPlugin {
13
13
  private readonly entryMatchCallback;
14
14
  constructor(matchCallback: (src: string) => boolean);
15
- apply(compiler: Compiler): void;
15
+ apply(compiler: webpack.Compiler): void;
16
16
  }
17
17
  export default AddEntryAttributeWebpackPlugin;
@@ -1,3 +1,5 @@
1
- import { NormalModuleReplacementPlugin } from 'webpack';
1
+ import webpack from 'webpack';
2
2
  import ModuleFederationPlugin from 'webpack/lib/container/ModuleFederationPlugin.js';
3
+ declare const NormalModuleReplacementPlugin: typeof webpack.NormalModuleReplacementPlugin;
3
4
  export declare const moduleFederation: (typeof ModuleFederationPlugin | typeof NormalModuleReplacementPlugin)[];
5
+ export {};
@@ -1 +1 @@
1
- import e from"external-remotes-plugin";import{NormalModuleReplacementPlugin as r}from"webpack";import t from"webpack/lib/container/ModuleFederationPlugin.js";import{CONFIG as o}from"./common.js";import{resolve as i}from"./utils.js";let s={},a={},l={};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,i=t.filename||"remote_entry.js";if(l[o]=`${t.name}@${t.host}/${i}`,Array.isArray(t.library))for(let e=0,r=t.library.length;e<r;e++)s[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?a[`./${t}`]=i(t):"[object Object]"===Object.prototype.toString.call(t)&&(a[`./${t.name}`]=i(t.path))}return new t({filename:"remote_entry.js",...e,remotes:l,exposes:a})});moduleFederation.length&&(moduleFederation.push(new e),moduleFederation.push(new r(/(.*)/,e=>{s[e.request]&&(e.request=s[e.request])})));
1
+ import e from"external-remotes-plugin";import r from"webpack";import t from"webpack/lib/container/ModuleFederationPlugin.js";import{CONFIG as o}from"./common.js";import{resolve as l}from"./utils.js";let a=r.NormalModuleReplacementPlugin,i={},m={},n={};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(n[o]=`${t.name}@${t.host}/${l}`,Array.isArray(t.library))for(let e=0,r=t.library.length;e<r;e++)i[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?m[`./${t}`]=l(t):"[object Object]"===Object.prototype.toString.call(t)&&(m[`./${t.name}`]=l(t.path))}return new t({filename:"remote_entry.js",...e,remotes:n,exposes:m})});moduleFederation.length&&(moduleFederation.push(new e),moduleFederation.push(new a(/(.*)/,e=>{i[e.request]&&(e.request=i[e.request])})));
@@ -1 +1 @@
1
- import e from"fs";import t from"add-asset-html-webpack-plugin";import s from"html-webpack-plugin";import{AutomaticPrefetchPlugin as o,DefinePlugin as n,SourceMapDevToolPlugin as l,WatchIgnorePlugin as i}from"webpack";import a from"webpackbar";import"./cleanup.js";import{CONFIG as r,ENTRYPATH as p,PUBLICPATH as m}from"./common.js";import c from"./define.js";import"./docs.js";import u from"./done.js";import d from"./html-add-entry-attr.js";import f from"./html-plugin-option.js";import{moduleFederation as j}from"./module-federation.js";import g from"./module.config.js";import{APPTYPE as h,DEV as b,FRAMEWORK as y,PACKAGENAME as w,PROGRAMPATH as x,hasEslintConfig as k,hasStylelintConfig as v}from"./process-env.js";import"./routes.js";import{seo as O}from"./seo.js";import{resolveNodeModulesPath as C,resolveProgramPath as $}from"./utils.js";import B from"./virtual-module-plugin.js";import A from"./virtual-modules.js";let S=[".eslintrc.js",".eslintrc.json",".eslintrc.yaml",".eslintrc.json"],T=[".stylelintrc",".stylelintrc.json",".stylelintrc.yaml",".stylelintrc.yml",".stylelintrc.js","stylelint.config.js","stylelint.config.cjs"],K=e.readdirSync(x),L=!1,M=!1;for(let e=0,t=K.length;e<t;e++)T.includes(K[e])&&(M=!0),S.includes(K[e])&&(L=!0);L||(L=k),M||(M=v);let P=M?(await import("stylelint-webpack-plugin")).default:null,F=L?(await import("eslint-webpack-plugin")).default:null;export const alias={"@":$("src")};Object.assign(alias,r.alias),"library"===h&&Object.assign(alias,{"@":$("site"),"@pkg":$("components"),[w]:$("components")});let N=r.assetHtml.map(e=>({publicPath:"",...e}));export const outputConfig={path:$("library"===h?"docs":"dist"),filename:"js/[name].bundle.js",chunkFilename:"js/[name].chunk.js",assetModuleFilename:"assets/[name][hash][ext][query]",library:{name:w,type:"window"},globalObject:"window",chunkLoadingGlobal:`webpackJsonp_${w}`,pathinfo:b,clean:!0,publicPath:m};let R=C(`@moneko/${y}/lib/packages/${p[h]}/index.js`);"single-component"===h&&(Object.assign(alias,{[w]:$("umd")}),R=$(b?"example/index.ts":"src/index.ts"),outputConfig.path=$(b?"dist":"umd"),outputConfig.filename="index.js",outputConfig.globalObject="this",outputConfig.library={export:"default",name:w,type:"umd",umdNamedDefine:!0});let W={main:R};r.entry&&("string"==typeof r.entry?W=r.entry:Object.keys(r.entry)&&Object.assign(W,r.entry)),r.output&&("string"==typeof r.output?outputConfig.path=r.output:Object.keys(r.output)&&Object.assign(outputConfig,r.output));let _=r.routeBaseName.split("/").filter(Boolean).length,q=`${Array(_).fill("..").join("/")+(_?"/":"")}404.html`,{pathSegmentsToKeep:D=_,path:G=q}=r.fixBrowserRouter||{},H={entry:W,stats:"errors-only",infrastructureLogging:{level:"none"},target:"web",plugins:[new o,...j,F&&new F({fix:!0,threads:!0,extensions:["js","md","mdx","cjs","ejs","mjs","jsx","ts","tsx","json","html","coffee","vue"]}),P&&new P({fix:!0,threads:!0,extensions:["css","scss","sass","less","ts","tsx","js","jsx"],exclude:["node_modules/","es/","lib/","docs/","coverage/","dist/"]}),r.htmlPluginOption&&new s(f),r.fixBrowserRouter&&new s({filename:G,inject:!1,templateContent:()=>`<html html><head><title>${f.title}</title><script>var pathSegmentsToKeep = ${D||_};var l = window.location;l.replace(l.protocol + '//' + l.hostname + (l.port ? ':' + l.port : '') + l.pathname.split('/').slice(0, 1 + pathSegmentsToKeep).join('/') + '/?/' + l.pathname.slice(1).split('/').slice(pathSegmentsToKeep).join('/').replace(/&/g, '~and~') + (l.search ? '&' + l.search.slice(1).replace(/&/g, '~and~') : '') + l.hash);</script></head><body></body></html>`}),new t(N),"single-spa"===h&&new d(e=>!!(e.match(/main\.(.*)\.bundle.js$/)||e.match("main.bundle.js"))),new n(c),new i({paths:[/\.d\.ts$/]}),r.sourceMap&&new l(r.sourceMap),r.bar&&new a(r.bar),new u({done:()=>{!b&&r.seo&&O(),r.done?.(),b||setTimeout(()=>{process.exit(0)},2e3)}}),new B(A),...r.plugins].filter(Boolean),experiments:{topLevelAwait:!0,syncWebAssembly:!0,asyncWebAssembly:!0},resolve:{extensions:[".tsx",".ts",".js",".jsx"],alias:alias,fallback:{path:!1,fs:!1,crypto:!1,assert:!1}},module:g,externals:r.externals,output:outputConfig};export default H;
1
+ import e from"fs";import t from"add-asset-html-webpack-plugin";import s from"html-webpack-plugin";import o from"webpack";import n from"webpackbar";import"./cleanup.js";import{CONFIG as l,ENTRYPATH as i,PUBLICPATH as a}from"./common.js";import r from"./define.js";import"./docs.js";import p from"./done.js";import m from"./html-add-entry-attr.js";import c from"./html-plugin-option.js";import{moduleFederation as u}from"./module-federation.js";import d from"./module.config.js";import{APPTYPE as f,DEV as j,FRAMEWORK as g,PACKAGENAME as h,PROGRAMPATH as b,hasEslintConfig as y,hasStylelintConfig as w}from"./process-env.js";import"./routes.js";import{seo as x}from"./seo.js";import{resolveNodeModulesPath as k,resolveProgramPath as v}from"./utils.js";import O from"./virtual-module-plugin.js";import C from"./virtual-modules.js";let{AutomaticPrefetchPlugin:$,DefinePlugin:B,SourceMapDevToolPlugin:A,WatchIgnorePlugin:S}=o,T=[".eslintrc.js",".eslintrc.json",".eslintrc.yaml",".eslintrc.json"],K=[".stylelintrc",".stylelintrc.json",".stylelintrc.yaml",".stylelintrc.yml",".stylelintrc.js","stylelint.config.js","stylelint.config.cjs"],L=e.readdirSync(b),M=!1,P=!1;for(let e=0,t=L.length;e<t;e++)K.includes(L[e])&&(P=!0),T.includes(L[e])&&(M=!0);M||(M=y),P||(P=w);let F=P?(await import("stylelint-webpack-plugin")).default:null,N=M?(await import("eslint-webpack-plugin")).default:null;export const alias={"@":v("src")};Object.assign(alias,l.alias),"library"===f&&Object.assign(alias,{"@":v("site"),"@pkg":v("components"),[h]:v("components")});let R=l.assetHtml.map(e=>({publicPath:"",...e}));export const outputConfig={path:v("library"===f?"docs":"dist"),filename:"js/[name].bundle.js",chunkFilename:"js/[name].chunk.js",assetModuleFilename:"assets/[name][hash][ext][query]",library:{name:h,type:"window"},globalObject:"window",chunkLoadingGlobal:`webpackJsonp_${h}`,pathinfo:j,clean:!0,publicPath:a};let W=k(`@moneko/${g}/lib/packages/${i[f]}/index.js`);"single-component"===f&&(Object.assign(alias,{[h]:v("umd")}),W=v(j?"example/index.ts":"src/index.ts"),outputConfig.path=v(j?"dist":"umd"),outputConfig.filename="index.js",outputConfig.globalObject="this",outputConfig.library={export:"default",name:h,type:"umd",umdNamedDefine:!0});let _={main:W};l.entry&&("string"==typeof l.entry?_=l.entry:Object.keys(l.entry)&&Object.assign(_,l.entry)),l.output&&("string"==typeof l.output?outputConfig.path=l.output:Object.keys(l.output)&&Object.assign(outputConfig,l.output));let q=l.routeBaseName.split("/").filter(Boolean).length,D=`${Array(q).fill("..").join("/")+(q?"/":"")}404.html`,{pathSegmentsToKeep:G=q,path:H=D}=l.fixBrowserRouter||{},J={entry:_,stats:"errors-only",infrastructureLogging:{level:"none"},target:"web",plugins:[new $,...u,N&&new N({fix:!0,threads:!0,extensions:["js","md","mdx","cjs","ejs","mjs","jsx","ts","tsx","json","html","coffee","vue"]}),F&&new F({fix:!0,threads:!0,extensions:["css","scss","sass","less","ts","tsx","js","jsx"],exclude:["node_modules/","es/","lib/","docs/","coverage/","dist/"]}),l.htmlPluginOption&&new s(c),l.fixBrowserRouter&&new s({filename:H,inject:!1,templateContent:()=>`<html html><head><title>${c.title}</title><script>var pathSegmentsToKeep = ${G||q};var l = window.location;l.replace(l.protocol + '//' + l.hostname + (l.port ? ':' + l.port : '') + l.pathname.split('/').slice(0, 1 + pathSegmentsToKeep).join('/') + '/?/' + l.pathname.slice(1).split('/').slice(pathSegmentsToKeep).join('/').replace(/&/g, '~and~') + (l.search ? '&' + l.search.slice(1).replace(/&/g, '~and~') : '') + l.hash);</script></head><body></body></html>`}),new t(R),"single-spa"===f&&new m(e=>!!(e.match(/main\.(.*)\.bundle.js$/)||e.match("main.bundle.js"))),new B(r),new S({paths:[/\.d\.ts$/]}),l.sourceMap&&new A(l.sourceMap),l.bar&&new n(l.bar),new p({done:()=>{!j&&l.seo&&x(),l.done?.(),j||setTimeout(()=>{process.exit(0)},2e3)}}),new O(C),...l.plugins].filter(Boolean),experiments:{topLevelAwait:!0,syncWebAssembly:!0,asyncWebAssembly:!0},resolve:{extensions:[".tsx",".ts",".js",".jsx"],alias:alias,fallback:{path:!1,fs:!1,crypto:!1,assert:!1}},module:d,externals:l.externals,output:outputConfig};export default J;
@@ -1,3 +1,3 @@
1
- import { type Configuration } from 'webpack';
2
- declare const _default: Configuration;
1
+ import webpack from 'webpack';
2
+ declare const _default: webpack.Configuration;
3
3
  export default _default;
@@ -1,4 +1,4 @@
1
- import e from"@soda/friendly-errors-webpack-plugin";import o from"chalk";import{HotModuleReplacementPlugin as r}from"webpack";import{merge as t}from"webpack-merge";import{CONFIG as s}from"./common.js";import{hasPkg as a}from"./has-pkg.js";import{getIPv4 as p,getPort as i}from"./net.js";import{CUSTOMCONFIG as m,isReact as l}from"./process-env.js";import{isFunction as n,resolveProgramPath as c}from"./utils.js";import d from"./webpack.common.js";let{yellow:v,green:h}=o,f=p(),w=s.devServer.port||3e3,u=await i(w,65535,s.devServer.host),g=s.devServer.port!==u,k=a("@moneko/mock"),y=k&&await import("@moneko/mock"),$=l&&(await import("@pmmmwh/react-refresh-webpack-plugin")).default,S=!1;s.cacheDirectory&&(S={type:"filesystem",allowCollectingMemory:!0,cacheDirectory:s.cacheDirectory,name:`${m||"default"}-development`});let b=!1===s.devtool||s.devtool?s.devtool:"eval-cheap-module-source-map";s.devServer.port=u;let j="/"===s.routeBaseName,x=s.devServer.https?"https:":"http:",D=j?"":s.routeBaseName;export default t(d,{devtool:b,mode:"development",cache:S,devServer:{headers:{"Access-Control-Allow-Origin":"*"},compress:s.devServer.compress,host:"0.0.0.0",port:u,historyApiFallback:j||{index:D.endsWith("/")?D:`${D}/`,disableDotRule:!0},https:s.devServer.https,proxy:s.proxy,allowedHosts:s.devServer.allowedHosts,client:{progress:!1,logging:"info",overlay:!1},static:{watch:{ignored:e=>e.endsWith(".d.ts")||/\/node_modules\//.test(e)}},setupMiddlewares:(e,o)=>{if(!o)throw Error("webpack-dev-server is not defined");return o.app&&n(y)&&y(o.app,c("mock/")),e},open:!1,hot:!0},plugins:[new r,$&&new $,new e({compilationSuccessInfo:{messages:[`You application is running here:
1
+ import e from"@soda/friendly-errors-webpack-plugin";import o from"chalk";import r from"webpack";import{merge as t}from"webpack-merge";import{CONFIG as s}from"./common.js";import{hasPkg as a}from"./has-pkg.js";import{getIPv4 as p,getPort as i}from"./net.js";import{CUSTOMCONFIG as m,isReact as l}from"./process-env.js";import{isFunction as n,resolveProgramPath as c}from"./utils.js";import d from"./webpack.common.js";let{HotModuleReplacementPlugin:v}=r,{yellow:h,green:f}=o,w=p(),u=s.devServer.port||3e3,g=await i(u,65535,s.devServer.host),k=s.devServer.port!==g,y=a("@moneko/mock"),$=y&&await import("@moneko/mock"),S=l&&(await import("@pmmmwh/react-refresh-webpack-plugin")).default,b=!1;s.cacheDirectory&&(b={type:"filesystem",allowCollectingMemory:!0,cacheDirectory:s.cacheDirectory,name:`${m||"default"}-development`});let j=!1===s.devtool||s.devtool?s.devtool:"eval-cheap-module-source-map";s.devServer.port=g;let x="/"===s.routeBaseName,D=s.devServer.https?"https:":"http:",A=x?"":s.routeBaseName;export default t(d,{devtool:j,mode:"development",cache:b,devServer:{headers:{"Access-Control-Allow-Origin":"*"},compress:s.devServer.compress,host:"0.0.0.0",port:g,historyApiFallback:x||{index:A.endsWith("/")?A:`${A}/`,disableDotRule:!0},https:s.devServer.https,proxy:s.proxy,allowedHosts:s.devServer.allowedHosts,client:{progress:!1,logging:"info",overlay:!1},static:{watch:{ignored:e=>e.endsWith(".d.ts")||/\/node_modules\//.test(e)}},setupMiddlewares:(e,o)=>{if(!o)throw Error("webpack-dev-server is not defined");return o.app&&n($)&&$(o.app,c("mock/")),e},open:!1,hot:!0},plugins:[new v,S&&new S,new e({compilationSuccessInfo:{messages:[`You application is running here:
2
2
 
3
- Local: ${o.cyan(`${x}//${s.devServer.host}:${u}${D}`)}
4
- Network: ${o.cyan(`${x}//${f}:${u}${D}`)}`],notes:g?[`Port ${v(w)} is in use, trying ${h(u)} instead`]:[]},clearConsole:!0})].filter(Boolean)});
3
+ Local: ${o.cyan(`${D}//${s.devServer.host}:${g}${A}`)}
4
+ Network: ${o.cyan(`${D}//${w}:${g}${A}`)}`],notes:k?[`Port ${h(u)} is in use, trying ${f(g)} instead`]:[]},clearConsole:!0})].filter(Boolean)});
@@ -1,3 +1,3 @@
1
- import { type Configuration } from 'webpack';
2
- declare const _default: Configuration;
1
+ import webpack from 'webpack';
2
+ declare const _default: webpack.Configuration;
3
3
  export default _default;
@@ -1 +1 @@
1
- import e from"css-minimizer-webpack-plugin";import i from"mini-css-extract-plugin";import n from"terser-webpack-plugin";import{optimize as m}from"webpack";import{BundleAnalyzerPlugin as o}from"webpack-bundle-analyzer";import{merge as r}from"webpack-merge";import{CONFIG as s}from"./common.js";import{getMinifyOption as t}from"./minify.js";import{CUSTOMCONFIG as c}from"./process-env.js";import l from"./webpack.common.js";let{cssnanoMinify:p,swcMinify:a}=e,u="swc"===s.compiler?"swc":"terser",f="swc"===s.compiler?"swc":"cssnano",d=[];s.minifier&&(s.minifier.js&&d.push(new n(t(s.minifier.js?.type||u,s.minifier.js?.options))),s.minifier.css&&d.push(new e({minify:{swc:a,cssnano:p}[s.minifier.css?.type||f],minimizerOptions:s.minifier.css?.options})));let h={splitChunks:s.splitChunk,runtimeChunk:s.runtimeChunk,chunkIds:"named",moduleIds:"named",removeAvailableModules:!0,removeEmptyChunks:!0,mergeDuplicateChunks:!0,minimize:!0,minimizer:d},k=!1;s.cacheDirectory&&(k={type:"filesystem",allowCollectingMemory:!0,cacheDirectory:s.cacheDirectory,name:`${c||"default"}-production`});export default r(l,{devtool:!1===s.devtool||s.devtool?s.devtool:"cheap-module-source-map",mode:"production",cache:k,optimization:h,plugins:[new i({filename:"style/[name].bundle.css",chunkFilename:"style/[name].chunk.css",experimentalUseImportModule:!0}),s.bundleAnalyzer&&new o(s.bundleAnalyzer),s.splitChunk&&new m.MinChunkSizePlugin({minChunkSize:1e4})].filter(Boolean)});
1
+ import e from"css-minimizer-webpack-plugin";import i from"mini-css-extract-plugin";import n from"terser-webpack-plugin";import m from"webpack";import{BundleAnalyzerPlugin as o}from"webpack-bundle-analyzer";import{merge as r}from"webpack-merge";import{CONFIG as s}from"./common.js";import{getMinifyOption as t}from"./minify.js";import{CUSTOMCONFIG as c}from"./process-env.js";import l from"./webpack.common.js";let{optimize:p}=m,{cssnanoMinify:a,swcMinify:u}=e,f="swc"===s.compiler?"swc":"terser",d="swc"===s.compiler?"swc":"cssnano",h=[];s.minifier&&(s.minifier.js&&h.push(new n(t(s.minifier.js?.type||f,s.minifier.js?.options))),s.minifier.css&&h.push(new e({minify:{swc:u,cssnano:a}[s.minifier.css?.type||d],minimizerOptions:s.minifier.css?.options})));let k={splitChunks:s.splitChunk,runtimeChunk:s.runtimeChunk,chunkIds:"named",moduleIds:"named",removeAvailableModules:!0,removeEmptyChunks:!0,mergeDuplicateChunks:!0,minimize:!0,minimizer:h},w=!1;s.cacheDirectory&&(w={type:"filesystem",allowCollectingMemory:!0,cacheDirectory:s.cacheDirectory,name:`${c||"default"}-production`});export default r(l,{devtool:!1===s.devtool||s.devtool?s.devtool:"cheap-module-source-map",mode:"production",cache:w,optimization:k,plugins:[new i({filename:"style/[name].bundle.css",chunkFilename:"style/[name].chunk.css",experimentalUseImportModule:!0}),s.bundleAnalyzer&&new o(s.bundleAnalyzer),s.splitChunk&&new p.MinChunkSizePlugin({minChunkSize:1e4})].filter(Boolean)});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moneko/core",
3
- "version": "3.0.0-beta.90",
3
+ "version": "3.0.0-beta.91",
4
4
  "description": "core",
5
5
  "main": "lib/index.js",
6
6
  "type": "module",
@@ -38,7 +38,7 @@
38
38
  "ts-import-plugin": "3.0.0",
39
39
  "ts-loader": "9.4.4",
40
40
  "typescript": "5.0.4",
41
- "webpack": "5.88.2",
41
+ "webpack": "5.88.1",
42
42
  "webpack-bundle-analyzer": "4.9.0",
43
43
  "webpack-cli": "5.1.4",
44
44
  "webpack-dev-server": "4.15.1",