@moneko/core 3.0.0-beta.117 → 3.0.0-beta.119
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/common.js +1 -1
- package/lib/html-add-entry-attr.js +1 -1
- package/lib/virtual-modules.js +1 -3
- package/lib/webpack.common.js +1 -1
- package/package.json +1 -1
- package/typings/global.d.ts +11 -1
package/lib/common.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{accessSync as e,constants as t}from"fs";import{join as o}from"path";import s from"readline";import r from"chalk";import{merge as i}from"webpack-merge";import{APPTYPE as n,CUSTOMCONFIG as a,FRAMEWORK as l,PACKAGENAME as c,PROGRAMPATH as m,jsxImportSource as
|
|
1
|
+
import{accessSync as e,constants as t}from"fs";import{join as o}from"path";import s from"readline";import r from"chalk";import{merge as i}from"webpack-merge";import{APPTYPE as n,CUSTOMCONFIG as a,FRAMEWORK as l,PACKAGENAME as c,PROGRAMPATH as m,jsxImportSource as u,pkgName as p}from"./process-env.js";import{isFunction as d,readConf as h,resolveProgramPath as f}from"./utils.js";export const ENTRYPATH={mobile:"mobile",site:"site",backstage:"backstage",micro:"micro",library:"library"};let g=[`@moneko/${l}`,"neko-ui","antd","@antv","katex","font-pingfang-sc","font-pingfang-tc","react-photo-view","react-markdown-editor-lite","schema-design","@app"],x={library:{"@":f("site"),"@pkg":f("components"),[c]:f("components")},mobile:{},site:{},backstage:{},micro:{}},b={seo:!1,mode:"csr",compiler:"swc",bundleAnalyzer:!1,entry:{},minifier:{js:{},css:{}},sourceMap:{filename:"[file].map",publicPath:""},env:{},routeBaseName:"/",publicPath:"/",rem:{designSize:"mobile"===n?375:1680},fallbackCompPath:null,modifyVars:{},prefixCls:"n",alias:Object.assign({"@":f("src")},x[n]),layoutSider:{},moduleRules:[],prefixJsLoader:[],cssModules:[],importOnDemand:{},proxy:[],cacheDirectory:`${m}/node_modules/.temp_cache`,devServer:{allowedHosts:[".baidu.com"],host:"localhost",port:3e3,https:!1,compress:!1},htmlPluginOption:{template:`./node_modules/${p}/template/index.html`,favicon:`./node_modules/${p}/template/favicon.ico`,tags:[]},assetHtml:[],routerMode:"browser",fixBrowserRouter:!1,plugins:[],splitChunk:{chunks:"all",minSize:1024,minChunks:1,cacheGroups:{route:{test:/[\\/].git[\\/]router/,priority:-10,reuseExistingChunk:!0,name:"route"},example:{test:/[\\/].git[\\/]example/,priority:-10,reuseExistingChunk:!0,name:"example"}}},runtimeChunk:"single",moduleFederation:[],rulesInclude:{less:g,css:g,js:g,media:g,fonts:g},mdx:{jsxImportSource:u,useDynamicImport:!0,remarkPlugins:[],rehypePlugins:[]},jsxDomExpressions:{moduleName:"solid-js/web",builtIns:["For","Show","Switch","Match","Suspense","SuspenseList","Portal","Index","Dynamic","ErrorBoundary"],contextToCustomElements:!0,wrapConditionals:!0,generate:"dom",hydratable:!1},bar:{name:"编译中",color:"#6f42c1"},virtualModule:{},normalizeCss:!0,externalsPresets:{}};export const log=e=>{s.cursorTo(process.stdout,0),process.stdout.write(e)};let y=b,C=null,w={},k={};try{C=o(m,"./config/index.ts"),e(C,t.R_OK)}catch(e){C=null}if(C)try{let e=(await h(C,"index")).default;w=d(e)?e(process):e}catch(e){process.stdout.write(r.red(e))}if(a){let s=null;try{s=o(m,`./config/${a}.ts`),e(s,t.R_OK)}catch(e){s=null}if(null!==s)try{let e=(await h(s,a)).default;k=d(e)?e(process):e}catch(e){process.stdout.write(r.red(e))}}"tsc"===(y=i(y,w,k)).compiler&&y.minifier&&(y.minifier.js||Object.assign(y.minifier,{js:{type:"terser"}}),y.minifier.css||Object.assign(y.minifier,{css:{type:"cssnano"}})),!1===y.devtool&&(y.sourceMap=!1),!1===y.sourceMap&&(y.devtool=!1),y.fixBrowserRouter&&y.htmlPluginOption&&(y.htmlPluginOption.tags||(y.htmlPluginOption.tags=[]),y.htmlPluginOption.tags.push({textContent:'!function(n){var a=location.search.slice(1);if("/"===a[0]){for(var o=[],c=decodeURIComponent(a).split("&"),e=0,t=c.length;e<t;e++)o.push(c[e].replace(/~and~/g,"&"));var l=o.join("&");l!==a&&window.history.replaceState(null,null,"".concat(n.pathname.slice(0,-1),"?").concat(l).concat(n.hash))}}(window.location);'}));export const CONFIG=y;export const PUBLICPATH=CONFIG.publicPath||"/";export let hasCustomRouter=!1;try{e(o(CONFIG.alias["@"],"./router/index.ts"),t.R_OK),hasCustomRouter=!0}catch(e){hasCustomRouter=!1}global.NEKOCLICONFIG={CONFIG,log};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
export default class{constructor(t){this.entryMatchCallback=t}apply(t){t.hooks.compilation.tap("AddEntryAttributeWebpackPlugin",a=>{let e=t.options.plugins.map(({constructor:t})=>t).find(t=>t&&"HtmlWebpackPlugin"===t.name);if(e){let t=e.getHooks(a);t.alterAssetTagGroups.tap("AddEntryAttributeWebpackPlugin",t=>(t.headTags.forEach(t=>{"script"===t.tagName&&this.entryMatchCallback(t.attributes.src)&&(t.attributes.entry=!0)}),t))}})}};
|
package/lib/virtual-modules.js
CHANGED
|
@@ -1,3 +1 @@
|
|
|
1
|
-
import{accessSync as o,constants as
|
|
2
|
-
${a.rem?.designSize?t:""}
|
|
3
|
-
await import('@moneko/${l}/lib/entry.js');`};a.fallbackCompPath&&Object.assign(i,{"@app/fallback":`import Fallback from "${a.fallbackCompPath}";export default Fallback;`});let c={};try{let r=m(s("site"),"./mdx-scope.ts");o(r,p.R_OK),c='import scope from "@/mdx-scope";export default scope;'}catch(o){c={}}Object.assign(i,{"@app/mdx-scope":c});export default i;
|
|
1
|
+
import{accessSync as o,constants as t}from"fs";import{join as p}from"path";import m from"./app.js";import a from"./common/rem.js";import{CONFIG as r}from"./common.js";import{coverage as e}from"./coverage.js";import{FRAMEWORK as i,isMicro as l}from"./process-env.js";import{resolveProgramPath as s}from"./utils.js";let c=r.rem?.designSize?a:"",n=`await import('@moneko/${i}/lib/entry.js');`;l&&(c+="if (window.__POWERED_BY_QIANKUN__) {__webpack_public_path__ = window.__INJECTED_PUBLIC_PATH_BY_QIANKUN__;}",n=`const { bootstrap, mount, unmount } = await import('@moneko/${i}/lib/entry.js');export { bootstrap, mount, unmount };`);let _={...r.virtualModule,"@app":m,"@app/fallback":"export default null","@app/coverage":e,"@app/entry":`${r.normalizeCss?`import "@moneko/${i}/lib/normalize.css";`:""}${c}${n}`};r.fallbackCompPath&&Object.assign(_,{"@app/fallback":`import Fallback from "${r.fallbackCompPath}";export default Fallback;`});let f={};try{let m=p(s("site"),"./mdx-scope.ts");o(m,t.R_OK),f='import scope from "@/mdx-scope";export default scope;'}catch(o){f={}}Object.assign(_,{"@app/mdx-scope":f});export default _;
|
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 o from"webpack";import l from"webpackbar";import"./cleanup.js";import{CONFIG as n,PUBLICPATH as r}from"./common.js";import i from"./define.js";import a from"./done.js";import p from"./html-add-entry-attr.js";import m from"./html-plugin-option.js";import{moduleFederation as c}from"./module-federation.js";import u from"./module.config.js";import{CUSTOMCONFIG as f,DEV as
|
|
1
|
+
import e from"fs";import t from"add-asset-html-webpack-plugin";import s from"html-webpack-plugin";import o from"webpack";import l from"webpackbar";import"./cleanup.js";import{CONFIG as n,PUBLICPATH as r}from"./common.js";import i from"./define.js";import a from"./done.js";import p from"./html-add-entry-attr.js";import m from"./html-plugin-option.js";import{moduleFederation as c}from"./module-federation.js";import u from"./module.config.js";import{CUSTOMCONFIG as f,DEV as d,PACKAGENAME as h,PROGRAMPATH as j,hasEslintConfig as y,hasStylelintConfig as g,isLibrary as w,isMicro as b}from"./process-env.js";import{seo as x}from"./seo.js";import{resolveNodeModulesPath as k,resolveProgramPath as v}from"./utils.js";import C from"./virtual-module-plugin.js";import $ from"./virtual-modules.js";let{AutomaticPrefetchPlugin:O,DefinePlugin:B,SourceMapDevToolPlugin:P,WatchIgnorePlugin:A}=o,M=[".eslintrc.js",".eslintrc.json",".eslintrc.yaml",".eslintrc.json"],S=[".stylelintrc",".stylelintrc.json",".stylelintrc.yaml",".stylelintrc.yml",".stylelintrc.js","stylelint.config.js","stylelint.config.cjs"],T=e.readdirSync(j),D=!1,K=!1;for(let e=0,t=T.length;e<t;e++)S.includes(T[e])&&(K=!0),M.includes(T[e])&&(D=!0);D||(D=y),K||(K=g);let L=K?(await import("stylelint-webpack-plugin")).default:null,F=D?(await import("eslint-webpack-plugin")).default:null,R=n.assetHtml.map(e=>({publicPath:"",...e}));export const outputConfig={path:v(w?"docs":"dist"),filename:"js/[name].bundle.js",chunkFilename:"js/[chunkhash].js",assetModuleFilename:"assets/[hash][ext][query]",library:{name:h,type:"window"},globalObject:"window",chunkLoadingGlobal:`webpackJsonp_${h}`,pathinfo:d,clean:!0,publicPath:r,asyncChunks:!0};let W={main:k("@app/entry")};n.entry&&("string"==typeof n.entry?W=n.entry:Object.keys(n.entry)&&Object.assign(W,n.entry)),n.output&&("string"==typeof n.output?outputConfig.path=n.output:Object.keys(n.output)&&Object.assign(outputConfig,n.output));let _=n.routeBaseName.split("/").filter(Boolean).length,q=`${Array(_).fill("..").join("/")+(_?"/":"")}404.html`,{pathSegmentsToKeep:G=_,path:H=q}=n.fixBrowserRouter||{},J=!1;n.cacheDirectory&&(J={type:"filesystem",allowCollectingMemory:!0,cacheDirectory:n.cacheDirectory,memoryCacheUnaffected:!0,name:`${f||"default"}-${d?"development":"production"}`});export const clientConfig={entry:W,stats:"errors-only",cache:J,infrastructureLogging:{level:"none"},target:"web",externalsPresets:n.externalsPresets,plugins:[new O,...c,F&&new F({fix:!0,threads:!0,extensions:["js","md","mdx","cjs","ejs","mjs","jsx","ts","tsx","json","html","coffee","vue"]}),L&&new L({fix:!0,threads:!0,extensions:["css","scss","sass","less","ts","tsx","js","jsx"],exclude:["node_modules/","es/","lib/","docs/","coverage/","dist/"]}),n.htmlPluginOption&&new s(m),n.fixBrowserRouter&&new s({filename:H,inject:!1,templateContent:()=>`<html html><head><title>${m.title}</title><script>var pathSegmentsToKeep = ${G||_};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),b&&new p(e=>!!(e.match(/main\.(.*)\.bundle.js$/)||e.match("main.bundle.js"))),new B(i),new A({paths:[/\.d\.ts$/]}),n.sourceMap&&new P(n.sourceMap),n.bar&&new l(n.bar),new a({done:()=>{!d&&n.seo&&x(),n.done?.(),d||setTimeout(()=>{process.exit(0)},2e3)}}),new C($),...n.plugins].filter(Boolean),experiments:{topLevelAwait:!0,syncWebAssembly:!0,asyncWebAssembly:!0},resolve:{extensions:[".tsx",".ts",".js",".jsx"],alias:n.alias,fallback:{path:!1,fs:!1,crypto:!1,assert:!1}},module:u,externals:n.externals,output:outputConfig};
|
package/package.json
CHANGED
package/typings/global.d.ts
CHANGED
|
@@ -242,7 +242,17 @@ export declare type ConfigType<T extends 'tsc' | 'swc' = 'swc'> = {
|
|
|
242
242
|
media?: string[];
|
|
243
243
|
fonts?: string[];
|
|
244
244
|
};
|
|
245
|
-
|
|
245
|
+
/** bundle分析
|
|
246
|
+
* @default false
|
|
247
|
+
* @example
|
|
248
|
+
* // 推荐
|
|
249
|
+
* {
|
|
250
|
+
* analyzerMode: 'static',
|
|
251
|
+
* reportFilename: 'report.html',
|
|
252
|
+
* openAnalyzer: false,
|
|
253
|
+
* }
|
|
254
|
+
*/
|
|
255
|
+
bundleAnalyzer: BundleAnalyzerPlugin.Options | false;
|
|
246
256
|
/** seo优化
|
|
247
257
|
* @default false
|
|
248
258
|
*/
|