@moneko/core 3.11.1-beta.9 → 3.11.2

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.
@@ -1 +1 @@
1
- import e from"webpack-node-externals";import o from"../module.config.mjs";import{CUSTOMCONFIG as s}from"../paths.mjs";import{isLibrary as t}from"../process-env.mjs";import{resolveProgramPath as r}from"../utils/index.mjs";let m={entry:{main:r("site/ssr.tsx")},output:{path:r(`${t?"docs":"dist"}/server`),library:{type:"commonjs2",umdNamedDefine:!1},filename:"[name].cjs",chunkFilename:"[chunkhash].cjs",globalObject:"global"},cache:{type:"filesystem",name:[s,process.env.NODE_ENV,"server"].filter(Boolean).join("-")},externalsPresets:{node:!0},externals:[e({allowlist:["react","react-dom","solid-js","@app","@moneko"]})],module:o(!0),target:"node"};export default m;
1
+ import e from"../module.config.mjs";import{CUSTOMCONFIG as s}from"../paths.mjs";import{isLibrary as t}from"../process-env.mjs";import{resolveProgram as o}from"../utils/index.mjs";let m={entry:{main:o("site/ssr.tsx")},output:{path:o(`${t?"docs":"dist"}/server`),library:{type:"commonjs2",umdNamedDefine:!1},filename:"[name].cjs",chunkFilename:"[chunkhash].cjs",globalObject:"global"},cache:{type:"filesystem",name:[s,process.env.NODE_ENV,"server"].filter(Boolean).join("-")},externalsPresets:{node:!0},externals:[],module:e(!0),target:"node"};export default m;
package/lib/build.mjs CHANGED
@@ -1 +1 @@
1
- import{removeDirAll as o}from"@moneko/mdx";import r from"webpack";import{merge as m}from"webpack-merge";import e from"./build/common.mjs";import i from"./build/server.mjs";import{CONFIG as t}from"./config.mjs";import s from"./module.config.mjs";import l from"./paths.mjs";import n from"./plugin/done.mjs";import{SSR as p}from"./process-env.mjs";import a from"./utils/compiler-listener.mjs";import f from"./utils/log.mjs";import c from"./utils/seo.mjs";import g from"./utils/progress.mjs";import h from"chalk";let{ProgressPlugin:u}=r,d=[m(e,{module:s(!1),plugins:[t.done&&new n({done:t.done}),t.bar&&new u({handler(o,r,...m){let e=t.bar;g(o,e.name||"Build",m.length?`[${r}] ${m.join(" ")}`:"",e.color)}})].filter(Boolean)})];p&&d.push(m(e,i));let j=r(d),[w,b]=j.compilers,k=[a("client",w)];async function B(){j.run((o,r)=>{if(o)throw o;if(r&&(r.hasErrors()||r.hasWarnings()))for(let o=0,m=r.stats.length;o<m;o++){let m=r.stats[o];for(let o=0,r=m.compilation.warnings.length;o<r;o++)f(h.yellowBright(m.compilation.warnings[o].message));for(let o=0,r=m.compilation.errors.length;o<r;o++)f(h.redBright(m.compilation.errors[o].message))}}),await Promise.all(k),t.seo&&c()}b&&k.push(a("server",b)),await B(),process.on("exit",function(){o(l.cachePath)});
1
+ import{removeDirAll as o}from"@moneko/mdx";import r from"webpack";import{merge as m}from"webpack-merge";import e from"./build/common.mjs";import i from"./build/server.mjs";import{CONFIG as t}from"./config.mjs";import s from"./module.config.mjs";import n from"./paths.mjs";import l from"./plugin/done.mjs";import{SSR as a}from"./process-env.mjs";import p from"./utils/log.mjs";import f from"./utils/seo.mjs";import c from"./utils/progress.mjs";import g from"chalk";let{ProgressPlugin:h}=r,u=[m(e,{module:s(!1),plugins:[t.done&&new l({done:t.done}),t.bar&&new h({handler(o,r,...m){let e=t.bar;c(o,e.name||"Build",m.length?`[${r}] ${m.join(" ")}`:"",e.color)}})].filter(Boolean)})];a&&u.push(m(e,i));let d=r(u);async function j(){await new Promise(o=>{d.run((r,m)=>{if(r)throw r;if(m&&(m.hasErrors()||m.hasWarnings()))for(let o=0,r=m.stats.length;o<r;o++){let r=m.stats[o];for(let o=0,m=r.compilation.warnings.length;o<m;o++)p(g.yellowBright(r.compilation.warnings[o].message));for(let o=0,m=r.compilation.errors.length;o<m;o++)p(g.redBright(r.compilation.errors[o].message))}o(r)})}),t.seo&&f()}await j(),process.on("exit",function(){o(n.cachePath)});
package/lib/common.mjs CHANGED
@@ -1 +1 @@
1
- import{CONFIG as e,PUBLICPATH as t}from"./config.mjs";import o,{CUSTOMCONFIG as s}from"./paths.mjs";import r from"./plugin/override-resolve.mjs";import n from"./plugins.config.mjs";import{PACKAGENAME as i,PACKAGEVERSION as l,isDev as a,isLibrary as p}from"./process-env.mjs";import m from"./rule.mjs";import{resolveNodeModulesPath as c,resolveProgramPath as u}from"./utils/index.mjs";export const outputConfig={path:u(p?"docs":"dist"),filename:"js/[name].bundle.js",chunkFilename:`js/[${a?"name":"chunkhash"}].js`,assetModuleFilename:e=>{let t=e.filename;return t?.endsWith("?url")&&m.worker_file.test(t.replace("?url",""))?"worker/[name][ext]":"assets/[name][hash][ext]"},library:{name:i,type:"window"},globalObject:"window",chunkLoadingGlobal:`webpackJsonp_${i}`,pathinfo:a,clean:!0,publicPath:t,asyncChunks:!0,charset:!0};let f={main:[e.polyfill&&`${o.corePath}/polyfills/replace-children.js`,c("@app/entry")].filter(Boolean)};e.entry&&("string"==typeof e.entry?f={main:[e.entry]}:Object.keys(e.entry)&&(f=Object.assign(f,e.entry))),"string"==typeof f.main&&(f.main=[f.main]),e.output&&("string"==typeof e.output?outputConfig.path=e.output:Object.keys(e.output)&&Object.assign(outputConfig,e.output));let d=!1;e.cacheDirectory&&(d={type:"filesystem",store:"pack",allowCollectingMemory:!0,cacheDirectory:e.cacheDirectory,memoryCacheUnaffected:!0,name:[s,process.env.NODE_ENV].filter(Boolean).join("-"),version:l});let y=Object.assign({original:e.alias["@"],override:s&&u(s)},e.overrideResolve);export const commonConfig={devtool:e.devtool,entry:f,mode:a?"development":"production",stats:"errors-only",cache:d,infrastructureLogging:{level:"error"},target:"web",externalsPresets:e.externalsPresets,plugins:n,node:{global:!1},experiments:{topLevelAwait:!0,asyncWebAssembly:!0,cacheUnaffected:!0,layers:!0,lazyCompilation:a&&{imports:!1,entries:!1},buildHttp:e.buildHttp,backCompat:!0,futureDefaults:!1,css:!1,outputModule:!1},resolve:{extensions:["...",".jsx",".ts",".tsx"],alias:e.alias,modules:[o.nodeModules],mainFields:["browser","module","main"],mainFiles:["index"],plugins:[e.overrideResolve&&new r(y),...e.resolvePlugins].filter(Boolean),fallback:{path:!1,fs:!1,crypto:!1,assert:!1}},externals:e.externals,output:outputConfig};
1
+ import{CONFIG as e,PUBLICPATH as t}from"./config.mjs";import o,{CUSTOMCONFIG as s}from"./paths.mjs";import r from"./plugin/override-resolve.mjs";import n from"./plugins.config.mjs";import{PACKAGENAME as i,PACKAGEVERSION as l,isDev as a,isLibrary as p}from"./process-env.mjs";import m from"./rule.mjs";import{node_modules as c,resolveProgram as u}from"./utils/index.mjs";export const outputConfig={path:u(p?"docs":"dist"),filename:"js/[name].bundle.js",chunkFilename:`js/[${a?"name":"chunkhash"}].js`,assetModuleFilename:e=>{let t=e.filename;return t?.endsWith("?url")&&m.worker_file.test(t.replace("?url",""))?"worker/[name][ext]":"assets/[name][hash][ext]"},library:{name:i,type:"window"},globalObject:"window",chunkLoadingGlobal:`webpackJsonp_${i}`,pathinfo:a,clean:!0,publicPath:t,asyncChunks:!0,charset:!0};let f={main:[e.polyfill&&`${o.corePath}/polyfills/replace-children.js`,c("@app/entry")].filter(Boolean)};e.entry&&("string"==typeof e.entry?f={main:[e.entry]}:Object.keys(e.entry)&&(f=Object.assign(f,e.entry))),"string"==typeof f.main&&(f.main=[f.main]),e.output&&("string"==typeof e.output?outputConfig.path=e.output:Object.keys(e.output)&&Object.assign(outputConfig,e.output));let d=!1;e.cacheDirectory&&(d={type:"filesystem",store:"pack",allowCollectingMemory:!0,cacheDirectory:e.cacheDirectory,memoryCacheUnaffected:!0,name:[s,process.env.NODE_ENV].filter(Boolean).join("-"),version:l});let y=Object.assign({original:e.alias["@"],override:s&&u(s)},e.overrideResolve);export const commonConfig={devtool:e.devtool,entry:f,mode:a?"development":"production",stats:"errors-only",cache:d,infrastructureLogging:{level:"error"},target:"web",externalsPresets:e.externalsPresets,plugins:n,node:{global:!1},experiments:{topLevelAwait:!0,asyncWebAssembly:!0,cacheUnaffected:!0,layers:!0,lazyCompilation:a&&{imports:!1,entries:!1},buildHttp:e.buildHttp,backCompat:!0,futureDefaults:!1,css:!1,outputModule:!1},resolve:{extensions:["...",".jsx",".ts",".tsx"],alias:e.alias,modules:[o.nodeModules],mainFields:["browser","module","main"],mainFiles:["index"],plugins:[e.overrideResolve&&new r(y),...e.resolvePlugins].filter(Boolean),fallback:{path:!1,fs:!1,crypto:!1,assert:!1}},externals:e.externals,output:outputConfig};
package/lib/config.mjs CHANGED
@@ -1 +1 @@
1
- import{fileExists as e}from"@moneko/mdx";import{merge as o}from"webpack-merge";import t from"./options/jsx-dom-expressions.mjs";import s from"./options/split-chunk.mjs";import a,{CUSTOMCONFIG as i}from"./paths.mjs";import{FRAMEWORK as r,PACKAGENAME as l,isDev as n,isLibrary as m,isMobile as p,jsxImportSource as c,mainDirectory as u}from"./process-env.mjs";import{isFunction as d,resolveProgramPath as h}from"./utils/index.mjs";import f from"./utils/log.mjs";import g from"./utils/read-conf.mjs";let x=["@moneko","neko-ui","antd","@antv","katex","font-pingfang-sc","font-pingfang-tc","react-photo-view","react-markdown-editor-lite","schema-design","@app",".cache/http/data"],P={devtool:n?"eval-cheap-module-source-map":"cheap-module-source-map",seo:!1,mode:"csr",bundleAnalyzer:!1,polyfill:!1,entry:{},minifier:{},sourceMap:{filename:"[file].map",publicPath:""},env:{NODE_ENV:process.env.NODE_ENV},basename:"/",publicPath:"/",rem:{designSize:p?375:1680},fallbackCompPath:null,modifyVars:{},prefixCls:"n",alias:{"@":h(u)},moduleRules:[],prefixJsLoader:[],cssModules:[],importOnDemand:{},proxy:{},cacheDirectory:a.webpackCachePath,devServer:{host:"localhost",port:3e3},htmlPluginOption:{},assetHtml:[],routerMode:"browser",fixBrowserRouter:!1,plugins:[],resolvePlugins:[],overrideResolve:!1,splitChunk:s,runtimeChunk:"single",moduleFederation:[],rulesInclude:{css:x,js:x,media:x,font:x,wasm:[]},mdx:{jsx:!1,development:n,jsxImportSource:c,providerImportSource:`@moneko/${r}/mdx`},jsxDomExpressions:t,bar:{name:"Client",color:"#6f42c1"},normalizeCss:!0,externalsPresets:{},buildHttp:{allowedUris:[],lockfileLocation:`${a.httpCachePath}/http.lock`,cacheLocation:`${a.httpCachePath}/data`,upgrade:!0},virtualModule:{},cssExtract:{}};m&&(P.alias=Object.assign(P.alias,{"@pkg":a.componentsPath,[l]:a.componentsPath}));let v=P,C={},k={};if(e(a.configPath)){let e=(await g(a.configPath,"index")).default;C=d(e)?e(process):e}if(i&&e(a.customConfigPath)){let e=(await g(a.customConfigPath,i)).default;k=d(e)?e(process):e}(!1===(v=o(v,C,k)).devtool||!1===v.sourceMap)&&(v.sourceMap=!1,v.devtool=!1),v.fixBrowserRouter&&v.htmlPluginOption&&(v.htmlPluginOption.tags||(v.htmlPluginOption.tags=[]),v.htmlPluginOption.tags.push({textContent:"(function(l) {if (l.search[1] === '/' ) {var decoded = l.search.slice(1).split('&').map(function(s) {return s.replace(/~and~/g, '&')}).join('?');window.history.replaceState(null, null,l.pathname.slice(0, -1) + decoded + l.hash);}}(window.location))"}));export const CONFIG=v;export const PUBLICPATH=CONFIG.publicPath||"/";global.NEKOCLICONFIG={CONFIG,CUSTOMCONFIG:i,log:f};
1
+ import{fileExists as e}from"@moneko/mdx";import{merge as o}from"webpack-merge";import t from"./options/jsx-dom-expressions.mjs";import s from"./options/split-chunk.mjs";import a,{CUSTOMCONFIG as i}from"./paths.mjs";import{APPTYPE as r,FRAMEWORK as l,NODE_ENV as n,PACKAGENAME as m,isDev as p,isLibrary as c,isMobile as u,jsxImportSource as d,mainDirectory as h}from"./process-env.mjs";import{isFunction as f,resolveProgram as g}from"./utils/index.mjs";import x from"./utils/log.mjs";import P from"./utils/read-conf.mjs";import v from"./utils/setup-env.mjs";let C=["@moneko","neko-ui","antd","@antv","katex","font-pingfang-sc","font-pingfang-tc","react-photo-view","react-markdown-editor-lite","schema-design","@app",".cache/http/data"],j={devtool:p?"eval-cheap-module-source-map":"cheap-module-source-map",seo:!1,mode:"csr",bundleAnalyzer:!1,polyfill:!1,entry:{},minifier:{},sourceMap:{filename:"[file].map",publicPath:""},env:v(n,r,l),basename:"/",publicPath:"/",rem:{designSize:u?375:1680},fallbackCompPath:null,modifyVars:{},prefixCls:"n",alias:{"@":g(h)},moduleRules:[],prefixJsLoader:[],cssModules:[],importOnDemand:{},proxy:{},cacheDirectory:a.webpackCachePath,devServer:{host:"localhost",port:3e3},htmlPluginOption:{},assetHtml:[],routerMode:"browser",fixBrowserRouter:!1,plugins:[],resolvePlugins:[],overrideResolve:!1,splitChunk:s,runtimeChunk:"single",moduleFederation:[],rulesInclude:{css:C,js:C,media:C,font:C,wasm:[]},mdx:{jsx:!1,development:p,jsxImportSource:d,providerImportSource:`@moneko/${l}/mdx`},jsxDomExpressions:t,bar:{name:"Client",color:"#6f42c1"},normalizeCss:!0,externalsPresets:{},buildHttp:{allowedUris:[],lockfileLocation:`${a.httpCachePath}/http.lock`,cacheLocation:`${a.httpCachePath}/data`,upgrade:!0},virtualModule:{},cssExtract:{}};c&&(j.alias=Object.assign(j.alias,{"@pkg":a.componentsPath,[m]:a.componentsPath}));let k=j,w={},b={};if(e(a.configPath)){let e=(await P(a.configPath,"index")).default;w=f(e)?e(process):e}if(i&&e(a.customConfigPath)){let e=(await P(a.customConfigPath,i)).default;b=f(e)?e(process):e}(!1===(k=o(k,w,b)).devtool||!1===k.sourceMap)&&(k.sourceMap=!1,k.devtool=!1),k.fixBrowserRouter&&k.htmlPluginOption&&(k.htmlPluginOption.tags||(k.htmlPluginOption.tags=[]),k.htmlPluginOption.tags.push({textContent:"(function(l) {if (l.search[1] === '/' ) {var decoded = l.search.slice(1).split('&').map(function(s) {return s.replace(/~and~/g, '&')}).join('?');window.history.replaceState(null, null,l.pathname.slice(0, -1) + decoded + l.hash);}}(window.location))"}));export const CONFIG=k;export const PUBLICPATH=CONFIG.publicPath||"/";global.NEKOCLICONFIG={CONFIG,CUSTOMCONFIG:i,log:x};
package/lib/dev.mjs CHANGED
@@ -1 +1 @@
1
- import{directoryExists as e,removeDirAll as t}from"@moneko/mdx";import o from"express";import i from"multer";import r from"webpack";import s from"webpack-dev-middleware";import l from"webpack-hot-middleware";import{merge as m}from"webpack-merge";import a from"./build/server.mjs";import{commonConfig as n}from"./common.mjs";import{CONFIG as c}from"./config.mjs";import{PORT as p,devLog as d,headers as u}from"./dev/config.mjs";import h from"./dev/mock.mjs";import f from"./dev/proxy.mjs";import w from"./module.config.mjs";import g from"./paths.mjs";import{SSR as j,isLibrary as x,isReact as k}from"./process-env.mjs";import $ from"./rule.mjs";import b from"./utils/compiler-listener.mjs";import y from"./utils/has-pkg.mjs";import{empty as v,resolveProgramPath as _}from"./utils/index.mjs";import P from"./utils/progress.mjs";import S from"./utils/sigint-exit.mjs";let{HotModuleReplacementPlugin:B,ProgressPlugin:D,WatchIgnorePlugin:C}=r,L=y("stylelint-webpack-plugin")&&(await import("stylelint-webpack-plugin")).default,M=y("eslint-webpack-plugin")&&(await import("eslint-webpack-plugin")).default,T=k&&(await import("@pmmmwh/react-refresh-webpack-plugin")).default,E=["js","jsx","ts","tsx","json","html","vue"],F=E.join(","),O=["css","scss","sass","less","ts","tsx","js","jsx"],R=O.join(","),U=["node_modules/","es/","lib/","umd/","docs/","coverage/","dist/"],q=new URLSearchParams({timeout:2e3,reload:!0,quiet:!0,noInfo:!0,overlay:!0,dynamicPublicPath:!0}).toString(),A=n.output.path;j&&(A=_(`${x?"docs":"dist"}/client`));let G=m(n,{entry:{main:[`webpack-hot-middleware/client?name=client&path=//localhost:${p}/__hmr__&${q}`]},output:{path:A},module:w(!1),plugins:[new B,new C({paths:[/\.d\.ts$/]}),T&&new T,M&&new M({fix:!0,threads:!0,files:[`${c.alias["@"]}/**/*.{${F}}`,x&&`${c.alias["@pkg"]}/**/*.{${F}}`].filter(Boolean),extensions:E,exclude:U,cache:!0,cacheLocation:`${g.lineCachePath}/.eslintcache`,lintDirtyModulesOnly:!0}),L&&new L({fix:!0,threads:!0,files:[`${c.alias["@"]}/**/*.{${R}}`,x&&`${c.alias["@pkg"]}/**/*.{${R}}`].filter(Boolean),extensions:O,exclude:U,cache:!0,cacheLocation:`${g.lineCachePath}/.stylelintcache`,lintDirtyModulesOnly:!0}),c.bar&&new D({handler(e,t,...o){let i=c.bar;P(e,i.name||"Build",o.length?`[${t}] ${o.join(" ")}`:"",i.color)}})].filter(Boolean)}),I=[G];j&&I.push(m(n,a));let[z,H]=r(I).compilers;z.hooks.done.tap("client",e=>{d(null,e)});let J=o(),K=i(),N=s(z,{writeToDisk:!1,index:"index.html",headers:()=>u,serverSideRender:j,lastModified:!0});if(J.use(N),J.use(l(z,{log:!1,path:"/__hmr__",heartbeat:2e3,ignoreUnaccepted:!1,ignoreDeclined:!0,ignoreErrored:!0})),c.proxy&&f(J,c.proxy),e(g.mockPath)){let e=h(g.mockPath);J.use(e)}let Q=`${G.output.path}/index.html`;J.all("/*",K.any(),function(e,t,o){if("GET"!==e.method)return o();{let e=N.context.outputFileSystem,o=e?.readFileSync?.(Q);t.end(o)}});let V=[b("client",z)];H&&(H.watch({aggregateTimeout:20,ignored:$.dev_watch_ignored,poll:300,stdin:!0},d),V.push(b("server",H))),await Promise.all(V);let W=J.listen(p,()=>{});process.on("exit",function(){N.close(v),W.close(v),W.closeAllConnections(),t(g.cachePath)}),S(()=>{process.exit(1)});
1
+ import{directoryExists as e,removeDirAll as t}from"@moneko/mdx";import o from"express";import i from"multer";import s from"webpack";import l from"webpack-dev-middleware";import r from"webpack-hot-middleware";import{merge as m}from"webpack-merge";import a from"./build/server.mjs";import{commonConfig as n}from"./common.mjs";import{CONFIG as c}from"./config.mjs";import{PORT as p,devLog as d,headers as u}from"./dev/config.mjs";import h from"./dev/mock.mjs";import f from"./dev/proxy.mjs";import w from"./module.config.mjs";import x from"./paths.mjs";import{SSR as j,isLibrary as g,isReact as k}from"./process-env.mjs";import $ from"./utils/has-pkg.mjs";import{empty as b,resolveProgram as y}from"./utils/index.mjs";import v from"./utils/progress.mjs";import _ from"./utils/sigint-exit.mjs";let{HotModuleReplacementPlugin:P,ProgressPlugin:S,WatchIgnorePlugin:B}=s,C=$("stylelint-webpack-plugin")&&(await import("stylelint-webpack-plugin")).default,D=$("eslint-webpack-plugin")&&(await import("eslint-webpack-plugin")).default,L=k&&(await import("@pmmmwh/react-refresh-webpack-plugin")).default,M=["js","jsx","ts","tsx","json","html","vue"],F=M.join(","),O=["css","scss","sass","less","ts","tsx","js","jsx"],R=O.join(","),T=["node_modules/","es/","lib/","umd/","docs/","coverage/","dist/"],q=new URLSearchParams({timeout:2e3,reload:!0,quiet:!0,noInfo:!0,overlay:!0,dynamicPublicPath:!0}).toString(),A=n.output.path;j&&(A=y(`${g?"docs":"dist"}/client`));let E=m(n,{entry:{main:[`webpack-hot-middleware/client?name=client&path=//localhost:${p}/__hmr__&${q}`]},output:{path:A},module:w(!1),plugins:[new P,new B({paths:[/\.d\.ts$/]}),L&&new L,D&&new D({fix:!0,threads:!0,files:[`${c.alias["@"]}/**/*.{${F}}`,g&&`${c.alias["@pkg"]}/**/*.{${F}}`].filter(Boolean),extensions:M,exclude:T,cache:!0,cacheLocation:`${x.lineCachePath}/.eslintcache`,lintDirtyModulesOnly:!0}),C&&new C({fix:!0,threads:!0,files:[`${c.alias["@"]}/**/*.{${R}}`,g&&`${c.alias["@pkg"]}/**/*.{${R}}`].filter(Boolean),extensions:O,exclude:T,cache:!0,cacheLocation:`${x.lineCachePath}/.stylelintcache`,lintDirtyModulesOnly:!0}),c.bar&&new S({handler(e,t,...o){let i=c.bar;v(e,i.name||"Build",o.length?`[${t}] ${o.join(" ")}`:"",i.color)}})].filter(Boolean)}),G=[E];j&&G.push(m(n,a));let I=s(G);I.compilers[0].hooks.done.tap("client-log",e=>{d(null,e)});let U=o(),z=i(),H=l(I,{writeToDisk:!1,index:"index.html",headers:()=>u,serverSideRender:j,lastModified:!0});if(U.use(H),U.use(r(I,{log:!1,path:"/__hmr__",heartbeat:2e3})),c.proxy&&f(U,c.proxy),e(x.mockPath)){let e=h(x.mockPath);U.use(e)}let J=`${E.output.path}/index.html`;U.all("/*",z.any(),function(e,t,o){if("GET"!==e.method)return o();{let e=H.context.outputFileSystem,o=e?.readFileSync?.(J);t.end(o)}});let K=U.listen(p,()=>{});process.on("exit",function(){H.close(b),K.close(b),K.closeAllConnections(),t(x.cachePath)}),_(()=>{process.exit(1)});
package/lib/index.d.mts CHANGED
@@ -1,6 +1,6 @@
1
1
  export { default as paths, CUSTOMCONFIG, yarnArgv, routeDir } from './paths.mjs';
2
2
  export { APPTYPE, FRAMEWORK, PACKAGENAME, PACKAGEVERSION, coreName, isDev, isLibrary, isMicro, mainDirectory, } from './process-env.mjs';
3
- export { realResolve, resolveNodeModulesPath, resolveProgramPath } from './utils/index.mjs';
3
+ export { realResolve, resolveProgram } from './utils/index.mjs';
4
4
  export { default as log } from './utils/log.mjs';
5
5
  export { default as hasPkg } from './utils/has-pkg.mjs';
6
6
  export { default as osTmpDir } from './utils/os-tmp-dir.mjs';
package/lib/index.mjs CHANGED
@@ -1 +1 @@
1
- export{default as paths,CUSTOMCONFIG,yarnArgv,routeDir}from"./paths.mjs";export{APPTYPE,FRAMEWORK,PACKAGENAME,PACKAGEVERSION,coreName,isDev,isLibrary,isMicro,mainDirectory}from"./process-env.mjs";export{realResolve,resolveNodeModulesPath,resolveProgramPath}from"./utils/index.mjs";export{default as log}from"./utils/log.mjs";export{default as hasPkg}from"./utils/has-pkg.mjs";export{default as osTmpDir}from"./utils/os-tmp-dir.mjs";export{yApiMock,yApiSchemaMock}from"./dev/mock.mjs";export{getIPv4,getPort}from"./dev/net.mjs";export{default as jsxDomExpressions}from"./options/jsx-dom-expressions.mjs";export{default as splitChunk}from"./options/split-chunk.mjs";export{default as Rule}from"./rule.mjs";import o from"./cjs/index.cjs";let e=o.default;export const coreJsVersion=e.coreJsVersion;export const loadModuleMeta=e.loadModuleMeta;
1
+ export{default as paths,CUSTOMCONFIG,yarnArgv,routeDir}from"./paths.mjs";export{APPTYPE,FRAMEWORK,PACKAGENAME,PACKAGEVERSION,coreName,isDev,isLibrary,isMicro,mainDirectory}from"./process-env.mjs";export{realResolve,resolveProgram}from"./utils/index.mjs";export{default as log}from"./utils/log.mjs";export{default as hasPkg}from"./utils/has-pkg.mjs";export{default as osTmpDir}from"./utils/os-tmp-dir.mjs";export{yApiMock,yApiSchemaMock}from"./dev/mock.mjs";export{getIPv4,getPort}from"./dev/net.mjs";export{default as jsxDomExpressions}from"./options/jsx-dom-expressions.mjs";export{default as splitChunk}from"./options/split-chunk.mjs";export{default as Rule}from"./rule.mjs";import o from"./cjs/index.cjs";let e=o.default;export const coreJsVersion=e.coreJsVersion;export const loadModuleMeta=e.loadModuleMeta;
@@ -1 +1 @@
1
- let e;import{CONFIG as s}from"./config.mjs";import o from"./options/modify-vars.mjs";import t from"./options/swcrc.mjs";import r,{CUSTOMCONFIG as a}from"./paths.mjs";import{getLightningCssTargets as n}from"./polyfills/targets.mjs";import{FRAMEWORK as l,isDev as i,isLibrary as m}from"./process-env.mjs";import d from"./rule.mjs";import c from"./utils/has-pkg.mjs";import{resolveNodeModulesPath as u,resolveProgramPath as p}from"./utils/index.mjs";import f from"./utils/svg-to-data-uri.mjs";import{comment as y,getCommentPath as g}from"./vm/docs.mjs";import v from"./vm/generate-doc.mjs";import j from"./options/css-extract.mjs";let x={loader:`${r.corePath}/loader/lightningcss.cjs`,options:{sourceMap:!!s.sourceMap,analyzeDependencies:!1,targets:n(),drafts:{nesting:!0,customMedia:!0},errorRecovery:!1,unusedSymbols:[],rem:!!s.rem}},h={loader:"less-loader",options:{sourceMap:!!s.sourceMap,lessOptions:{modifyVars:o,javascriptEnabled:!0}}},_=[...s.cssModules,`@moneko/${l}`,"neko-ui"].map(u),w=["components","example","mock","site","src","server"].map(p);function k(e){return[...w,...s.rulesInclude?.[e]?.map(u)||[]]}a&&w.push(p(a)),s.overrideResolve&&s.overrideResolve.override&&w.push(s.overrideResolve.override);let M=k("css"),O=k("js"),R=k("media"),b=k("wasm"),L=k("font");c("sass")&&(e={loader:"sass-loader",options:{implementation:await import("sass"),sassOptions:{}}});let P=m&&i&&{test:d.tsdoc,include:s.alias["@pkg"],exclude:[d.node_modules,d.__tests__],enforce:"pre",loader:`${r.corePath}/loader/ts-doc.cjs`,options:{comment:y,generateDoc:v,getCommentPath:g}},$=[{resourceQuery:/raw/i,type:"asset/source"},{resourceQuery:/url/i,type:"asset/resource",generator:{filename:e=>{let s=e.filename;return s&&s.endsWith("wasm?url")?"wasm/[name][ext]":"assets/[name][ext]"}}},{test:d.wasm,type:"webassembly/async",include:b},{test:d.txt,type:"asset/source"},{test:d.ico,type:"asset/inline",include:R},{test:d.svg,type:"asset/inline",generator:{dataUrl:e=>f(e.toString())},include:R},{test:d.image,type:"asset",dependency:{not:["url"]},generator:{filename:"assets/images/[name][ext]"},include:R},{test:d.video,type:"asset",dependency:{not:["url"]},generator:{filename:"assets/video/[name][ext]"},include:R},{test:d.font,type:"asset",dependency:{not:["url"]},generator:{filename:"assets/fonts/[name][ext]"},include:L}],B=s.prefixJsLoader.filter(Boolean)||[];export default(o=>{let a={loader:"swc-loader",options:t(o)},n={loader:"css-loader",options:{modules:{auto:e=>{if(e){for(let s=0,o=_.length;s<o;s++)if(e.includes(_[s]))return d.css_module.test(e)}return d.node_modules_css_module.test(e)},localIdentName:"[path][name]_[local]",exportLocalsConvention:"dashesOnly",exportOnlyLocals:o},importLoaders:2}};return{noParse:d.no_parse,rules:[P,{oneOf:[...$,{test:d.js,use:[...B,a],include:O},{test:d.css,use:[j,"css-loader",x],include:M},e&&{test:d.scss,use:[j,n,x,e],include:M},{test:d.less,use:[j,n,x,h],include:M},{test:d.markdown,use:[...B,{loader:`${r.corePath}/loader/mdx.cjs`,options:s.mdx}],exclude:[d.node_modules]}].filter(Boolean)},...s.moduleRules].filter(Boolean)}});
1
+ let e;import{CONFIG as s}from"./config.mjs";import o from"./options/modify-vars.mjs";import t from"./options/swcrc.mjs";import r,{CUSTOMCONFIG as a}from"./paths.mjs";import{getLightningCssTargets as n}from"./polyfills/targets.mjs";import{FRAMEWORK as l,isDev as i,isLibrary as m}from"./process-env.mjs";import d from"./rule.mjs";import c from"./utils/has-pkg.mjs";import{node_modules as u,resolveProgram as p}from"./utils/index.mjs";import f from"./utils/svg-to-data-uri.mjs";import{comment as y,getCommentPath as g}from"./vm/docs.mjs";import v from"./vm/generate-doc.mjs";import j from"./options/css-extract.mjs";let x={loader:`${r.corePath}/loader/lightningcss.cjs`,options:{sourceMap:!!s.sourceMap,analyzeDependencies:!1,targets:n(),drafts:{nesting:!0,customMedia:!0},errorRecovery:!1,unusedSymbols:[],rem:!!s.rem}},h={loader:"less-loader",options:{sourceMap:!!s.sourceMap,lessOptions:{modifyVars:o,javascriptEnabled:!0}}},_=[...s.cssModules,`@moneko/${l}`,"neko-ui"].map(u),w=["components","example","mock","site","src","server"].map(p);function k(e){return[...w,...s.rulesInclude?.[e]?.map(u)||[]]}a&&w.push(p(a)),s.overrideResolve&&s.overrideResolve.override&&w.push(s.overrideResolve.override);let M=k("css"),O=k("js"),R=k("media"),b=k("wasm"),L=k("font");c("sass")&&(e={loader:"sass-loader",options:{implementation:await import("sass"),sassOptions:{}}});let P=m&&i&&{test:d.tsdoc,include:s.alias["@pkg"],exclude:[d.node_modules,d.__tests__],enforce:"pre",loader:`${r.corePath}/loader/ts-doc.cjs`,options:{comment:y,generateDoc:v,getCommentPath:g}},$=[{resourceQuery:/raw/i,type:"asset/source"},{resourceQuery:/url/i,type:"asset/resource",generator:{filename:e=>{let s=e.filename;return s&&s.endsWith("wasm?url")?"wasm/[name][ext]":"assets/[name][ext]"}}},{test:d.wasm,type:"webassembly/async",include:b},{test:d.txt,type:"asset/source"},{test:d.ico,type:"asset/inline",include:R},{test:d.svg,type:"asset/inline",generator:{dataUrl:e=>f(e.toString())},include:R},{test:d.image,type:"asset",dependency:{not:["url"]},generator:{filename:"assets/images/[name][ext]"},include:R},{test:d.video,type:"asset",dependency:{not:["url"]},generator:{filename:"assets/video/[name][ext]"},include:R},{test:d.font,type:"asset",dependency:{not:["url"]},generator:{filename:"assets/fonts/[name][ext]"},include:L}],B=s.prefixJsLoader.filter(Boolean)||[];export default(o=>{let a={loader:"swc-loader",options:t(o)},n={loader:"css-loader",options:{modules:{auto:e=>{if(e){for(let s=0,o=_.length;s<o;s++)if(e.includes(_[s]))return d.css_module.test(e)}return d.node_modules_css_module.test(e)},localIdentName:"[path][name]_[local]",exportLocalsConvention:"dashesOnly",exportOnlyLocals:o},importLoaders:2}};return{noParse:d.no_parse,rules:[P,{oneOf:[...$,{test:d.js,use:[...B,a],include:O},{test:d.css,use:[j,"css-loader",x],include:M},e&&{test:d.scss,use:[j,n,x,e],include:M},{test:d.less,use:[j,n,x,h],include:M},{test:d.markdown,use:[...B,{loader:`${r.corePath}/loader/mdx.cjs`,options:s.mdx}],exclude:[d.node_modules]}].filter(Boolean)},...s.moduleRules].filter(Boolean)}});
@@ -1,4 +1,4 @@
1
- import{merge as e}from"webpack-merge";import{CONFIG as t}from"../config.mjs";import{PACKAGENAME as i,coreName as o}from"../process-env.mjs";import{resolveProgramPath as m}from"../utils/index.mjs";import{description as r,keywords as a}from"../vm/info.mjs";let{favicon:n=`node_modules/${o}/lib/options/favicon.ico`,template:l,...p}=t.htmlPluginOption||{},s=e({title:t.env?.PROJECTNAME||i.toLocaleUpperCase()||"Title",filename:"index.html",hash:!1,minify:{minifyJS:!0,minifyCSS:!0,collapseWhitespace:!0,removeComments:!0,removeRedundantAttributes:!1,removeScriptTypeAttributes:!1,removeStyleLinkTypeAttributes:!1,removeAttributeQuotes:!0,useShortDoctype:!0},meta:{charset:"UTF-8","X-UA-Compatible":{"http-equiv":"X-UA-Compatible",content:"IE=edge,Chrome=1"},HandheldFriendly:"true",MobileOptimized:"320","screen-orientation":"portrait","x5-orientation":"portrait",browsermode:"application","x5-page-mode":"app","msapplication-tap-highlight":"no",viewport:"width=device-width,initial-scale=1,maximum-scale=1,minimum-scale=1","apple-mobile-web-app-capable":"yes",renderer:"webkit",description:r,keywords:a},tags:[],favicon:n?m(n):n},p,l?{template:l?m(l):void 0}:{templateContent:function({htmlWebpackPlugin:{options:e}}){let t=e.tags,i="",o="";return t&&t.map(function(e){let{tag:t="script",textContent:m="",inject:r="head",...a}=e,n="";for(let e in a)Object.prototype.hasOwnProperty.call(a,e)&&(n+=`${e}="${a[e]}" `);let l=`<${t} ${n}>${m}</${t}>`;"body"===r?o+=l:i+=l}),`<!DOCTYPE html>
1
+ import{merge as e}from"webpack-merge";import{CONFIG as t}from"../config.mjs";import{PACKAGENAME as i,coreName as o}from"../process-env.mjs";import{resolveProgram as m}from"../utils/index.mjs";import{description as r,keywords as a}from"../vm/info.mjs";let{favicon:n=`node_modules/${o}/lib/options/favicon.ico`,template:l,...p}=t.htmlPluginOption||{},s=e({title:t.env?.PROJECTNAME||i.toLocaleUpperCase()||"Title",filename:"index.html",hash:!1,minify:{minifyJS:!0,minifyCSS:!0,collapseWhitespace:!0,removeComments:!0,removeRedundantAttributes:!1,removeScriptTypeAttributes:!1,removeStyleLinkTypeAttributes:!1,removeAttributeQuotes:!0,useShortDoctype:!0},meta:{charset:"UTF-8","X-UA-Compatible":{"http-equiv":"X-UA-Compatible",content:"IE=edge,Chrome=1"},HandheldFriendly:"true",MobileOptimized:"320","screen-orientation":"portrait","x5-orientation":"portrait",browsermode:"application","x5-page-mode":"app","msapplication-tap-highlight":"no",viewport:"width=device-width,initial-scale=1,maximum-scale=1,minimum-scale=1","apple-mobile-web-app-capable":"yes",renderer:"webkit",description:r,keywords:a},tags:[],favicon:n?m(n):n},p,l?{template:l?m(l):void 0}:{templateContent:function({htmlWebpackPlugin:{options:e}}){let t=e.tags,i="",o="";return t&&t.map(function(e){let{tag:t="script",textContent:m="",inject:r="head",...a}=e,n="";for(let e in a)Object.prototype.hasOwnProperty.call(a,e)&&(n+=`${e}="${a[e]}" `);let l=`<${t} ${n}>${m}</${t}>`;"body"===r?o+=l:i+=l}),`<!DOCTYPE html>
2
2
  <html lang="en">
3
3
  <head>
4
4
  <title>${e.title}</title>
package/lib/paths.d.mts CHANGED
@@ -1,3 +1,5 @@
1
+ export declare const __filename: string;
2
+ export declare const __dirname: string;
1
3
  export declare const yarnArgv: Record<string, string> & {
2
4
  config?: string;
3
5
  };
@@ -10,10 +12,13 @@ export declare const yarnArgv: Record<string, string> & {
10
12
  */
11
13
  export declare const CUSTOMCONFIG: string | undefined;
12
14
  declare const paths: {
15
+ __dirname: string;
16
+ __filename: string;
13
17
  nodeModules: string;
14
18
  corePath: string;
15
19
  programPath: string;
16
20
  webpackCachePath: string;
21
+ lineCachePath: string;
17
22
  cachePath: string;
18
23
  httpCachePath: string;
19
24
  swcCachePath: string;
@@ -23,7 +28,6 @@ declare const paths: {
23
28
  pagesPath: string;
24
29
  componentsPath: string;
25
30
  mockPath: string;
26
- lineCachePath: string;
27
31
  };
28
32
  export declare const routeDir: string;
29
33
  export default paths;
package/lib/paths.mjs CHANGED
@@ -1 +1 @@
1
- import e from"url";import{resolve as o}from"path";let t=JSON.parse(process.env.npm_config_argv||'{"original":[]}').original;export const yarnArgv={};for(let e=0,o=t.length;e<o;e++){let o=t[e].split("=");Object.assign(yarnArgv,{[o[0]]:o[1]||!0})}export const CUSTOMCONFIG=process.env.npm_config_config||yarnArgv.config;let a=process.cwd(),c=o(a,"./node_modules"),r={nodeModules:c,corePath:e.fileURLToPath(new URL(".",import.meta.url)),programPath:a,webpackCachePath:`${c}/.temp_cache`,cachePath:`${c}/.cache/.mo`,httpCachePath:`${c}/.cache/http`,swcCachePath:`${c}/.swc`,configPath:`${a}/config/index.ts`,customConfigPath:`${a}/config/${CUSTOMCONFIG}.ts`,coveragePath:`${a}/coverage/clover.xml`,pagesPath:`${a}/src/pages`,componentsPath:`${a}/components`,mockPath:`${a}/mock`,lineCachePath:`${c}/.cache`};export const routeDir="library"===process.env.APPTYPE?r.componentsPath:r.pagesPath;export default r;
1
+ import e from"url";import{dirname as t,resolve as o}from"path";let a=JSON.parse(process.env.npm_config_argv||'{"original":[]}').original;export const __filename=e.fileURLToPath(import.meta.url);export const __dirname=t(__filename);export const yarnArgv={};for(let e=0,t=a.length;e<t;e++){let t=a[e].split("=");Object.assign(yarnArgv,{[t[0]]:t[1]||!0})}export const CUSTOMCONFIG=process.env.npm_config_config||yarnArgv.config;let c=process.cwd(),r=o(c,"./node_modules"),n={__dirname,__filename,nodeModules:r,corePath:e.fileURLToPath(new URL(".",import.meta.url)),programPath:c,webpackCachePath:o(r,"./.temp_cache"),lineCachePath:o(r,"./.cache"),cachePath:o(r,"./.cache/.mo"),httpCachePath:o(r,"./.cache/http"),swcCachePath:o(r,"./.swc"),configPath:o(c,"./config/index.ts"),customConfigPath:o(c,`./config/${CUSTOMCONFIG}.ts`),coveragePath:o(c,"./coverage/clover.xml"),pagesPath:o(c,"./src/pages"),componentsPath:o(c,"./components"),mockPath:o(c,"./mock")};export const routeDir="library"===process.env.APPTYPE?n.componentsPath:n.pagesPath;export default n;
@@ -3,8 +3,8 @@ export interface VirtualModulePluginOption {
3
3
  [key: string]: string | object;
4
4
  }
5
5
  export declare class VirtualModuleWebpackPlugin {
6
- private hasTapped;
7
6
  private virtualModules;
7
+ private options;
8
8
  constructor(options?: VirtualModulePluginOption);
9
9
  private modify;
10
10
  apply(compiler: Compiler): void;
@@ -1 +1 @@
1
- import o from"webpack-virtual-modules";import{isLibrary as t}from"../process-env.mjs";import{node_modules as e}from"../utils/index.mjs";import{comment as i,docs as s}from"../vm/docs.mjs";import{examples as l}from"../vm/example.mjs";import{locales as r}from"../vm/locales.mjs";import m from"../vm/modules.mjs";import{route as p}from"../vm/routes.mjs";export class VirtualModuleWebpackPlugin{constructor(t={}){let i={};for(let o in t)if(Object.prototype.hasOwnProperty.call(t,o)){let s=t[o];Object.assign(i,{[e(o)]:"string"==typeof s?s:`export default ${JSON.stringify(s)}`})}this.hasTapped=!1,this.virtualModules=new o({...m,...i})}modify(o,t,i){let s=i||"",l=e(t),r=o?.inputFileSystem;for(;r&&r._inputFileSystem;)r=r._inputFileSystem;let m=r._virtualFiles[l];m&&m.contents===s||console.log("update :",l),this.virtualModules.writeModule(l,s)}apply(o){this.virtualModules.apply(o);let e=this.modify.bind(this,o);p.on("change",e),r.on("change",e),t&&(l.on("change",e),s.on("change",e),i.on("change",e)),o.hooks.compilation.tap("VirtualModuleWebpackPlugin",()=>{if(!this.hasTapped){for(let o of(this.hasTapped=!0,l))e(o[0],o[1]);for(let o of s)e(o[0],o[1]);for(let o of i)e(o[0],o[1])}})}}
1
+ import o from"webpack-virtual-modules";import{isLibrary as t}from"../process-env.mjs";import{node_modules as e}from"../utils/index.mjs";import{comment as i,docs as s}from"../vm/docs.mjs";import{examples as r}from"../vm/example.mjs";import{locales as l}from"../vm/locales.mjs";import m from"../vm/modules.mjs";import{route as p}from"../vm/routes.mjs";import n from"../paths.mjs";export class VirtualModuleWebpackPlugin{constructor(t={}){this.virtualModules=new o(m),this.options={};let e={};for(let o in t)if(Object.prototype.hasOwnProperty.call(t,o)){let i=t[o];Object.assign(e,{[o]:"string"==typeof i?i:`export default ${JSON.stringify(i)}`})}this.options=e}modify(o,t,i){let s=i||"",r=t.startsWith(n.nodeModules)?t:e(t),l=o?.inputFileSystem;for(;l&&l._inputFileSystem;)l=l._inputFileSystem;let m=l._virtualFiles?.[r];m&&m.contents===s||this.virtualModules.writeModule(r,s)}apply(o){this.virtualModules.apply(o);let e=(t,e)=>{this.modify(o,t,e)};p.on("change",e),l.on("change",e),t&&(r.on("change",e),s.on("change",e),i.on("change",e)),o.hooks.compilation.tap("VirtualModuleWebpackPlugin",()=>{for(let o in this.options)Object.prototype.hasOwnProperty.call(this.options,o)&&e(o,this.options[o]);for(let o of r)e(o[0],o[1]);for(let o of s)e(o[0],o[1]);for(let o of i)e(o[0],o[1])})}}
@@ -1,6 +1,7 @@
1
1
  import type { AppType, Framework } from './index.mjs';
2
2
  export declare const APPTYPE: AppType;
3
3
  export declare const FRAMEWORK: Framework;
4
+ export declare const NODE_ENV: string;
4
5
  export declare const isLibrary: boolean;
5
6
  export declare const isMicro: boolean;
6
7
  export declare const isMobile: boolean;
@@ -1 +1 @@
1
- export const APPTYPE=process.env.APPTYPE;export const FRAMEWORK=process.env.FRAMEWORK;export const isLibrary="library"===APPTYPE;export const isMicro="micro"===APPTYPE;export const isMobile="mobile"===APPTYPE;export const isReact="react"===FRAMEWORK;export const isSolid="solid"===FRAMEWORK;export const SSR="true"===process.env.SSR;export const mainDirectory=isLibrary?"site":"src";export const jsxImportSource={react:"react",solid:"solid-js/h"}[FRAMEWORK];export const PACKAGENAME=process.env.npm_package_name;export const PACKAGEVERSION=process.env.npm_package_version;export const coreName="@moneko/core";export const isDev="development"===process.env.NODE_ENV;
1
+ export const APPTYPE=process.env.APPTYPE;export const FRAMEWORK=process.env.FRAMEWORK;export const NODE_ENV=process.env.NODE_ENV;export const isLibrary="library"===APPTYPE;export const isMicro="micro"===APPTYPE;export const isMobile="mobile"===APPTYPE;export const isReact="react"===FRAMEWORK;export const isSolid="solid"===FRAMEWORK;export const SSR="true"===process.env.SSR;export const mainDirectory=isLibrary?"site":"src";export const jsxImportSource={react:"react",solid:"solid-js/h"}[FRAMEWORK];export const PACKAGENAME=process.env.npm_package_name;export const PACKAGEVERSION=process.env.npm_package_version;export const coreName="@moneko/core";export const isDev="development"===NODE_ENV;
@@ -1,16 +1,14 @@
1
1
  export declare function toUpperCaseString(string: string): string;
2
2
  type ProgramPath<T extends string> = `${T extends string ? T : string}`;
3
- type NodeModulesPath<T> = ProgramPath<`node_modules/${T extends string ? T : string}`>;
4
3
  /** 位于项目根目录下的位置
5
4
  * @param {string} src 路径
6
5
  * @returns {string} 位于项目根目录下的位置
7
6
  */
8
- export declare function resolveProgramPath<T extends string>(src: T): ProgramPath<T>;
7
+ export declare function resolveProgram<T extends string>(src: T): ProgramPath<T>;
9
8
  /** 位于项目根目录node_modules下的位置
10
- * @param {string} src 路径
9
+ * @param {string} name 路径
11
10
  * @returns {string} 位于项目根目录node_modules下的位置
12
11
  */
13
- export declare const resolveNodeModulesPath: <T extends string>(src: T) => NodeModulesPath<T>;
14
12
  export declare function node_modules<T extends string>(name: T): `node_modules/${T}`;
15
13
  /** 获取模块真实入口位置
16
14
  * @param {string} url 路径
@@ -1 +1 @@
1
- import{resolve as e}from"path";import o from"./resolver-sync.mjs";import t from"../paths.mjs";export function toUpperCaseString(e){return e?.replaceAll(/\b\w/g,e=>e.toUpperCase()).replaceAll(/\./g," ")}export function resolveProgramPath(o){return e(t.programPath,`./${o}`)}export const resolveNodeModulesPath=o=>e(t.nodeModules,`./${o}`);export function node_modules(o){return e(t.nodeModules,`./${o}`)}export const realResolve=e=>o.resolveSync({},t.programPath,e)||e;export function isObject(e){let o=typeof e;return null!==e&&("object"===o||"function"===o)}export function isFunction(e){if(!isObject(e))return!1;let o=Object.prototype.toString.call(e);return"[object Function]"===o||"[object AsyncFunction]"===o||"[object GeneratorFunction]"===o||"[object Proxy]"===o}export function empty(){}
1
+ import{resolve as t}from"path";import e from"./resolver-sync.mjs";import o from"../paths.mjs";export function toUpperCaseString(t){return t?.replaceAll(/\b\w/g,t=>t.toUpperCase()).replaceAll(/\./g," ")}export function resolveProgram(e){return t(o.programPath,`./${e}`)}export function node_modules(e){return t(o.nodeModules,`./${e}`)}export const realResolve=t=>e.resolveSync({},o.programPath,t)||t;export function isObject(t){let e=typeof t;return null!==t&&("object"===e||"function"===e)}export function isFunction(t){if(!isObject(t))return!1;let e=Object.prototype.toString.call(t);return"[object Function]"===e||"[object AsyncFunction]"===e||"[object GeneratorFunction]"===e||"[object Proxy]"===e}export function empty(){}
@@ -1 +1 @@
1
- import t from"events";class e extends t{constructor(t={}){super(),this.data=t}setData(t,e){this.data[t]=e,this.emit("change",t,e)}getData(t){return this.data[t]}removeData(t){Object.prototype.hasOwnProperty.call(this.data,t)&&(delete this.data[t],this.emit("change",t,null))}[Symbol.iterator](){let t=Object.keys(this.data),e=0;return{next:()=>{if(e<t.length){let a=t[e++];return{value:[a,this.data[a]],done:!1}}return{value:void 0,done:!0}}}}}export default e;
1
+ import t from"events";class e extends t{constructor(t={}){super(),this.data=t}setData(t,e){this.data[t]!==e&&(this.data[t]=e,this.emit("change",t,e))}getData(t){return this.data[t]}removeData(t){Object.prototype.hasOwnProperty.call(this.data,t)&&(delete this.data[t],this.emit("change",t,null))}[Symbol.iterator](){let t=Object.keys(this.data),e=0;return{next:()=>{if(e<t.length){let a=t[e++];return{value:[a,this.data[a]],done:!1}}return{value:void 0,done:!0}}}}}export default e;
package/lib/utils/seo.mjs CHANGED
@@ -1 +1 @@
1
- import{join as m}from"path";import{saveFileSync as o,scanRouter as t,sitemap as r}from"@moneko/mdx";import{resolveProgramPath as e}from"./index.mjs";import{outputConfig as p}from"../common.mjs";import{CONFIG as i}from"../config.mjs";import{routeDir as s}from"../paths.mjs";import{isLibrary as f}from"../process-env.mjs";export default(()=>{let{domain:n,nojekyll:a,path:j}=i.seo||{},l=j&&e(j)||p?.path;if(!n||!l)return;let x=`https://${n}${i.basename}`;o(m(l,"CNAME"),n),o(m(l,"robots"),`Sitemap: ${x}/sitemap.txt`),o(m(l,"sitemap.txt"),r(s,x,t(s,f)).join("\n")),a&&o(m(l,".nojekyll"),"")});
1
+ import{join as m}from"path";import{saveFileSync as o,scanRouter as t,sitemap as r}from"@moneko/mdx";import{resolveProgram as e}from"./index.mjs";import{outputConfig as p}from"../common.mjs";import{CONFIG as i}from"../config.mjs";import{routeDir as s}from"../paths.mjs";import{isLibrary as f}from"../process-env.mjs";export default(()=>{let{domain:n,nojekyll:a,path:j}=i.seo||{},l=j&&e(j)||p?.path;if(!n||!l)return;let x=`https://${n}${i.basename}`;o(m(l,"CNAME"),n),o(m(l,"robots"),`Sitemap: ${x}/sitemap.txt`),o(m(l,"sitemap.txt"),r(s,x,t(s,f)).join("\n")),a&&o(m(l,".nojekyll"),"")});
@@ -0,0 +1,3 @@
1
+ import { type DotenvParseOutput } from 'dotenv';
2
+ declare function setupEnv(mode: string, type: string, framework: string): DotenvParseOutput;
3
+ export default setupEnv;
@@ -0,0 +1 @@
1
+ import{relative as r}from"path";import{config as t}from"dotenv";import o from"../paths.mjs";export default function(e,a,p){let n=[r(o.programPath,".env"),r(o.programPath,".env/.env"),r(o.programPath,`.env/.${"production"===e?"prod":"dev"}.env`)],m={NODE_ENV:e,APPTYPE:a,FRAMEWORK:p};return n.forEach(r=>{let o=t({path:r,override:!0}).parsed;o&&Object.assign(m,o)}),m}
@@ -1,4 +1,4 @@
1
1
  import ReactiveObject from '../utils/reactive-object.mjs';
2
2
  export declare const exampleModuleName = "@app/example";
3
3
  export declare const examples: ReactiveObject<Record<string, string>>;
4
- export declare function generatorDemo(): void;
4
+ export declare function generatorExample(): void;
@@ -1 +1 @@
1
- import{generateExample as e}from"@moneko/mdx";import{watchFiles as t}from"./utils.mjs";import o from"../paths.mjs";import{isDev as r,isLibrary as m}from"../process-env.mjs";import p from"../utils/reactive-object.mjs";import a from"../rule.mjs";export const exampleModuleName="@app/example";function n(){if(!m)return{};let t={},r=JSON.parse(e(o.componentsPath,`${exampleModuleName}/`));for(let e in r)Object.prototype.hasOwnProperty.call(r,e)&&Object.assign(t,{[e]:`rr(() => import('${e}'))rr`});return{[exampleModuleName]:`export default ${JSON.stringify(t).replace(a.extract_func,"$1")}`,...r}}export const examples=new p(n());export function generatorDemo(){let e=n();for(let t in e)Object.prototype.hasOwnProperty.call(e,t)&&examples.setData(t,e[t])}m&&r&&t(o.componentsPath,/(?<!\/examples\/(.+)\.md)$/,generatorDemo);
1
+ import{generateExample as e}from"@moneko/mdx";import{watchFiles as t}from"./utils.mjs";import r from"../paths.mjs";import{isDev as o,isLibrary as m}from"../process-env.mjs";import p from"../utils/reactive-object.mjs";import a from"../rule.mjs";export const exampleModuleName="@app/example";function l(){if(!m)return{};let t=JSON.parse(e(r.componentsPath,`${exampleModuleName}/`)),o={};for(let e in t)Object.prototype.hasOwnProperty.call(t,e)&&Object.assign(o,{[e]:`rr(() => import('${e}'))rr`});return{...t,[`${exampleModuleName}/index.js`]:`export default ${JSON.stringify(o).replace(a.extract_func,"$1")}`}}export const examples=new p(l());export function generatorExample(){let e=l();for(let t in e)Object.prototype.hasOwnProperty.call(e,t)&&examples.setData(t,e[t])}m&&o&&t(r.componentsPath,/(?<!\/examples\/(.+)\.md)$/,generatorExample);
@@ -1 +1 @@
1
- import{join as m}from"path";import{getAppEntry as o,getAppFallback as e,getAppMdxScope as r,getAppMergeRouter as p,getAppNormalizeCss as t,getAppPrefixRouter as a,getAppRem as s,getAppSuspense as i}from"@moneko/mdx";import f from"./coverage.mjs";import{docs as n,docsModuleName as l}from"./docs.mjs";import{exampleModuleName as c,examples as x}from"./example.mjs";import d from"./info.mjs";import{locales as g,localesModuleName as j}from"./locales.mjs";import{route as u,routesModuleName as h}from"./routes.mjs";import{CONFIG as v}from"../config.mjs";import D from"../paths.mjs";import{APPTYPE as k,FRAMEWORK as z}from"../process-env.mjs";import{node_modules as b,resolveProgramPath as y}from"../utils/index.mjs";let C={[b("@app/info")]:`export default ${JSON.stringify(d)}`,[b("@app/entry")]:o(m(v.alias["@"],"./index.ts"),!!v.rem,!!v.normalizeCss,k,z),[b("@app/rem")]:s(v.rem?.designSize||1680),[b("@app/fallback")]:e(v.fallbackCompPath),[b("@app/coverage")]:f(D.coveragePath),[b("@app/merge-router")]:p(),[b("@app/prefix-router")]:a(),[b("@app/normalize/index.css")]:t(),[b("@app/suspense/index.tsx")]:i(k,z),[b("@app/mdx-scope")]:r(y("site/mdx-scope.ts")),[b(c)]:x.getData(c),[b(h)]:u.getData(h),[b(j)]:g.getData(j),[b(l)]:n.getData(l)};export default C;
1
+ import{join as e}from"path";import{getAppEntry as o,getAppFallback as p,getAppMdxScope as r,getAppMergeRouter as m,getAppNormalizeCss as t,getAppPrefixRouter as a,getAppRem as s,getAppSuspense as i}from"@moneko/mdx";import f from"./coverage.mjs";import{docs as n,docsModuleName as l}from"./docs.mjs";import c from"./info.mjs";import{locales as d,localesModuleName as x}from"./locales.mjs";import{route as g,routesModuleName as j}from"./routes.mjs";import{CONFIG as u}from"../config.mjs";import v from"../paths.mjs";import{APPTYPE as h,FRAMEWORK as k}from"../process-env.mjs";import{node_modules as y,resolveProgram as z}from"../utils/index.mjs";let D={[y("@app/env")]:`export default ${JSON.stringify(u.env)}`,[y("@app/info")]:`export default ${JSON.stringify(c)}`,[y("@app/entry")]:o(e(u.alias["@"],"./index.ts"),!!u.rem,!!u.normalizeCss,h,k),[y("@app/rem")]:s(u.rem?.designSize||1680),[y("@app/fallback")]:p(u.fallbackCompPath),[y("@app/coverage")]:f(v.coveragePath),[y("@app/merge-router")]:m(),[y("@app/prefix-router")]:a(),[y("@app/normalize/index.css")]:t(),[y("@app/suspense/index.tsx")]:i(h,k),[y("@app/mdx-scope")]:r(z("site/mdx-scope.ts")),[y(j)]:g.getData(j),[y(x)]:d.getData(x),[y(l)]:n.getData(l)};export default D;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moneko/core",
3
- "version": "3.11.1-beta.9",
3
+ "version": "3.11.2",
4
4
  "description": "core",
5
5
  "main": "lib/index.mjs",
6
6
  "type": "module",
@@ -21,6 +21,7 @@
21
21
  "core-js": "3.36.1",
22
22
  "core-js-compat": "3.36.1",
23
23
  "css-loader": "7.1.1",
24
+ "dotenv": "16.4.5",
24
25
  "enhanced-resolve": "5.16.0",
25
26
  "express": "4.19.2",
26
27
  "html-webpack-plugin": "5.6.0",
@@ -40,7 +41,6 @@
40
41
  "webpack-dev-middleware": "7.2.1",
41
42
  "webpack-hot-middleware": "2.26.1",
42
43
  "webpack-merge": "5.10.0",
43
- "webpack-node-externals": "3.0.0",
44
44
  "webpack-virtual-modules": "0.6.1",
45
45
  "xml2js": "0.6.2"
46
46
  },
@@ -48,6 +48,8 @@
48
48
  "@swc/cli": "0.3.12",
49
49
  "@types/express": "4.17.21",
50
50
  "@types/multer": "1.4.11",
51
+ "@types/webpack-bundle-analyzer": "4.7.0",
52
+ "@types/webpack-hot-middleware": "2.25.9",
51
53
  "sass": "1.75.0",
52
54
  "sass-loader": "14.2.0"
53
55
  },
@@ -262,14 +262,14 @@ export declare type ConfigType = {
262
262
  /** 覆盖解析插件配置, 当设置为 `{}` 时为启用
263
263
  * @default false
264
264
  * @example
265
- * import { resolveProgramPath } from '@moneko/core';
265
+ * import { resolveProgram } from '@moneko/core';
266
266
  *
267
267
  * // 此时当 src 和 src-test 目录下有相同相对路径的文件时,
268
268
  * // 将优先使用 src-test 下的文件进行解析
269
269
  * const conf = {
270
270
  * overrideResolve: {
271
- * original: resolveProgramPath('src'), // 这里可以省略, 默认为 src 目录, 当为组件库时, 默认为 site 目录
272
- * override: resolveProgramPath('src-test'),
271
+ * original: resolveProgram('src'), // 这里可以省略, 默认为 src 目录, 当为组件库时, 默认为 site 目录
272
+ * override: resolveProgram('src-test'),
273
273
  * }
274
274
  * }
275
275
  */
@@ -1,11 +0,0 @@
1
- import type { Compiler } from 'webpack';
2
- export interface VirtualModulePluginOption {
3
- [key: string]: string | object;
4
- }
5
- export declare class ExamplesWebpackPlugin {
6
- private hasTapped;
7
- private virtualModules;
8
- constructor();
9
- private modify;
10
- apply(compiler: Compiler): void;
11
- }
@@ -1 +0,0 @@
1
- import t from"webpack-virtual-modules";import{node_modules as i}from"../utils/index.mjs";import{examples as e}from"../vm/example.mjs";export class ExamplesWebpackPlugin{constructor(){this.hasTapped=!1,this.virtualModules=new t}modify(t,e,s){let l=s||"",o=i(e),p=t?.inputFileSystem;for(;p&&p._inputFileSystem;)p=p._inputFileSystem;let a=p._virtualFiles[o];a&&a.contents===l||this.virtualModules.writeModule(o,l)}apply(t){this.virtualModules.apply(t);let i=this.modify.bind(this,t);e.on("change",i),t.hooks.compilation.tap("ExamplesWebpackPlugin",()=>{if(!this.hasTapped)for(let t of(this.hasTapped=!0,e))i(t[0],t[1])})}}
@@ -1,3 +0,0 @@
1
- import type { Compiler } from 'webpack';
2
- declare function compilerListener(name: string, compiler: Compiler): Promise<unknown>;
3
- export default compilerListener;
@@ -1 +0,0 @@
1
- import o from"./log.mjs";export default function(r,e){return new Promise((n,t)=>{e.hooks.failed.tap(r,o=>{t(o)}),e.hooks.done.tap(r,r=>{r.hasErrors()||n(!0);for(let e=0,n=r.compilation.warnings.length;e<n;e++)o(r.compilation.warnings[e].message);for(let e=0,n=r.compilation.errors.length;e<n;e++)o(r.compilation.errors[e].message)})})}