@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 +1 -1
- package/lib/vm/utils.js +1 -1
- package/package.json +1 -1
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
|
|
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{
|
|
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)}
|