@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.
- package/lib/html-add-entry-attr.d.ts +2 -2
- package/lib/module-federation.d.ts +3 -1
- package/lib/module-federation.js +1 -1
- package/lib/webpack.common.js +1 -1
- package/lib/webpack.dev.d.ts +2 -2
- package/lib/webpack.dev.js +3 -3
- package/lib/webpack.prod.d.ts +2 -2
- package/lib/webpack.prod.js +1 -1
- package/package.json +2 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
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
|
|
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 {};
|
package/lib/module-federation.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"external-remotes-plugin";import
|
|
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])})));
|
package/lib/webpack.common.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"fs";import t from"add-asset-html-webpack-plugin";import s from"html-webpack-plugin";import
|
|
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;
|
package/lib/webpack.dev.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import
|
|
2
|
-
declare const _default: Configuration;
|
|
1
|
+
import webpack from 'webpack';
|
|
2
|
+
declare const _default: webpack.Configuration;
|
|
3
3
|
export default _default;
|
package/lib/webpack.dev.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import e from"@soda/friendly-errors-webpack-plugin";import o from"chalk";import
|
|
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(`${
|
|
4
|
-
Network: ${o.cyan(`${
|
|
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)});
|
package/lib/webpack.prod.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import
|
|
2
|
-
declare const _default: Configuration;
|
|
1
|
+
import webpack from 'webpack';
|
|
2
|
+
declare const _default: webpack.Configuration;
|
|
3
3
|
export default _default;
|
package/lib/webpack.prod.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"css-minimizer-webpack-plugin";import i from"mini-css-extract-plugin";import n from"terser-webpack-plugin";import
|
|
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.
|
|
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.
|
|
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",
|