@moneko/core 3.0.0-beta.111 → 3.0.0-beta.113

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 CHANGED
@@ -1,4 +1,4 @@
1
- import{accessSync as e,constants as t}from"fs";import{join as o}from"path";import s from"readline";import i from"chalk";import{merge as r}from"webpack-merge";import{APPTYPE as n,CUSTOMCONFIG as l,FRAMEWORK as a,PACKAGENAME as c,PROGRAMPATH as m,jsxImportSource as p,pkgName as u}from"./process-env.js";import{isFunction as d,readConf as h,resolveProgramPath as g}from"./utils.js";export const ENTRYPATH={mobile:"mobile",site:"site","back-stage":"back-stage","single-spa":"single-spa",library:"library","single-component":"single-component"};let f=[`@moneko/${a}`,"neko-ui","antd","@antv","katex","font-pingfang-sc","font-pingfang-tc","react-photo-view","react-markdown-editor-lite","schema-design","@app"],x={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"}}};"single-component"===n&&(x=!1);let b={library:{"@":g("site"),"@pkg":g("components"),[c]:g("components")},"single-component":{[c]:g("umd")},mobile:{},site:{},"back-stage":{},"single-spa":{}},y={seo:!1,mode:"csr",compiler:"swc",bundleAnalyzer:{analyzerMode:"static",reportFilename:"report.html",openAnalyzer:!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({"@":g("src")},b[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/${u}/template/index.html`,favicon:`./node_modules/${u}/template/favicon.ico`,tags:[]},assetHtml:[],routerMode:"browser",fixBrowserRouter:!1,plugins:[],splitChunk:x,runtimeChunk:"single-component"!==n&&"single",moduleFederation:[],rulesInclude:{less:f,css:f,js:f,media:f,fonts:f},mdx:{jsxImportSource:p,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 w=y,C=null,k={},O={};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;k=d(e)?e(process):e}catch(e){process.stdout.write(i.red(e))}if(l){let s=null;try{s=o(m,`./config/${l}.ts`),e(s,t.R_OK)}catch(e){s=null}if(null!==s)try{let e=(await h(s,l)).default;O=d(e)?e(process):e}catch(e){process.stdout.write(i.red(e))}}"tsc"===(w=r(w,k,O)).compiler&&w.minifier&&(w.minifier.js||Object.assign(w.minifier,{js:{type:"terser"}}),w.minifier.css||Object.assign(w.minifier,{css:{type:"cssnano"}})),!1===w.devtool&&(w.sourceMap=!1),!1===w.sourceMap&&(w.devtool=!1),w.fixBrowserRouter&&w.htmlPluginOption&&(w.htmlPluginOption.tags||(w.htmlPluginOption.tags=[]),w.htmlPluginOption.tags.push({textContent:`
1
+ import{accessSync as e,constants as t}from"fs";import{join as o}from"path";import s from"readline";import i from"chalk";import{merge as r}from"webpack-merge";import{APPTYPE as n,CUSTOMCONFIG as l,FRAMEWORK as a,PACKAGENAME as c,PROGRAMPATH as m,jsxImportSource as p,pkgName as u}from"./process-env.js";import{isFunction as d,readConf as h,resolveProgramPath as g}from"./utils.js";export const ENTRYPATH={mobile:"mobile",site:"site","back-stage":"back-stage","single-spa":"single-spa",library:"library","single-component":"single-component"};let f=[`@moneko/${a}`,"neko-ui","antd","@antv","katex","font-pingfang-sc","font-pingfang-tc","react-photo-view","react-markdown-editor-lite","schema-design","@app"],x={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"}}};"single-component"===n&&(x=!1);let b={library:{"@":g("site"),"@pkg":g("components"),[c]:g("components")},"single-component":{[c]:g("umd")},mobile:{},site:{},"back-stage":{},"single-spa":{}},y={seo:!1,mode:"csr",compiler:"swc",bundleAnalyzer:{analyzerMode:"static",reportFilename:"report.html",openAnalyzer:!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({"@":g("src")},b[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/${u}/template/index.html`,favicon:`./node_modules/${u}/template/favicon.ico`,tags:[]},assetHtml:[],routerMode:"browser",fixBrowserRouter:!1,plugins:[],splitChunk:x,runtimeChunk:"single",moduleFederation:[],rulesInclude:{less:f,css:f,js:f,media:f,fonts:f},mdx:{jsxImportSource:p,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 w=y,C=null,k={},O={};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;k=d(e)?e(process):e}catch(e){process.stdout.write(i.red(e))}if(l){let s=null;try{s=o(m,`./config/${l}.ts`),e(s,t.R_OK)}catch(e){s=null}if(null!==s)try{let e=(await h(s,l)).default;O=d(e)?e(process):e}catch(e){process.stdout.write(i.red(e))}}"tsc"===(w=r(w,k,O)).compiler&&w.minifier&&(w.minifier.js||Object.assign(w.minifier,{js:{type:"terser"}}),w.minifier.css||Object.assign(w.minifier,{css:{type:"cssnano"}})),!1===w.devtool&&(w.sourceMap=!1),!1===w.sourceMap&&(w.devtool=!1),w.fixBrowserRouter&&w.htmlPluginOption&&(w.htmlPluginOption.tags||(w.htmlPluginOption.tags=[]),w.htmlPluginOption.tags.push({textContent:`
2
2
  (function(l) {
3
3
  if (l.search[1] === '/' ) {
4
4
  var decoded = l.search.slice(1).split('&').map(function(s) {
@@ -1 +1 @@
1
- import{resolve as e}from"path";import s from"mini-css-extract-plugin";import o from"mini-svg-data-uri";import{CONFIG as t,PUBLICPATH as r}from"./common.js";import{hasPkg as l}from"./has-pkg.js";import a from"./modifyVars.js";import{APPTYPE as n,DEV as i,FRAMEWORK as c,__dirname as m}from"./process-env.js";import p from"./swcrc.js";import d from"./tsloader.config.js";import{resolveNodeModulesPath as u,resolveProgramPath as f}from"./utils.js";let y="single-spa"===n?r:"../",x={loader:s.loader,options:{publicPath:"/"!==y?y:"../"}},g=l("@moneko/postcss")&&{loader:"postcss-loader",options:{postcssOptions:await import("@moneko/postcss")}};i&&(x="style-loader");let $=[...t.cssModules,`@moneko/${c}`,"neko-ui"].map(u),j=[...["src/styles/variables/*.less","src/styles/mixins/*.less","site/styles/variables/*.less","site/styles/mixins/*.less"].map(f)],v=["components","example","mock","site","src","server"].map(f),b=[x,{loader:"@teamsupercell/typings-for-css-modules-loader",options:{verifyOnly:!i}},{loader:"css-loader",options:{modules:{auto:e=>{for(let s=0,o=$.length;s<o;s++)if(e&&e?.includes($[s]))return/(.*(?<!\.global\.(le|c)ss)$)/i.test(e);return/(^(?!.*node_modules))(.*(?<!\.global\.(le|c)ss)$)/i.test(e)},localIdentName:"[path][name]__[local]",exportLocalsConvention:"dashesOnly"},importLoaders:2}},g,"css-unicode-loader",{loader:"less-loader",options:{sourceMap:!!t.sourceMap,lessOptions:{modifyVars:a,javascriptEnabled:!0}}},{loader:"style-resources-loader",options:{patterns:j}}].filter(Boolean),w={loader:"tsc"===t.compiler?"ts-loader":"swc-loader",options:"tsc"===t.compiler?d:p(i)},h={rules:[{test:/\.mdx?$/,include:[f("components")],exclude:[/(.+)\/examples\/(.+).mdx?$/i],enforce:"pre",use:[{loader:e(m,"./loader/frontmatter.cjs")}]},{oneOf:[{resourceQuery:/raw/,type:"asset/source"},{test:/\.wasm$/,type:"webassembly/async"},{test:/\.txt$/,type:"asset/source"},{test:/\.(gif|png|jpe?g|ico|mp4)$/i,type:"asset",dependency:{not:["url"]},generator:{filename:"assets/images/[name][ext][query]"},include:v.concat(t.rulesInclude?.media?.map(u)||[])},{test:/\.svg$/,type:"asset/inline",generator:{dataUrl:e=>o("string"!=typeof e?e.toString():e)}},{test:/\.(eot|ttf|otf|woff(|2))$/,type:"asset",generator:{filename:"assets/fonts/[name][ext][query]"},include:v.concat(t.rulesInclude?.fonts?.map(u)||[])},{test:/\.less$/,use:b,include:v.concat(t.rulesInclude?.less?.map(u)||[])},{test:/\.css$/,use:[x,"css-loader",g,"css-unicode-loader"].filter(Boolean),include:v.concat(t.rulesInclude?.css?.map(u)||[])},{test:/\.(cj|mj|t|j)s(|x)$/,use:[...t.prefixJsLoader,w].filter(Boolean),include:v.concat(t.rulesInclude?.js?.map(u)||[])},{test:/\.mdx?$/,use:[...t.prefixJsLoader,w,{loader:"@mdx-js/loader",options:t.mdx}].filter(Boolean),include:v,exclude:[/(.+)\/examples\/(.+).mdx?$/i]},{test:/\.mdx?$/,type:"asset/source",include:[/(.+)\/examples\/(.+).mdx?$/i]},{type:"asset/source",include:[/(.+)\/examples\/(.+).*?$/i]}]},...t.moduleRules]};export default h;
1
+ import{resolve as e}from"path";import s from"mini-css-extract-plugin";import o from"mini-svg-data-uri";import{CONFIG as t,PUBLICPATH as r}from"./common.js";import{hasPkg as l}from"./has-pkg.js";import a from"./modifyVars.js";import{APPTYPE as n,DEV as i,FRAMEWORK as c,__dirname as m}from"./process-env.js";import p from"./swcrc.js";import d from"./tsloader.config.js";import{resolveNodeModulesPath as u,resolveProgramPath as f}from"./utils.js";let y="single-spa"===n?r:"../",x={loader:s.loader,options:{publicPath:"/"!==y?y:"../"}},g=l("@moneko/postcss")&&{loader:"postcss-loader",options:{postcssOptions:await import("@moneko/postcss")}};i&&(x="style-loader");let $=[...t.cssModules,`@moneko/${c}`,"neko-ui"].map(u),j=[...["src/styles/variables/*.less","src/styles/mixins/*.less","site/styles/variables/*.less","site/styles/mixins/*.less"].map(f)],v=["components","example","mock","site","src","server"].map(f),b=[x,{loader:"@teamsupercell/typings-for-css-modules-loader",options:{verifyOnly:!i}},{loader:"css-loader",options:{modules:{auto:e=>{for(let s=0,o=$.length;s<o;s++)if(e&&e?.includes($[s]))return/(.*(?<!\.?global\.(le|c)ss)$)/i.test(e);return/(^(?!.*node_modules))(.*(?<!\.?global\.(le|c)ss)$)/i.test(e)},localIdentName:"[path][name]__[local]",exportLocalsConvention:"dashesOnly"},importLoaders:2}},g,"css-unicode-loader",{loader:"less-loader",options:{sourceMap:!!t.sourceMap,lessOptions:{modifyVars:a,javascriptEnabled:!0}}},{loader:"style-resources-loader",options:{patterns:j}}].filter(Boolean),w={loader:"tsc"===t.compiler?"ts-loader":"swc-loader",options:"tsc"===t.compiler?d:p(i)},h={rules:[{test:/\.mdx?$/,include:[f("components")],exclude:[/(.+)\/examples\/(.+).mdx?$/i],enforce:"pre",use:[{loader:e(m,"./loader/frontmatter.cjs")}]},{oneOf:[{resourceQuery:/raw/,type:"asset/source"},{test:/\.wasm$/,type:"webassembly/async"},{test:/\.txt$/,type:"asset/source"},{test:/\.(gif|png|jpe?g|ico|mp4)$/i,type:"asset",dependency:{not:["url"]},generator:{filename:"assets/images/[name][ext][query]"},include:v.concat(t.rulesInclude?.media?.map(u)||[])},{test:/\.svg$/,type:"asset/inline",generator:{dataUrl:e=>o("string"!=typeof e?e.toString():e)}},{test:/\.(eot|ttf|otf|woff(|2))$/,type:"asset",generator:{filename:"assets/fonts/[name][ext][query]"},include:v.concat(t.rulesInclude?.fonts?.map(u)||[])},{test:/\.less$/,use:b,include:v.concat(t.rulesInclude?.less?.map(u)||[])},{test:/\.css$/,use:[x,"css-loader",g,"css-unicode-loader"].filter(Boolean),include:v.concat(t.rulesInclude?.css?.map(u)||[])},{test:/\.(cj|mj|t|j)s(|x)$/,use:[...t.prefixJsLoader,w].filter(Boolean),include:v.concat(t.rulesInclude?.js?.map(u)||[])},{test:/\.mdx?$/,use:[...t.prefixJsLoader,w,{loader:"@mdx-js/loader",options:t.mdx}].filter(Boolean),include:v,exclude:[/(.+)\/examples\/(.+).mdx?$/i]},{test:/\.mdx?$/,type:"asset/source",include:[/(.+)\/examples\/(.+).mdx?$/i]},{type:"asset/source",include:[/(.+)\/examples\/(.+).*?$/i]}]},...t.moduleRules]};export default h;
package/lib/routes.js CHANGED
@@ -1,2 +1,3 @@
1
- let e,t;import{readFileSync as r,readdirSync as o,statSync as n}from"fs";import{join as s,relative as i}from"path";import{watch as a}from"chokidar";import{load as l}from"js-yaml";import{hasCustomRouter as m}from"./common.js";import c from"./object-listener.js";import{APPTYPE as p,FRAMEWORK as u,FRAMEWORKNAME as d,PROGRAMPATH as f,createElement as g}from"./process-env.js";let h=/^---\n([\s\S]+?)\n---\n/;function x(e,t){let{regex:a,alia:m,base:c=e,outputSource:p}=t,u=o(e);return u.reduce((o,u)=>{let d=s(e,u),f=n(d);if(f.isDirectory()){let e=x(d,{...t,base:c});if(e.length>0){let t={},r={path:u,key:i(c,d)};if(p)Object.assign(t,{children:e});else{let o=e.splice(0,1)[0];e.length?Object.assign(t,{children:[{...o,path:"/",key:r.key},...e]}):Object.assign(t,o)}o.push(Object.assign(t,r))}}else if(a.test(d)){let e=r(d,{encoding:"utf-8"}),t=function(e){let t=e.match(h);return t&&t[1]?t[1].trim():null}(e),n=t?l(t):{},a=i(c,d);o.push(Object.assign({path:u,key:a,meta:{...n}},m&&{component:`rr(() => import(/* webpackChunkName: '${a}' */'${s(m,a)}'))rr`},p&&{codes:function(e){let t;let r={},o=/```(.+?)\n([\s\S]*?)\n```/g;for(;null!==(t=o.exec(e));){let[,e="jsx",o]=t,n=e.split(" ").pop()||"jsx";r[n]=o.trim()}return Object.keys(r).length?r:{jsx:e}}(e.replace(h,"").replace(/^\n+|\n+$/g,""))}))}return o},[])}let j=s(f,"./components");export const route=c({name:"@app/routes",data:"export default []"});export const example=c({name:"@app/example",data:{}});let $=`() => ${g}(SuspenseComp, { comp: $1 })`,b=`import { ${g} } from "${d}";import { SuspenseComp } from "@moneko/${u}";`;m&&(b+=`import merge from "@moneko/${u}/lib/merge.js";import customRouter from "@/router";`),["react","solid"].includes(u)||($="$1",b="");export let routes=[];function k(e,t,r){let o=a(e,{ignored:(e,r)=>{if(r)return!r?.isDirectory()&&t.test(e)},persistent:!0,ignoreInitial:!1});o.on("add",()=>{r()}).on("change",()=>{r()}).on("unlink",()=>{r()}),process.on("SIGINT",function(){o.close()})}"library"===p&&(k(j,/(?<!README\.mdx?)$/,function(){clearTimeout(e),e=setTimeout(()=>{clearTimeout(e),routes=x(j,{regex:/README\.mdx?$/,alia:"@pkg"});let t=JSON.stringify(routes).replace(/"rr\((.+?)\)rr"/g,$).slice(1,-1);Object.assign(route.data,{data:`${b}const routes = [{ path: "/", children: [{ path: "/" }, ${t}] }];
2
- export default ${m?'merge([...routes, ...customRouter], "path")':"routes"}`})},100)}),k(j,/(?<!\/examples\/(.+)\.md)$/,function(){clearTimeout(t),t=setTimeout(()=>{clearTimeout(t);let e={};x(j,{regex:/\/examples\/(.+)\.md$/,outputSource:!0}).forEach(t=>{let r=[example.data.name,t.key].filter(Boolean).join("/"),o=t.children?.[0].children?.filter(e=>e.codes)?.map(e=>({title:e.path.replace(/.md$/,""),order:0,...e.meta,codes:e.codes})).sort((e,t)=>e.order-t.order);Object.assign(e,{[r]:`export default ${JSON.stringify(o)};`})}),Object.assign(example.data,{data:e})},100)}));
1
+ let e,t;import{readFileSync as r,readdirSync as o,statSync as s}from"fs";import{join as n,relative as a}from"path";import{watch as i}from"chokidar";import{load as l}from"js-yaml";import{hasCustomRouter as p}from"./common.js";import c from"./object-listener.js";import{APPTYPE as m,FRAMEWORK as u,FRAMEWORKNAME as d,PROGRAMPATH as f,createElement as g}from"./process-env.js";let h=/^---\n([\s\S]+?)\n---\n/;function x(e){return e.replace(/\$/g,":").replace(/^index\.tsx?$/,"/")}function $(e,t){let{regex:i,alia:p,base:c=e,outputSource:m}=t,u=o(e);return u.reduce((o,u)=>{let d=n(e,u),f=s(d);if(f.isDirectory()){let e=$(d,{...t,base:c});if(e.length>0){let t={},r={path:x(u),key:x(a(c,d))};if(m)Object.assign(t,{children:e});else{let o=e.findIndex(e=>"/"===e.path||r.path===e.path),s=e.splice(o,1)[0];e.length?Object.assign(t,{children:[{...s,path:r.path===s.path?"/":s.path},...e]}):Object.assign(t,s)}o.push(Object.assign(t,r))}}else if(i.test(d)){let e=r(d,{encoding:"utf-8"}),t=function(e){let t=e.match(h);return t&&t[1]?t[1].trim():null}(e),s=t?l(t):{},i=a(c,d),u=x(i);o.push(Object.assign({path:u.split("/").slice(-2,-1)?.join("")||"/",key:u.replace(/\/?index.tsx?$/,"/").split("/").filter(Boolean).join("/"),meta:{...s}},p&&{component:`rr(() => import(/* webpackChunkName: '${i}' */'${n(p,i)}'))rr`},m&&{codes:function(e){let t;let r={},o=/```(.+?)\n([\s\S]*?)\n```/g;for(;null!==(t=o.exec(e));){let[,e="jsx",o]=t,s=e.split(" ").pop()||"jsx";r[s]=o.trim()}return Object.keys(r).length?r:{jsx:e}}(e.replace(h,"").replace(/^\n+|\n+$/g,""))}))}return o},[])}let j=n(f,"./components");export const route=c({name:"@app/routes",data:"export default []"});export const example=c({name:"@app/example",data:{}});let b=`() => ${g}(SuspenseComp, { comp: $1 })`,O=`import { ${g} } from "${d}";import { SuspenseComp } from "@moneko/${u}";`;p&&(O+=`import merge from "@moneko/${u}/lib/merge.js";import customRouter from "@/router";`),["react","solid"].includes(u)||(b="$1",O="");export let routes=[];function k(e,t,r){let o=i(e,{ignored:(e,r)=>{if(r)return!r?.isDirectory()&&t.test(e)},persistent:!0,ignoreInitial:!1});o.on("add",()=>{r()}).on("change",()=>{r()}).on("unlink",()=>{r()}),process.on("SIGINT",function(){o.close()})}let y=n(f,"./src/pages");"library"===m?(k(j,/(?<!README\.mdx?)$/,function(){clearTimeout(e),e=setTimeout(()=>{clearTimeout(e),routes=$(j,{regex:/README\.mdx?$/,alia:"@pkg"});let t=JSON.stringify(routes).replace(/"rr\((.+?)\)rr"/g,b).slice(1,-1);Object.assign(route.data,{data:`${O}const routes = [{ path: "/", children: [{ path: "/" }, ${t}] }];
2
+ export default ${p?'merge([...routes, ...customRouter], "path")':"routes"}`})},100)}),k(j,/(?<!\/examples\/(.+)\.md)$/,function(){clearTimeout(t),t=setTimeout(()=>{clearTimeout(t);let e={};$(j,{regex:/\/examples\/(.+)\.md$/,outputSource:!0}).forEach(t=>{let r=[example.data.name,t.key].filter(Boolean).join("/"),o=t.children?.[0].children?.filter(e=>e.codes)?.map(e=>({title:e.path.replace(/.md$/,""),order:0,...e.meta,codes:e.codes})).sort((e,t)=>e.order-t.order);Object.assign(e,{[r]:`export default ${JSON.stringify(o)};`})}),Object.assign(example.data,{data:e})},100)})):k(y,/(?<!index\.tsx?)$/,function(){clearTimeout(e),e=setTimeout(()=>{clearTimeout(e),routes=$(y,{regex:/index\.tsx?$/,alia:"@/pages"});let t=JSON.stringify(routes).replace(/"rr\((.+?)\)rr"/g,b).slice(1,-1);Object.assign(route.data,{data:`${O}const routes = [{ path: "/", children: [{ path: "/" }, ${t}] }];
3
+ export default ${p?'merge([...routes, ...customRouter], "path")':"routes"}`})},100)});
@@ -1 +1 @@
1
- import e from"fs";import t from"add-asset-html-webpack-plugin";import s from"html-webpack-plugin";import n from"webpack";import o from"webpackbar";import"./cleanup.js";import{CONFIG as l,PUBLICPATH as i}from"./common.js";import r 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 u}from"./module-federation.js";import c from"./module.config.js";import{APPTYPE as d,DEV as f,PACKAGENAME as j,PROGRAMPATH as g,hasEslintConfig as h,hasStylelintConfig as y}from"./process-env.js";import{seo as b}from"./seo.js";import{resolveNodeModulesPath as w,resolveProgramPath as x}from"./utils.js";import k from"./virtual-module-plugin.js";import v from"./virtual-modules.js";let{AutomaticPrefetchPlugin:C,DefinePlugin:O,SourceMapDevToolPlugin:$,WatchIgnorePlugin:B}=n,P=[".eslintrc.js",".eslintrc.json",".eslintrc.yaml",".eslintrc.json"],A=[".stylelintrc",".stylelintrc.json",".stylelintrc.yaml",".stylelintrc.yml",".stylelintrc.js","stylelint.config.js","stylelint.config.cjs"],S=e.readdirSync(g),T=!1,K=!1;for(let e=0,t=S.length;e<t;e++)A.includes(S[e])&&(K=!0),P.includes(S[e])&&(T=!0);T||(T=h),K||(K=y);let L=K?(await import("stylelint-webpack-plugin")).default:null,M=T?(await import("eslint-webpack-plugin")).default:null,F=l.assetHtml.map(e=>({publicPath:"",...e}));export const outputConfig={path:x("library"===d?"docs":"dist"),filename:"js/[name].bundle.js",chunkFilename:"js/[name].chunk.js",assetModuleFilename:"assets/[name][hash][ext][query]",library:{name:j,type:"window"},globalObject:"window",chunkLoadingGlobal:`webpackJsonp_${j}`,pathinfo:f,clean:!0,publicPath:i};let N=w("@app/entry");"single-component"===d&&(N=x(f?"example/index.ts":"src/index.ts"),outputConfig.path=x(f?"dist":"umd"),outputConfig.filename="index.js",outputConfig.globalObject="this",outputConfig.library={export:"default",name:j,type:"umd",umdNamedDefine:!0});let R={main:N};l.entry&&("string"==typeof l.entry?R=l.entry:Object.keys(l.entry)&&Object.assign(R,l.entry)),l.output&&("string"==typeof l.output?outputConfig.path=l.output:Object.keys(l.output)&&Object.assign(outputConfig,l.output));let W=l.routeBaseName.split("/").filter(Boolean).length,_=`${Array(W).fill("..").join("/")+(W?"/":"")}404.html`,{pathSegmentsToKeep:q=W,path:D=_}=l.fixBrowserRouter||{};export const clientConfig={entry:R,stats:"errors-only",infrastructureLogging:{level:"none"},target:"web",externalsPresets:l.externalsPresets,plugins:[new C,...u,M&&new M({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/"]}),l.htmlPluginOption&&new s(m),l.fixBrowserRouter&&new s({filename:D,inject:!1,templateContent:()=>`<html html><head><title>${m.title}</title><script>var pathSegmentsToKeep = ${q||W};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(F),"single-spa"===d&&new p(e=>!!(e.match(/main\.(.*)\.bundle.js$/)||e.match("main.bundle.js"))),new O(r),new B({paths:[/\.d\.ts$/]}),l.sourceMap&&new $(l.sourceMap),l.bar&&new o(l.bar),new a({done:()=>{!f&&l.seo&&b(),l.done?.(),f||setTimeout(()=>{process.exit(0)},2e3)}}),new k(v),...l.plugins].filter(Boolean),experiments:{topLevelAwait:!0,syncWebAssembly:!0,asyncWebAssembly:!0},resolve:{extensions:[".tsx",".ts",".js",".jsx"],alias:l.alias,fallback:{path:!1,fs:!1,crypto:!1,assert:!1}},module:c,externals:l.externals,output:outputConfig};
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,PUBLICPATH as i}from"./common.js";import r 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{APPTYPE as f,CUSTOMCONFIG as d,DEV as h,PACKAGENAME as j,PROGRAMPATH as y,hasEslintConfig as g,hasStylelintConfig as b}from"./process-env.js";import{seo as w}from"./seo.js";import{resolveNodeModulesPath as x,resolveProgramPath as k}from"./utils.js";import C from"./virtual-module-plugin.js";import v from"./virtual-modules.js";let{AutomaticPrefetchPlugin:$,DefinePlugin:O,SourceMapDevToolPlugin:B,WatchIgnorePlugin:P}=o,A=[".eslintrc.js",".eslintrc.json",".eslintrc.yaml",".eslintrc.json"],D=[".stylelintrc",".stylelintrc.json",".stylelintrc.yaml",".stylelintrc.yml",".stylelintrc.js","stylelint.config.js","stylelint.config.cjs"],M=e.readdirSync(y),S=!1,T=!1;for(let e=0,t=M.length;e<t;e++)D.includes(M[e])&&(T=!0),A.includes(M[e])&&(S=!0);S||(S=g),T||(T=b);let K=T?(await import("stylelint-webpack-plugin")).default:null,L=S?(await import("eslint-webpack-plugin")).default:null,F=l.assetHtml.map(e=>({publicPath:"",...e}));export const outputConfig={path:k("library"===f?"docs":"dist"),filename:"js/[chunkhash].js",chunkFilename:"js/[chunkhash].js",assetModuleFilename:"assets/[hash][ext][query]",library:{name:j,type:"window"},globalObject:"window",chunkLoadingGlobal:`webpackJsonp_${j}`,pathinfo:h,clean:!0,publicPath:i,asyncChunks:!0};let N=x("@app/entry");"single-component"===f&&(N=k(h?"example/index.ts":"src/index.ts"),outputConfig.path=k(h?"dist":"umd"),outputConfig.filename="index.js",outputConfig.globalObject="this",outputConfig.library={export:"default",name:j,type:"umd",umdNamedDefine:!0});let R={main:N};l.entry&&("string"==typeof l.entry?R=l.entry:Object.keys(l.entry)&&Object.assign(R,l.entry)),l.output&&("string"==typeof l.output?outputConfig.path=l.output:Object.keys(l.output)&&Object.assign(outputConfig,l.output));let W=l.routeBaseName.split("/").filter(Boolean).length,_=`${Array(W).fill("..").join("/")+(W?"/":"")}404.html`,{pathSegmentsToKeep:q=W,path:G=_}=l.fixBrowserRouter||{},H=!1;l.cacheDirectory&&(H={type:"filesystem",allowCollectingMemory:!0,cacheDirectory:l.cacheDirectory,memoryCacheUnaffected:!0,name:`${d||"default"}-${h?"development":"production"}`});export const clientConfig={entry:R,stats:"errors-only",cache:H,infrastructureLogging:{level:"none"},target:"web",externalsPresets:l.externalsPresets,plugins:[new $,...c,L&&new L({fix:!0,threads:!0,extensions:["js","md","mdx","cjs","ejs","mjs","jsx","ts","tsx","json","html","coffee","vue"]}),K&&new K({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(m),l.fixBrowserRouter&&new s({filename:G,inject:!1,templateContent:()=>`<html html><head><title>${m.title}</title><script>var pathSegmentsToKeep = ${q||W};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(F),"single-spa"===f&&new p(e=>!!(e.match(/main\.(.*)\.bundle.js$/)||e.match("main.bundle.js"))),new O(r),new P({paths:[/\.d\.ts$/]}),l.sourceMap&&new B(l.sourceMap),l.bar&&new n(l.bar),new a({done:()=>{!h&&l.seo&&w(),l.done?.(),h||setTimeout(()=>{process.exit(0)},2e3)}}),new C(v),...l.plugins].filter(Boolean),experiments:{topLevelAwait:!0,syncWebAssembly:!0,asyncWebAssembly:!0},resolve:{extensions:[".tsx",".ts",".js",".jsx"],alias:l.alias,fallback:{path:!1,fs:!1,crypto:!1,assert:!1}},module:u,externals:l.externals,output:outputConfig};
@@ -1,4 +1,4 @@
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{clientConfig as 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,B=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:
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 p}from"./has-pkg.js";import{getIPv4 as i,getPort as a}from"./net.js";import{isReact as m}from"./process-env.js";import{isFunction as n,resolveProgramPath as l}from"./utils.js";import{clientConfig as d}from"./webpack.common.js";let{HotModuleReplacementPlugin:c}=r,{yellow:v,green:h}=o,w=i(),f=s.devServer.port||3e3,u=await a(f,65535,s.devServer.host),k=s.devServer.port!==u,g=p("@moneko/mock"),$=g&&await import("@moneko/mock"),S=m&&(await import("@pmmmwh/react-refresh-webpack-plugin")).default,b=!1===s.devtool||s.devtool?s.devtool:"eval-cheap-module-source-map";s.devServer.port=u;let y="/"===s.routeBaseName,j=s.devServer.https?"https:":"http:",x=y?"":s.routeBaseName,A=t(d,{devtool:b,mode:"development",devServer:{headers:{"Access-Control-Allow-Origin":"*"},compress:s.devServer.compress,host:"0.0.0.0",port:u,historyApiFallback:y||{index:x.endsWith("/")?x:`${x}/`,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,l("mock/")),e},open:!1,hot:!0},plugins:[new c,S&&new S,new e({compilationSuccessInfo:{messages:[`You application is running here:
2
2
 
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)});export default[B];
3
+ Local: ${o.cyan(`${j}//${s.devServer.host}:${u}${x}`)}
4
+ Network: ${o.cyan(`${j}//${w}:${u}${x}`)}`],notes:k?[`Port ${v(f)} is in use, trying ${h(u)} instead`]:[]},clearConsole:!0})].filter(Boolean)});export default[A];
@@ -1 +1 @@
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{clientConfig as 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`});let y=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)});export default[y];
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{clientConfig as p}from"./webpack.common.js";let{optimize:l}=m,{cssnanoMinify:u,swcMinify:c}=e,a="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||a,s.minifier.js?.options))),s.minifier.css&&d.push(new e({minify:{swc:c,cssnano:u}[s.minifier.css?.type||f],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:d},w=r(p,{devtool:!1===s.devtool||s.devtool?s.devtool:"cheap-module-source-map",mode:"production",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 l.MinChunkSizePlugin({minChunkSize:1e4})].filter(Boolean)});export default[w];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moneko/core",
3
- "version": "3.0.0-beta.111",
3
+ "version": "3.0.0-beta.113",
4
4
  "description": "core",
5
5
  "main": "lib/index.js",
6
6
  "type": "module",
@@ -224,6 +224,9 @@ export declare type ConfigType<T extends 'tsc' | 'swc' = 'swc'> = {
224
224
  plugins: WebpackPluginInstance[];
225
225
  /** 对生产chunk进行拆分 */
226
226
  splitChunk?: false | OptimizationSplitChunksOptions;
227
+ /** 拆分 runtime 代码
228
+ * @default 'single'
229
+ */
227
230
  runtimeChunk?:
228
231
  | boolean
229
232
  | 'single'