@moneko/core 3.8.8 → 3.9.0

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/prod.js CHANGED
@@ -1 +1 @@
1
- import{removeDirAll as e}from"@moneko/mdx";import i from"css-minimizer-webpack-plugin";import o from"mini-css-extract-plugin";import n from"terser-webpack-plugin";import m from"webpack";import{BundleAnalyzerPlugin as r}from"webpack-bundle-analyzer";import{merge as s}from"webpack-merge";import t from"webpackbar";import{clientConfig as p}from"./common.js";import{CONFIG as a}from"./config.js";import{getMinifyOption as l}from"./minify.js";import c from"./paths.js";import u from"./plugin/done.js";import f from"./seo.js";let{optimize:{MinChunkSizePlugin:d}}=m,{cssnanoMinify:h,swcMinify:k}=i,w="swc"===a.compiler,b=[];a.minifier&&(a.minifier.js&&b.push(new n(l(a.minifier.js?.type||(w?"swc":"terser"),a.minifier.js?.options))),a.minifier.css&&b.push(new i({minify:{swc:k,cssnano:h}[a.minifier.css?.type||(w?"swc":"cssnano")],minimizerOptions:a.minifier.css?.options})));let g={splitChunks:a.splitChunk,runtimeChunk:a.runtimeChunk,chunkIds:"named",moduleIds:"named",removeAvailableModules:!0,removeEmptyChunks:!0,mergeDuplicateChunks:!0,mangleWasmImports:!0,minimize:!0,minimizer:b},y=m(s(p,{devtool:!1===a.devtool||a.devtool?a.devtool:"cheap-module-source-map",mode:"production",optimization:g,plugins:[new o({filename:"style/[name].bundle.css",chunkFilename:"style/[name].chunk.css",experimentalUseImportModule:!0}),a.splitChunk&&new d({minChunkSize:1e4}),a.bundleAnalyzer&&new r(a.bundleAnalyzer),a.bar&&new t(a.bar),new u({done:e=>{a.done?.(e),a.seo&&f()}})].filter(Boolean)}));y.watch({aggregateTimeout:20,ignored:/node_modules(?![\\/]@app)/,stdin:!0},e=>{if(e)throw y.close(()=>{}),e;y.hooks.done.tap("WatchRunPlugin",e=>{e.hasErrors(),y.close(()=>{})})}),process.on("exit",function(){e(c.cachePath)});
1
+ import{removeDirAll as e}from"@moneko/mdx";import i from"css-minimizer-webpack-plugin";import o from"mini-css-extract-plugin";import m from"terser-webpack-plugin";import n from"webpack";import{BundleAnalyzerPlugin as r}from"webpack-bundle-analyzer";import{merge as s}from"webpack-merge";import t from"webpackbar";import{clientConfig as p}from"./common.js";import{CONFIG as l}from"./config.js";import{getMinifyOption as a}from"./minify.js";import c from"./paths.js";import u from"./plugin/done.js";import f from"./seo.js";let{optimize:{MinChunkSizePlugin:d}}=n,{cssnanoMinify:h,swcMinify:w}=i,k="swc"===l.compiler,b=[];l.minifier&&(l.minifier.js&&b.push(new m(a(l.minifier.js?.type||(k?"swc":"terser"),l.minifier.js?.options))),l.minifier.css&&b.push(new i({minify:{swc:w,cssnano:h}[l.minifier.css?.type||(k?"swc":"cssnano")],minimizerOptions:l.minifier.css?.options})));let g={splitChunks:l.splitChunk,runtimeChunk:l.runtimeChunk,chunkIds:"named",moduleIds:"named",removeAvailableModules:!0,removeEmptyChunks:!0,mergeDuplicateChunks:!0,mangleWasmImports:!0,minimize:!0,minimizer:b},y=n(s(p,{devtool:!1===l.devtool||l.devtool?l.devtool:"cheap-module-source-map",mode:"production",optimization:g,plugins:[new o({filename:"style/[name].bundle.css",chunkFilename:"style/[name].chunk.css",experimentalUseImportModule:!0}),l.splitChunk&&new d({minChunkSize:1e4}),l.bundleAnalyzer&&new r(l.bundleAnalyzer),l.bar&&new t(l.bar),new u({done:e=>{l.done?.(e),l.seo&&f()}})].filter(Boolean)}));y.watch({aggregateTimeout:20,ignored:/node_modules(?![\\/]@app)/,stdin:!0},e=>{if(e)throw y.close(()=>{}),e;y.close(()=>{})}),process.on("exit",function(){e(c.cachePath)});
package/lib/vm/utils.js CHANGED
@@ -1 +1 @@
1
- import{join as e,relative as t}from"path";import{frontmatterSync as n,loadFileSync as r}from"@moneko/mdx";import{watch as i}from"chokidar";import{isDev as l,isSolid as o}from"../process-env.js";let s=o?"component":"element";export function mergeRouter(e,t){if(!e.length)return;let n=[];return e.forEach(e=>{let r=n.findIndex(n=>n[t]==e[t]);if(r>-1){let i=[...n[r].children||[],...e.children||[]];n[r]=Object.assign(e,n[r]),i.length&&(n[r].children=mergeRouter(i,t))}else n.push(Object.assign(e,Array.isArray(e.children)&&{children:mergeRouter(e.children,t)}))}),n.forEach((e,t)=>{if(e.children?.length){let{children:r=[],...i}=e;n[t]={path:i.path,key:i.key,children:[o&&{...i,path:e.path===i.path?"/":i.path},...r].filter(e=>e&&(e.component||e.children?.length))}}}),n}export function getTree(i){let l={};return i.files.forEach(o=>{let c={code:"",frontmatter:"{}"},a=t(i.base,o),h=i.base.split("/").filter(Boolean),p=o.split("/").filter(Boolean).slice(0,-1);(o.endsWith(".md")||o.endsWith(".mdx"))&&Object.assign(c,n(r(o)));let d={},f=Object.assign({meta:JSON.parse(c.frontmatter)},i.alia&&{[s]:`rr(() => import(/* webpackChunkName: '${a}' */'${e(i.alia,a)}'))rr`},i.outputSource&&{codes:function(e){let t;let n={},r=/```(.+?)\n([\s\S]*?)\n```/g;for(;null!==(t=r.exec(e));){let[,e="jsx",r]=t;n[e.split(" ").pop()||"jsx"]=r.trim()}return Object.keys(n).length?n:{jsx:e}}(c.code.replace(/^\n+|\n+$/g,""))});for(let e=h.length;e<p.length;e++){let t={path:p[e],key:p[e]};e===h.length?(Object.assign(d,l[t.key],{path:t.path,key:t.key},e===p.length-1&&f),l[t.key]=d):(d.children=(d.children||[]).concat([t]),i.outputSource?(Object.assign(t,{path:o.split("/").pop(),key:o.split("/").pop()},f),t.children=getTree({...i,base:`${i.base}/${t.key}`,files:i.files.filter(e=>e.startsWith(`${i.base}/${t.key}`))})):Object.assign(t,{key:p.slice(h.length,e+1).join("/")},f),d=t)}}),Object.values(l).sort((e,t)=>e.key>t.key?1:-1)}export function watchFiles(e,t,n,r=[]){let o=i(e,{ignored:(e,n)=>{if(n)return!n.isDirectory()&&t.test(e)},persistent:!0,ignoreInitial:!0});function s(){o.unwatch(e),o.close()}o.on("add",e=>{r.includes(e)||r.push(e),n(r)}).on("change",e=>{r.includes(e)||r.push(e),n(r)}).on("unlink",e=>{let t=r.indexOf(e);-1!==t&&r.splice(t,1),n(r)}),o.once("ready",()=>{l||s()}),process.on("SIGINT",s)}
1
+ import{join as e,relative as t}from"path";import{frontmatterSync as n,loadFileSync as r}from"@moneko/mdx";import{watch as i}from"chokidar";import{isSolid as l}from"../process-env.js";let o=l?"component":"element";export function mergeRouter(e,t){if(!e.length)return;let n=[];return e.forEach(e=>{let r=n.findIndex(n=>n[t]==e[t]);if(r>-1){let i=[...n[r].children||[],...e.children||[]];n[r]=Object.assign(e,n[r]),i.length&&(n[r].children=mergeRouter(i,t))}else n.push(Object.assign(e,Array.isArray(e.children)&&{children:mergeRouter(e.children,t)}))}),n.forEach((e,t)=>{if(e.children?.length){let{children:r=[],...i}=e;n[t]={path:i.path,key:i.key,children:[l&&{...i,path:e.path===i.path?"/":i.path},...r].filter(e=>e&&(e.component||e.children?.length))}}}),n}export function getTree(i){let l={};return i.files.forEach(s=>{let c={code:"",frontmatter:"{}"},a=t(i.base,s),h=i.base.split("/").filter(Boolean),p=s.split("/").filter(Boolean).slice(0,-1);(s.endsWith(".md")||s.endsWith(".mdx"))&&Object.assign(c,n(r(s)));let d={},f=Object.assign({meta:JSON.parse(c.frontmatter)},i.alia&&{[o]:`rr(() => import(/* webpackChunkName: '${a}' */'${e(i.alia,a)}'))rr`},i.outputSource&&{codes:function(e){let t;let n={},r=/```(.+?)\n([\s\S]*?)\n```/g;for(;null!==(t=r.exec(e));){let[,e="jsx",r]=t;n[e.split(" ").pop()||"jsx"]=r.trim()}return Object.keys(n).length?n:{jsx:e}}(c.code.replace(/^\n+|\n+$/g,""))});for(let e=h.length;e<p.length;e++){let t={path:p[e],key:p[e]};e===h.length?(Object.assign(d,l[t.key],{path:t.path,key:t.key},e===p.length-1&&f),l[t.key]=d):(d.children=(d.children||[]).concat([t]),i.outputSource?(Object.assign(t,{path:s.split("/").pop(),key:s.split("/").pop()},f),t.children=getTree({...i,base:`${i.base}/${t.key}`,files:i.files.filter(e=>e.startsWith(`${i.base}/${t.key}`))})):Object.assign(t,{key:p.slice(h.length,e+1).join("/")},f),d=t)}}),Object.values(l).sort((e,t)=>e.key>t.key?1:-1)}export function watchFiles(e,t,n,r=[]){let l=i(e,{ignored:(e,n)=>{if(n)return!n.isDirectory()&&t.test(e)},persistent:!0,ignoreInitial:!0});function o(){l.unwatch(e),l.close()}l.on("add",e=>{r.includes(e)||r.push(e),n(r)}).on("change",e=>{r.includes(e)||r.push(e),n(r)}).on("unlink",e=>{let t=r.indexOf(e);-1!==t&&r.splice(t,1),n(r)}),l.once("ready",()=>{o()}),process.on("SIGINT",o)}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moneko/core",
3
- "version": "3.8.8",
3
+ "version": "3.9.0",
4
4
  "description": "core",
5
5
  "main": "lib/index.js",
6
6
  "type": "module",