@moneko/core 3.0.0 → 3.0.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/app.js +1 -1
- package/lib/common.js +1 -1
- package/lib/generate-api.js +1 -1
- package/lib/module.config.js +1 -1
- package/lib/process-env.d.ts +0 -1
- package/lib/process-env.js +1 -1
- package/lib/seo.js +1 -1
- package/lib/webpack.common.js +1 -1
- package/lib/webpack.dev.js +1 -1
- package/package.json +1 -1
- package/typings/global.d.ts +1 -23
package/lib/app.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{readFileSync as e}from"fs";import{CONFIG as r}from"./common.js";import{APPTYPE as o,PACKAGENAME as p,PACKAGEVERSION as s}from"./process-env.js";import{resolveProgramPath as t,toUpperCaseString as a}from"./utils.js";let n={name:p,projectName:JSON.stringify(a(p).replace(/-/g," ")),version:s,base:r.
|
|
1
|
+
import{readFileSync as e}from"fs";import{CONFIG as r}from"./common.js";import{APPTYPE as o,PACKAGENAME as p,PACKAGEVERSION as s}from"./process-env.js";import{resolveProgramPath as t,toUpperCaseString as a}from"./utils.js";let n={name:p,projectName:JSON.stringify(a(p).replace(/-/g," ")),version:s,base:r.basename,type:o,routerMode:r.routerMode,prefixCls:r.prefixCls,theme:r.theme,description:process.env.npm_package_description,author:{name:process.env.npm_package_author_name,email:process.env.npm_package_author_email,url:process.env.npm_package_author_url},repository:{type:process.env.npm_package_repository_type,url:process.env.npm_package_repository_url,directory:process.env.npm_package_repository_directory}};if(parseInt(process.versions.node)>14){let r=e(t("package.json"),{encoding:"utf-8"}),{description:o,author:p,repository:s}=JSON.parse(r);n.author="string"==typeof p?{name:p}:p,n.repository="string"==typeof p?{url:s}:s,n.description=o}export default n;
|
package/lib/common.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{accessSync as e,constants as t}from"fs";import{join as o}from"path";import s from"readline";import r from"chalk";import{merge as i}from"webpack-merge";import{APPTYPE as n,CUSTOMCONFIG as a,FRAMEWORK as l,PACKAGENAME as c,PROGRAMPATH as m,jsxImportSource as
|
|
1
|
+
import{accessSync as e,constants as t}from"fs";import{join as o}from"path";import s from"readline";import r from"chalk";import{merge as i}from"webpack-merge";import{APPTYPE as n,CUSTOMCONFIG as a,FRAMEWORK as l,PACKAGENAME as c,PROGRAMPATH as m,jsxImportSource as p,pkgName as u}from"./process-env.js";import{isFunction as d,readConf as h,resolveProgramPath as f}from"./utils.js";export const ENTRYPATH={mobile:"mobile",site:"site",backstage:"backstage",micro:"micro",library:"library"};let g=["@moneko/core",`@moneko/${l}`,"neko-ui","antd","@antv","katex","font-pingfang-sc","font-pingfang-tc","react-photo-view","react-markdown-editor-lite","schema-design","@app"],x={library:{"@":f("site"),"@pkg":f("components"),[c]:f("components")},mobile:{},site:{},backstage:{},micro:{}},b={seo:!1,mode:"csr",compiler:"swc",bundleAnalyzer:!1,entry:{},minifier:{js:{},css:{}},sourceMap:{filename:"[file].map",publicPath:""},env:{},basename:"/",publicPath:"/",rem:{designSize:"mobile"===n?375:1680},fallbackCompPath:null,modifyVars:{},prefixCls:"n",alias:Object.assign({"@":f("src")},x[n]),moduleRules:[],prefixJsLoader:[],cssModules:[],importOnDemand:{},proxy:[],cacheDirectory:`${m}/node_modules/.temp_cache`,devServer:{allowedHosts:[".baidu.com"],host:"localhost",port:3e3,https:!1,compress:!1},htmlPluginOption:{template:`./node_modules/${u}/template/index.html`,favicon:`./node_modules/${u}/template/favicon.ico`,tags:[]},assetHtml:[],routerMode:"browser",fixBrowserRouter:!1,plugins:[],splitChunk:{chunks:"all",minSize:1024,minChunks:1,cacheGroups:{route:{test:/[\\/].git[\\/]router/,priority:-10,reuseExistingChunk:!0,name:"route"},example:{test:/[\\/].git[\\/]example/,priority:-10,reuseExistingChunk:!0,name:"example"}}},runtimeChunk:"single",moduleFederation:[],rulesInclude:{less:g,css:g,js:g,media:g,fonts:g},mdx:{jsxImportSource:p,useDynamicImport:!0,remarkPlugins:[],rehypePlugins:[]},jsxDomExpressions:{moduleName:"solid-js/web",builtIns:["For","Show","Switch","Match","Suspense","SuspenseList","Portal","Index","Dynamic","ErrorBoundary"],contextToCustomElements:!0,wrapConditionals:!0,generate:"dom",hydratable:!1},bar:{name:"编译中",color:"#6f42c1"},virtualModule:{},normalizeCss:!0,externalsPresets:{}};export const log=e=>{s.cursorTo(process.stdout,0),process.stdout.write(e)};let y=b,C=null,w={},k={};try{C=o(m,"./config/index.ts"),e(C,t.R_OK)}catch(e){C=null}if(C)try{let e=(await h(C,"index")).default;w=d(e)?e(process):e}catch(e){process.stdout.write(r.red(e))}if(a){let s=null;try{s=o(m,`./config/${a}.ts`),e(s,t.R_OK)}catch(e){s=null}if(null!==s)try{let e=(await h(s,a)).default;k=d(e)?e(process):e}catch(e){process.stdout.write(r.red(e))}}"tsc"===(y=i(y,w,k)).compiler&&y.minifier&&(y.minifier.js||Object.assign(y.minifier,{js:{type:"terser"}}),y.minifier.css||Object.assign(y.minifier,{css:{type:"cssnano"}})),!1===y.devtool&&(y.sourceMap=!1),!1===y.sourceMap&&(y.devtool=!1),y.fixBrowserRouter&&y.htmlPluginOption&&(y.htmlPluginOption.tags||(y.htmlPluginOption.tags=[]),y.htmlPluginOption.tags.push({textContent:'!function(n){var a=location.search.slice(1);if("/"===a[0]){for(var o=[],c=decodeURIComponent(a).split("&"),e=0,t=c.length;e<t;e++)o.push(c[e].replace(/~and~/g,"&"));var l=o.join("?");l!==a&&window.history.replaceState(null,null,"".concat(n.pathname.slice(0,-1),"?").concat(l).concat(n.hash))}}(window.location);'}));export const CONFIG=y;export const PUBLICPATH=CONFIG.publicPath||"/";export let hasCustomRouter=!1;try{e(o(CONFIG.alias["@"],"./router/index.ts"),t.R_OK),hasCustomRouter=!0}catch(e){hasCustomRouter=!1}global.NEKOCLICONFIG={CONFIG,log};
|
package/lib/generate-api.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{readFileSync as e}from"fs";import{dirname as t}from"path";import n from"typescript";import{CONFIG as r}from"./common.js";let{ScriptKind:l,ScriptTarget:o,SyntaxKind:i,createSourceFile:
|
|
1
|
+
import{readFileSync as e}from"fs";import{dirname as t}from"path";import n from"typescript";import{CONFIG as r}from"./common.js";let{ScriptKind:l,ScriptTarget:o,SyntaxKind:i,createSourceFile:a,forEachChild:c,getLeadingCommentRanges:u,isInterfaceDeclaration:s,isQuestionToken:f,isPropertySignature:m,isFunctionTypeNode:p,isUnionTypeNode:$,isMethodSignature:g}=n,h={};function b(e){let t=u(e.getSourceFile().text,e.pos);if(t){let n=e.getSourceFile().text.substring(t[0].pos,t[0].end),r=n.match(/\/\*\*([\s\S]*?)\*\//);if(r){let e=r[1].replace(/^\s*\* ?/gm,"").replace(/\s+$/,"").trim();return e}}return null}function d(e){if(!e)return null;let t=e.match(/@since\s+([^\n]+)/);return t?t[1].trim():null}function y(e){if(!e)return null;let t=e.match(/@author (\w+)\s*(?:<([^>]+)>)?/);if(t?.length){let e=t[1].trim(),n=t[2]?.trim(),r=/^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$/.test(n);return n?r&&(n=`mailto:${n}`):n=`https://github.com/${e}`,`[${e}](${n})`}return null}function x(e){if(!e)return null;let t=e.match(/@ignore\s+([^\n]+)/);return t?t[1].trim():null}let j=/(?<!['"])(unknown|any|void|bigint|object|undefined|null|boolean|number|string|symbol)(?!['"])/g;function T(e,t){if(!e)return null;let n=e.replace(/\b([A-Z][a-zA-Z0-9]*)\b/g,e=>{if(h[e]){let n=`/${[r.basename,h[e]].join("/").split("/").filter(Boolean).join("/")}`;return t?`[\\color{#009688}{${e}}](${n})`:`[${e}](${n})`}return t?`\\color{#009688}{${e}}`:e});return t&&(n=n.replace(j,e=>`\\color{#009688}{${e}}`)),n}function B(e){return(function(e){let t;if(!e)return null;let n=[];for(;t=/\\color{([^|}]*)\|?([^|}]*)\|?([^|}]*)\|?([^}]*)}{([^}]*)}/g.exec(e);)n.push(t[0]);return e.replace(/(\{|\}|\[|\]|\(|\)|=>|keyof|typeof|true|false)/g,e=>n.some(t=>t.includes(e))?e:`\\color{#569cd6}{${e}}`)})(e)?.replace(/^\s*\|\s*|\s*\|\s*$/gm,"").replace(/\n/g,"<br/>").replace(/\*/g,"\\*").replace(/\|/g,"\\|").replace(/(['"])((?:(?!\1).)*)\1/g,"\\color{#ce9178}{$1$2$1}")}function k(e){return e?e.replace(/^@[a-z].+/gm,"").replace(/(\n\s+)+/g,"<br />").replace(/\n/g,"<br />").replace(/(<br \/>)$/g,""):null}export default function w(u){let j=e(u,"utf-8"),w=a(u,j,o.Latest,!0,l.TS),E="";return c(w,e=>{s(e)?E+=function(e){let l=e.name.text;Object.assign(h,{[e.name.text]:t(e.getSourceFile().fileName).replace(r.alias["@pkg"],"")});let o=b(e),a=d(o),c=k(o),u=x(o)?.split("|")||[],s=u.includes("comment"),j=u.includes("initial"),w=u.includes("optional"),E=u.includes("version"),S=u.includes("author"),v=c?`\\color{|4||0.45}{${l}}`:l,F=(function(e){let t=[];if(e.heritageClauses){for(let r of e.heritageClauses)if(r.token===n.SyntaxKind.ExtendsKeyword)for(let e of r.types)t.push(e.getText())}return t})(e)?.map(e=>`<n-tag color="#4c81db" css=".tag{gap:0px;}">${T(B(e))}</n-tag>`),z=[c,v,a&&`\\color{#52c11b|1||0.9}{${a}}`,F.length>0&&`<sub>\`extends\`</sub> ${F.join(" ")}`].filter(Boolean).join(" "),K=`## ${z}`,N=e.members.filter(e=>m(e)&&e.type?.kind!==i.NeverKeyword||g(e)),q=[];if(N.length){N.forEach(e=>{let t=T(B(g(e)?`(${e.parameters.map(e=>`${e.name.getText()}: ${e.type?.getText()||"any"}`).join(", ")}): ${e.type?.getText()||"any"}`:e.type?.getText()||"any"),!0),n=b(e),r=B(e.name.getText());!r||r.startsWith("\\color")||(g(e)||function(e){if(e.type){if(!$(e.type))return p(e.type);for(let t of e.type.types)if(p(t))return!0}return!1}(e)||t?.includes("=>")?r=`\\color{#f9a913}{${r}}`:/^("|')(.+)("|')$/.test(r)||(r=`\\color{#4c81db}{${r}}`));let l=e.questionToken&&f(e.questionToken);q.push([r,!w&&`\\color{${l?"#f9a913":"#52c11b"}\\|\\|\\|0.9}{${l?"✘":"✔"}}`,!s&&B(k(n)),t,!j&&B(function(e){if(!e)return null;let t=e.match(/@default\s+([^\n]+)/);return t?t[1].trim():null}(n)),!E&&B(d(n)),!S&&(y(n)||y(o))])});let e=!1,t=!1,n=!1,r=!1;q.forEach(l=>{!s&&l[2]&&(r=!0),!j&&l[4]&&(n=!0),!E&&l[5]&&(t=!0),!S&&l[6]&&(e=!0)}),K+="\n";let l=["属性",!w&&"必要",r&&"说明","类型",n&&"默认值",t&&"版本",e&&"作者"].filter(Boolean).join("|");K+=`|${l}|`;let i=[":-",!w&&":-",r&&":-",":-",n&&":-",t&&":-",e&&":-"].filter(Boolean);K+="\n";let a=i.join("|");K+=`|${a}|`,q.forEach(l=>{K+="\n";let o=[l[0]||"-",!w&&(l[1]||"-"),r&&(l[2]||"-"),l[3]||"-",n&&(l[4]||"-"),t&&(l[5]||"-"),e&&(l[6]||"-")].filter(Boolean).join("|");K+=`|${o}|`}),K+="\n"}return K+="\n"}(e):n.isEnumDeclaration(e)&&(E+=function(e){let l=e.name.text,o=b(e),i=k(o),a=d(o);Object.assign(h,{[e.name.text]:t(e.getSourceFile().fileName).replace(r.alias["@pkg"],"")});let c=i?`\\color{|4||0.45}{${l}}`:l,u=[i,c,a&&`\\color{#52c11b|1||0.9}{${a}}`].filter(Boolean).join(" "),s=x(o)?.split("|")||[],f=s.includes("comment"),m=s.includes("version"),p=s.includes("author"),$=`## ${u}`;if(e.members.length){let t=[];e.members.forEach(e=>{let r=B(e.name.getText()),l=b(e),i=B(function(e){let t=e.initializer;return t&&n.isStringLiteral(t)?` '${t.text}'`:null}(e)),a=B(d(l)),c=B(k(l));!r||r.startsWith("\\color")||/^("|')(.+)("|')$/.test(r)||(r=`\\color{#4c81db}{${r}}`),t.push([r,!f&&c,i,!m&&a,!p&&(y(l)||y(o))])});let r=!1,l=!1,i=!1;t.forEach(e=>{!f&&e[1]&&(i=!0),!m&&e[3]&&(l=!0),!p&&e[4]&&(r=!0)}),$+="\n";let a=["属性",i&&"说明","值",l&&"版本",r&&"作者"].filter(Boolean).join("|");$+=`|${a}|`;let c=[":-",i&&":-",":-",l&&":-",r&&":-"].filter(Boolean);$+="\n";let u=c.join("|");$+=`|${u}|`,t.forEach(e=>{$+="\n";let t=[e[0]||"-",i&&(e[1]||"-"),e[2]||"-",l&&(e[3]||"-"),r&&(e[4]||"-")].filter(Boolean).join("|");$+=`|${t}|`})}return $+="\n\n"}(e))}),E}
|
package/lib/module.config.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{resolve as e}from"path";import s from"mini-css-extract-plugin";import o from"mini-svg-data-uri";import{CONFIG as t,PUBLICPATH as l}from"./common.js";import{hasPkg as r}from"./has-pkg.js";import a from"./modify-vars.js";import{FRAMEWORK as i,__dirname as n,isDev as c,isMicro as m}from"./process-env.js";import p from"./swcrc.js";import d from"./tsloader.config.js";import{resolveNodeModulesPath as u,resolveProgramPath as f}from"./utils.js";let y={loader:e(n,"./loader/css-unicode.cjs")},x=m?l:"../",$={loader:s.loader,options:{publicPath:"/"!==x?x:"../"}},g=r("@moneko/postcss")&&{loader:"postcss-loader",options:{postcssOptions:await import("@moneko/postcss")}};c&&($="style-loader");let j=[...t.cssModules,`@moneko/${i}`,"neko-ui"].map(u),v=[...["src/styles/variables.less","src/styles/mixins.less","site/styles/variables.less","site/styles/mixins.less"].map(f)],b=["components","example","mock","site","src","server"].map(f),w=[$,{loader:"@teamsupercell/typings-for-css-modules-loader",options:{verifyOnly:!c}},{loader:"css-loader",options:{modules:{auto:e=>{for(let s=0,o=j.length;s<o;s++)if(e&&e?.includes(j[s]))return/(.*(?<!\.?global\.(le|c)ss)$)/i.test(e);return/(^(?!.*node_modules))(.*(?<!\.?global\.(le|c)ss)$)/i.test(e)},localIdentName:"[path][name]__[local]",exportLocalsConvention:"dashesOnly"},importLoaders:2}},g,y,{loader:"less-loader",options:{sourceMap:!!t.sourceMap,lessOptions:{modifyVars:a,javascriptEnabled:!0}}},{loader:"style-resources-loader",options:{patterns:v}}].filter(Boolean),h={loader:"tsc"===t.compiler?"ts-loader":"swc-loader",options:"tsc"===t.compiler?d:p(c)},k=b.concat(t.rulesInclude?.media?.map(u)||[]),I=b.concat(t.rulesInclude?.fonts?.map(u)||[]),O=b.concat(t.rulesInclude?.less?.map(u)||[]),B=b.concat(t.rulesInclude?.css?.map(u)||[]),L=b.concat(t.rulesInclude?.js?.map(u)||[]),M={rules:[{test:/\.mdx?$/i,include:[f("components")],exclude:[/(.+)\/examples\/(.+).mdx?$/i],enforce:"pre",use:[{loader:e(n,"./loader/frontmatter.cjs")}]},{oneOf:[{resourceQuery:/raw/,type:"asset/source"},{test:/\.wasm$/i,type:"webassembly/async"},{test:/\.txt$/i,type:"asset/source"},{test:/\.ico$/i,type:"asset/inline",include:k},{test:/\.svg$/i,type:"asset/inline",generator:{dataUrl:e=>o("string"!=typeof e?e.toString():e)},include:k},{test:/\.(gif|png|jpe?g|mp4)$/i,type:"asset",dependency:{not:["url"]},generator:{filename:"assets/images/[name][ext][query]"},include:k},{test:/\.(eot|ttf|otf|woff|woff2)$/i,type:"asset",generator:{filename:"assets/fonts/[name][ext][query]"},include:I},{test:/\.less$/i,use:w,include:O},{test:/\.css$/i,use:[$,"css-loader",g,y].filter(Boolean),include:B},{test:/\.(cj|mj|t|j)s(|x)$/i,use:[...t.prefixJsLoader,h].filter(Boolean),include:L},{test:/\.mdx?$/i,use:[...t.prefixJsLoader,h,{loader:"@mdx-js/loader",options:t.mdx}].filter(Boolean),include:b,exclude:[/(.+)\/examples\/(.+).mdx?$/i]},{test:/\.mdx?$/i,type:"asset/source",include:[/(.+)\/examples\/(.+).mdx?$/i]},{type:"asset/source",include:[/(.+)\/examples\/(.+).*?$/i]}]},...t.moduleRules]};export default M;
|
|
1
|
+
import{resolve as e}from"path";import s from"mini-css-extract-plugin";import o from"mini-svg-data-uri";import{CONFIG as t,PUBLICPATH as l}from"./common.js";import{hasPkg as r}from"./has-pkg.js";import a from"./modify-vars.js";import{FRAMEWORK as i,__dirname as n,isDev as c,isMicro as m}from"./process-env.js";import p from"./swcrc.js";import d from"./tsloader.config.js";import{resolveNodeModulesPath as u,resolveProgramPath as f}from"./utils.js";let y={loader:e(n,"./loader/css-unicode.cjs")},x=m?l:"../",$={loader:s.loader,options:{publicPath:"/"!==x?x:"../"}},g=r("@moneko/postcss")&&{loader:"postcss-loader",options:{postcssOptions:await import("@moneko/postcss")}};c&&($="style-loader");let j=[...t.cssModules,`@moneko/${i}`,"neko-ui"].map(u),v=[...["src/styles/variables.less","src/styles/mixins.less","site/styles/variables.less","site/styles/mixins.less"].map(f)],b=["components","example","mock","site","src","server"].map(f),w=[$,c&&{loader:"@teamsupercell/typings-for-css-modules-loader",options:{verifyOnly:!c}},{loader:"css-loader",options:{modules:{auto:e=>{for(let s=0,o=j.length;s<o;s++)if(e&&e?.includes(j[s]))return/(.*(?<!\.?global\.(le|c)ss)$)/i.test(e);return/(^(?!.*node_modules))(.*(?<!\.?global\.(le|c)ss)$)/i.test(e)},localIdentName:"[path][name]__[local]",exportLocalsConvention:"dashesOnly"},importLoaders:2}},g,y,{loader:"less-loader",options:{sourceMap:!!t.sourceMap,lessOptions:{modifyVars:a,javascriptEnabled:!0}}},{loader:"style-resources-loader",options:{patterns:v}}].filter(Boolean),h={loader:"tsc"===t.compiler?"ts-loader":"swc-loader",options:"tsc"===t.compiler?d:p(c)},k=b.concat(t.rulesInclude?.media?.map(u)||[]),I=b.concat(t.rulesInclude?.fonts?.map(u)||[]),O=b.concat(t.rulesInclude?.less?.map(u)||[]),B=b.concat(t.rulesInclude?.css?.map(u)||[]),L=b.concat(t.rulesInclude?.js?.map(u)||[]),M={rules:[{test:/\.mdx?$/i,include:[f("components")],exclude:[/(.+)\/examples\/(.+).mdx?$/i],enforce:"pre",use:[{loader:e(n,"./loader/frontmatter.cjs")}]},{oneOf:[{resourceQuery:/raw/,type:"asset/source"},{test:/\.wasm$/i,type:"webassembly/async"},{test:/\.txt$/i,type:"asset/source"},{test:/\.ico$/i,type:"asset/inline",include:k},{test:/\.svg$/i,type:"asset/inline",generator:{dataUrl:e=>o("string"!=typeof e?e.toString():e)},include:k},{test:/\.(gif|png|jpe?g|mp4)$/i,type:"asset",dependency:{not:["url"]},generator:{filename:"assets/images/[name][ext][query]"},include:k},{test:/\.(eot|ttf|otf|woff|woff2)$/i,type:"asset",generator:{filename:"assets/fonts/[name][ext][query]"},include:I},{test:/\.less$/i,use:w,include:O},{test:/\.css$/i,use:[$,"css-loader",g,y].filter(Boolean),include:B},{test:/\.(cj|mj|t|j)s(|x)$/i,use:[...t.prefixJsLoader,h].filter(Boolean),include:L},{test:/\.mdx?$/i,use:[...t.prefixJsLoader,h,{loader:"@mdx-js/loader",options:t.mdx}].filter(Boolean),include:b,exclude:[/(.+)\/examples\/(.+).mdx?$/i]},{test:/\.mdx?$/i,type:"asset/source",include:[/(.+)\/examples\/(.+).mdx?$/i]},{type:"asset/source",include:[/(.+)\/examples\/(.+).*?$/i]}]},...t.moduleRules]};export default M;
|
package/lib/process-env.d.ts
CHANGED
package/lib/process-env.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{existsSync as e,mkdirSync as o,readFileSync as t}from"fs";import{join as r}from"path";import s from"url";import
|
|
1
|
+
import{existsSync as e,mkdirSync as o,readFileSync as t}from"fs";import{join as r}from"path";import s from"url";import n from"./yarn-argv.js";export const __dirname=s.fileURLToPath(new URL(".",import.meta.url));export const APPTYPE=process.env.APPTYPE;export const FRAMEWORK=process.env.FRAMEWORK;export const isLibrary="library"===APPTYPE;export const isMicro="micro"===APPTYPE;export const isReact="react"===FRAMEWORK;export const isSolid="solid"===FRAMEWORK;export const jsxImportSource={react:"react",solid:"solid-js/h"}[FRAMEWORK];export const createElement={react:"createElement",solid:"createComponent"}[FRAMEWORK];export const FRAMEWORKNAME={react:"react",solid:"solid-js"}[FRAMEWORK];export const PROGRAMPATH=process.cwd();export const PACKAGENAME=process.env.npm_package_name;export const PACKAGEVERSION=process.env.npm_package_version;let c=t(r(__dirname,"../package.json"),{encoding:"utf-8"});export const pkgName=JSON.parse(c).name;export const isDev="development"===process.env.NODE_ENV;export const cacheDir=r(PROGRAMPATH,"./node_modules/.cache/.mo/");e(cacheDir)||o(cacheDir,{recursive:!0});export const CUSTOMCONFIG=process.env.npm_config_config||n.config;let p=Object.keys(process.env);export const hasEslintConfig=-1!==p.findIndex(e=>e.startsWith("npm_package_eslintConfig_"));export const hasStylelintConfig=-1!==p.findIndex(e=>e.startsWith("npm_package_stylelint_"));
|
package/lib/seo.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{existsSync as t,mkdirSync as o,writeFileSync as r}from"fs";import{join as
|
|
1
|
+
import{existsSync as t,mkdirSync as o,writeFileSync as r}from"fs";import{join as s}from"path";import{CONFIG as e}from"./common.js";import{routes as m}from"./routes.js";import{resolveProgramPath as i}from"./utils.js";import{outputConfig as p}from"./webpack.common.js";function n(t,o){try{r(t,o,"utf-8")}catch(t){}}export const seo=()=>{let{domain:r,nojekyll:c,path:a}=e.seo||{};if(!r)return;let f=e.basename,h=f.endsWith("/")?f:`${f}/`,l=a&&i(a)||p?.path||process.cwd();t(l)||o(l),n(s(l,"CNAME"),r),n(s(l,"robots"),`Sitemap: https://${r}${h}sitemap.txt`);let u=[];!function t(o){o.forEach(o=>{u.push(`https://${r}${h}${o.key}`),Array.isArray(o.children)&&t(o.children)})}(m),n(s(l,"sitemap.txt"),u.join("\n")),c&&n(s(l,".nojekyll"),"")};
|
package/lib/webpack.common.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"fs";import t from"add-asset-html-webpack-plugin";import s from"html-webpack-plugin";import
|
|
1
|
+
import e from"fs";import t from"add-asset-html-webpack-plugin";import s from"html-webpack-plugin";import n from"webpack";import o from"webpackbar";import"./cleanup.js";import{CONFIG as l,PUBLICPATH as r}from"./common.js";import i from"./done.js";import a from"./html-add-entry-attr.js";import p from"./html-plugin-option.js";import{moduleFederation as c}from"./module-federation.js";import m from"./module.config.js";import{CUSTOMCONFIG as u,PACKAGENAME as f,PROGRAMPATH as d,hasEslintConfig as h,hasStylelintConfig as y,isDev as j,isLibrary as g,isMicro as b}from"./process-env.js";import{seo as w}from"./seo.js";import{resolveNodeModulesPath as x,resolveProgramPath as k}from"./utils.js";import v from"./virtual-module-plugin.js";import C from"./virtual-modules.js";let{AutomaticPrefetchPlugin:O,DefinePlugin:$,SourceMapDevToolPlugin:D,WatchIgnorePlugin:N}=n,P=[".eslintrc.js",".eslintrc.json",".eslintrc.yaml",".eslintrc.json"],S=[".stylelintrc",".stylelintrc.json",".stylelintrc.yaml",".stylelintrc.yml",".stylelintrc.js","stylelint.config.js","stylelint.config.cjs"],A=e.readdirSync(d),B=!1,E=!1;for(let e=0,t=A.length;e<t;e++)S.includes(A[e])&&(E=!0),P.includes(A[e])&&(B=!0);B||(B=h),E||(E=y);let M=E?(await import("stylelint-webpack-plugin")).default:null,T=B?(await import("eslint-webpack-plugin")).default:null,_=l.assetHtml.map(e=>({publicPath:"",...e}));export const outputConfig={path:k(g?"docs":"dist"),filename:"js/[name].bundle.js",chunkFilename:"js/[chunkhash].js",assetModuleFilename:"assets/[hash][ext][query]",library:{name:f,type:"window"},globalObject:"window",chunkLoadingGlobal:`webpackJsonp_${f}`,pathinfo:j,clean:!0,publicPath:r,asyncChunks:!0};let K={main:x("@app/entry")};l.entry&&("string"==typeof l.entry?K=l.entry:Object.keys(l.entry)&&Object.assign(K,l.entry)),l.output&&("string"==typeof l.output?outputConfig.path=l.output:Object.keys(l.output)&&Object.assign(outputConfig,l.output));let L=l.basename.split("/").filter(Boolean).length,F=`${Array(L).fill("..").join("/")+(L?"/":"")}404.html`,{pathSegmentsToKeep:J=L,path:R=F}=l.fixBrowserRouter||{},V=!1;l.cacheDirectory&&(V={type:"filesystem",allowCollectingMemory:!0,cacheDirectory:l.cacheDirectory,memoryCacheUnaffected:!0,name:`${u||"default"}-${j?"development":"production"}`});export const clientConfig={entry:K,stats:"errors-only",cache:V,infrastructureLogging:{level:"none"},target:"web",externalsPresets:l.externalsPresets,plugins:[new O,...c,T&&new T({fix:!0,threads:!0,extensions:["js","md","mdx","cjs","ejs","mjs","jsx","ts","tsx","json","html","coffee","vue"]}),M&&new M({fix:!0,threads:!0,extensions:["css","scss","sass","less","ts","tsx","js","jsx"],exclude:["node_modules/","es/","lib/","docs/","coverage/","dist/"]}),l.htmlPluginOption&&new s(p),l.fixBrowserRouter&&new s({filename:R,inject:!1,templateContent:()=>`<html html><head><title>${p.title}</title><script>var pathSegmentsToKeep = ${J||L};var l = window.location;l.replace(l.protocol + '//' + l.hostname + (l.port ? ':' + l.port : '') + l.pathname.split('/').slice(0, 1 + pathSegmentsToKeep).join('/') + '/?/' + l.pathname.slice(1).split('/').slice(pathSegmentsToKeep).join('/').replace(/&/g, '~and~') + (l.search ? '&' + l.search.slice(1).replace(/&/g, '~and~') : '') + l.hash);</script></head><body></body></html>`}),new t(_),b&&new a(e=>!!(e.match(/main\.(.*)\.bundle.js$/)||e.match("main.bundle.js"))),new $({"process.env":JSON.stringify({...l.env,NODE_ENV:process.env.NODE_ENV})}),new N({paths:[/\.d\.ts$/]}),l.sourceMap&&new D(l.sourceMap),l.bar&&new o(l.bar),new i({done:()=>{!j&&l.seo&&w(),l.done?.(),j||setTimeout(()=>{process.exit(0)},2e3)}}),new v(C),...l.plugins].filter(Boolean),experiments:{topLevelAwait:!0,syncWebAssembly:!0,asyncWebAssembly:!0},resolve:{extensions:[".tsx",".ts",".js",".jsx"],alias:l.alias,fallback:{path:!1,fs:!1,crypto:!1,assert:!1}},module:m,externals:l.externals,output:outputConfig};
|
package/lib/webpack.dev.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import e from"@soda/friendly-errors-webpack-plugin";import o from"chalk";import r from"webpack";import{merge as t}from"webpack-merge";import{CONFIG as s}from"./common.js";import{hasPkg as p}from"./has-pkg.js";import{getIPv4 as a,getPort as i}from"./net.js";import{isReact as m}from"./process-env.js";import{isFunction as n,resolveProgramPath as l}from"./utils.js";import{clientConfig as d}from"./webpack.common.js";let{HotModuleReplacementPlugin:c}=r,{yellow:v,green:h}=o,f=a(),w=s.devServer.port||3e3,u=await i(w,65535,s.devServer.host),k=s.devServer.port!==u,g=p("@moneko/mock"),$=g&&(await import("@moneko/mock")).default,S=m&&(await import("@pmmmwh/react-refresh-webpack-plugin")).default,b=!1===s.devtool||s.devtool?s.devtool:"eval-cheap-module-source-map";s.devServer.port=u;let y="/"===s.
|
|
1
|
+
import e from"@soda/friendly-errors-webpack-plugin";import o from"chalk";import r from"webpack";import{merge as t}from"webpack-merge";import{CONFIG as s}from"./common.js";import{hasPkg as p}from"./has-pkg.js";import{getIPv4 as a,getPort as i}from"./net.js";import{isReact as m}from"./process-env.js";import{isFunction as n,resolveProgramPath as l}from"./utils.js";import{clientConfig as d}from"./webpack.common.js";let{HotModuleReplacementPlugin:c}=r,{yellow:v,green:h}=o,f=a(),w=s.devServer.port||3e3,u=await i(w,65535,s.devServer.host),k=s.devServer.port!==u,g=p("@moneko/mock"),$=g&&(await import("@moneko/mock")).default,S=m&&(await import("@pmmmwh/react-refresh-webpack-plugin")).default,b=!1===s.devtool||s.devtool?s.devtool:"eval-cheap-module-source-map";s.devServer.port=u;let y="/"===s.basename,j=s.devServer.https?"https:":"http:",x=y?"":s.basename,A=t(d,{devtool:b,mode:"development",devServer:{headers:{"Access-Control-Allow-Origin":"*"},compress:s.devServer.compress,host:"0.0.0.0",port:u,historyApiFallback:y||{index:x.endsWith("/")?x:`${x}/`,disableDotRule:!0},https:s.devServer.https,proxy:s.proxy,allowedHosts:s.devServer.allowedHosts,client:{progress:!1,logging:"info",overlay:!1},static:{watch:{ignored:e=>e.endsWith(".d.ts")||/\/node_modules\//.test(e)}},setupMiddlewares:(e,o)=>{if(!o)throw Error("webpack-dev-server is not defined");return o.app&&n($)&&$(o.app,l("mock/")),e},open:!1,hot:!0},plugins:[new c,S&&new S,new e({compilationSuccessInfo:{messages:[`You application is running here:
|
|
2
2
|
|
|
3
3
|
Local: ${o.cyan(`${j}//${s.devServer.host}:${u}${x}`)}
|
|
4
4
|
Network: ${o.cyan(`${j}//${f}:${u}${x}`)}`],notes:k?[`Port ${v(w)} is in use, trying ${h(u)} instead`]:[]},clearConsole:!0})].filter(Boolean)});export default[A];
|
package/package.json
CHANGED
package/typings/global.d.ts
CHANGED
|
@@ -95,7 +95,7 @@ export declare type ConfigType<T extends 'tsc' | 'swc' = 'swc'> = {
|
|
|
95
95
|
[key: string]: string;
|
|
96
96
|
};
|
|
97
97
|
/** 根路由 */
|
|
98
|
-
|
|
98
|
+
basename: string;
|
|
99
99
|
/** 输出目录前置路径
|
|
100
100
|
* @default /
|
|
101
101
|
* */
|
|
@@ -114,28 +114,6 @@ export declare type ConfigType<T extends 'tsc' | 'swc' = 'swc'> = {
|
|
|
114
114
|
* @default n
|
|
115
115
|
*/
|
|
116
116
|
prefixCls?: string;
|
|
117
|
-
/** 左侧菜单栏, 不需要时设置为 false, 仅 type: back-stage 时有效 */
|
|
118
|
-
layoutSider:
|
|
119
|
-
| false
|
|
120
|
-
| {
|
|
121
|
-
theme?: 'light' | 'dark';
|
|
122
|
-
breakpoint?: 'xs' | 'sm' | 'md' | 'lg' | 'xl' | 'xxl';
|
|
123
|
-
};
|
|
124
|
-
/** iconfont图标设置 */
|
|
125
|
-
iconfont?: {
|
|
126
|
-
/** 图标加载地址
|
|
127
|
-
* @example
|
|
128
|
-
* iconfont: {
|
|
129
|
-
* scriptUrl: [
|
|
130
|
-
* '//at.alicdn.com/t/font_2632005_n3kt9cjpzn.js', // icon one
|
|
131
|
-
* '//at.alicdn.com/t/font_2446726_525dowa25vp.js', // icon two
|
|
132
|
-
* ]
|
|
133
|
-
* }
|
|
134
|
-
*/
|
|
135
|
-
scriptUrl?: string | string[];
|
|
136
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
137
|
-
extraCommonProps?: Record<string, any>;
|
|
138
|
-
};
|
|
139
117
|
/** 主题设置 */
|
|
140
118
|
theme?: Theme;
|
|
141
119
|
/** 自定义 webpack module rules */
|