@moneko/core 3.0.0-beta.112 → 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/module.config.js +1 -1
- package/lib/routes.js +3 -2
- package/package.json +1 -1
package/lib/module.config.js
CHANGED
|
@@ -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/(.*(
|
|
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
|
|
2
|
-
export default ${
|
|
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)});
|