@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.
- package/lib/build/server.mjs +1 -1
- package/lib/build.mjs +1 -1
- package/lib/common.mjs +1 -1
- package/lib/config.mjs +1 -1
- package/lib/dev.mjs +1 -1
- package/lib/index.d.mts +1 -1
- package/lib/index.mjs +1 -1
- package/lib/module.config.mjs +1 -1
- package/lib/options/html-plugin-option.mjs +1 -1
- package/lib/paths.d.mts +5 -1
- package/lib/paths.mjs +1 -1
- package/lib/plugin/virtual-module.d.mts +1 -1
- package/lib/plugin/virtual-module.mjs +1 -1
- package/lib/process-env.d.mts +1 -0
- package/lib/process-env.mjs +1 -1
- package/lib/utils/index.d.mts +2 -4
- package/lib/utils/index.mjs +1 -1
- package/lib/utils/reactive-object.mjs +1 -1
- package/lib/utils/seo.mjs +1 -1
- package/lib/utils/setup-env.d.mts +3 -0
- package/lib/utils/setup-env.mjs +1 -0
- package/lib/vm/example.d.mts +1 -1
- package/lib/vm/example.mjs +1 -1
- package/lib/vm/modules.mjs +1 -1
- package/package.json +4 -2
- package/typings/global.d.ts +3 -3
- package/lib/plugin/examples-plugin.d.mts +0 -11
- package/lib/plugin/examples-plugin.mjs +0 -1
- package/lib/utils/compiler-listener.d.mts +0 -3
- package/lib/utils/compiler-listener.mjs +0 -1
package/lib/build/server.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"
|
|
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
|
|
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{
|
|
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{
|
|
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
|
|
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,
|
|
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,
|
|
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;
|
package/lib/module.config.mjs
CHANGED
|
@@ -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{
|
|
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{
|
|
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
|
|
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
|
|
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])})}}
|
package/lib/process-env.d.mts
CHANGED
|
@@ -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;
|
package/lib/process-env.mjs
CHANGED
|
@@ -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"===
|
|
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;
|
package/lib/utils/index.d.mts
CHANGED
|
@@ -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
|
|
7
|
+
export declare function resolveProgram<T extends string>(src: T): ProgramPath<T>;
|
|
9
8
|
/** 位于项目根目录node_modules下的位置
|
|
10
|
-
* @param {string}
|
|
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 路径
|
package/lib/utils/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{resolve as
|
|
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{
|
|
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 @@
|
|
|
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}
|
package/lib/vm/example.d.mts
CHANGED
|
@@ -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
|
|
4
|
+
export declare function generatorExample(): void;
|
package/lib/vm/example.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{generateExample as e}from"@moneko/mdx";import{watchFiles as t}from"./utils.mjs";import
|
|
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);
|
package/lib/vm/modules.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{join as
|
|
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.
|
|
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
|
},
|
package/typings/global.d.ts
CHANGED
|
@@ -262,14 +262,14 @@ export declare type ConfigType = {
|
|
|
262
262
|
/** 覆盖解析插件配置, 当设置为 `{}` 时为启用
|
|
263
263
|
* @default false
|
|
264
264
|
* @example
|
|
265
|
-
* import {
|
|
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:
|
|
272
|
-
* override:
|
|
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 +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)})})}
|