@moneko/core 3.0.0-beta.100 → 3.0.0-beta.102
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.d.ts +0 -1
- package/lib/app.js +1 -1
- package/lib/common/rem.d.ts +2 -0
- package/lib/common/rem.js +28 -0
- package/lib/common.js +1 -1
- package/lib/docs.js +1 -1
- package/lib/generate-api.js +1 -1
- package/lib/virtual-modules.js +4 -1
- package/lib/webpack.common.js +1 -1
- package/package.json +13 -13
- package/typings/global.d.ts +10 -6
package/lib/app.d.ts
CHANGED
package/lib/app.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import o from"fs";import e from"path";import{CONFIG as
|
|
1
|
+
import o from"fs";import e from"path";import{CONFIG as t}from"./common.js";import r from"./html-plugin-option.js";import{APPTYPE as s,PACKAGENAME as i,PROGRAMPATH as m,programInfo as p}from"./process-env.js";import{toUpperCaseString as f}from"./utils.js";let n="library"===s?"site":"src",c={...p,base:t.routeBaseName,routerMode:t.routerMode,mode:t.mode,locales:o.existsSync(e.join(m,`./${n}/locales`)),favicon:r.favicon,prefixCls:t.prefixCls,theme:t.theme,type:s,persist:o.existsSync(e.join(m,`./${n}/persist.ts`)),projectName:JSON.stringify(f(i)),iconfont:t.iconfont};export default c;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import{CONFIG as e}from"../common.js";export default`(function (doc, win) {
|
|
2
|
+
function refreshRem() {
|
|
3
|
+
const docEl = doc.documentElement;
|
|
4
|
+
const clientWidth = docEl.clientWidth || doc.body.clientWidth;
|
|
5
|
+
const _designSize = clientWidth <= 375 ? 375 : ${e.rem?.designSize};
|
|
6
|
+
let unitSize = clientWidth;
|
|
7
|
+
|
|
8
|
+
if (clientWidth <= 375) {
|
|
9
|
+
unitSize = clientWidth;
|
|
10
|
+
} else if (clientWidth <= ${e.rem?.designSize}) {
|
|
11
|
+
unitSize = _designSize;
|
|
12
|
+
} else {
|
|
13
|
+
unitSize = clientWidth;
|
|
14
|
+
}
|
|
15
|
+
const rootSize = (16 / _designSize) * unitSize + 'px';
|
|
16
|
+
|
|
17
|
+
if (rootSize !== docEl.style.fontSize) {
|
|
18
|
+
docEl.style.fontSize = rootSize;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
refreshRem();
|
|
22
|
+
if ('addEventListener' in doc) {
|
|
23
|
+
const resizeEvt = 'orientationchange' in win ? 'orientationchange' : 'resize';
|
|
24
|
+
|
|
25
|
+
win.addEventListener(resizeEvt, refreshRem, false);
|
|
26
|
+
}
|
|
27
|
+
})(document, window);
|
|
28
|
+
`;
|
package/lib/common.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import e from"fs";import t from"path";import o from"readline";import s from"chalk";import{merge as i}from"webpack-merge";import{APPTYPE as n,CUSTOMCONFIG as r,FRAMEWORK as l,PROGRAMPATH as a,jsxImportSource as c,pkgName as m}from"./process-env.js";import{isFunction as p,readConf as u}from"./utils.js";export const ENTRYPATH={mobile:"mobile",site:"site","back-stage":"back-stage","single-spa":"single-spa",library:"library","single-component":"single-component"};let d=[`@moneko/${l}`,"neko-ui","antd","@antv","katex","font-pingfang-sc","font-pingfang-tc","react-photo-view","react-markdown-editor-lite","schema-design","@app"],h={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"}}};"single-component"===n&&(h=!1);let g={seo:!1,mode:"csr",compiler:"swc",bundleAnalyzer:{analyzerMode:"static",reportFilename:"report.html",openAnalyzer:!1},entry:{},minifier:{js:{},css:{}},sourceMap:{filename:"[file].map",publicPath:""},env:{},routeBaseName:"/",publicPath:"/",designSize:"mobile"===n?375:1680,fallbackCompPath:null,modifyVars:{},prefixCls:"n",alias:{},layoutSider:{},moduleRules:[],prefixJsLoader:[],cssModules:[],importOnDemand:{},proxy:[],cacheDirectory:`${a}/node_modules/.temp_cache`,devServer:{allowedHosts:[".baidu.com"],host:"localhost",port:3e3,https:!1,compress:!1},htmlPluginOption:{template:`./node_modules/${m}/template/index.html`,favicon:`./node_modules/${m}/template/favicon.ico`,tags:[]},assetHtml:[],routerMode:"browser",fixBrowserRouter:!1,plugins:[],splitChunk:h,runtimeChunk:"single-component"!==n&&"single",moduleFederation:[],rulesInclude:{less:d,css:d,js:d,media:d,fonts:d},mdx:{jsxImportSource:c,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:{}};export const log=e=>{o.cursorTo(process.stdout,0),process.stdout.write(e)};let f=g,y=null,x={},b={};try{y=t.join(a,"./config/index.ts"),e.accessSync(y,e.constants.R_OK)}catch(e){y=null}if(y)try{let e=(await u(y,"index")).default;x=p(e)?e(process):e}catch(e){process.stdout.write(s.red(e))}if(r){let o=null;try{o=t.join(a,`./config/${r}.ts`),e.accessSync(o,e.constants.R_OK)}catch(e){o=null}if(null!==o)try{let e=(await u(o,r)).default;b=p(e)?e(process):e}catch(e){process.stdout.write(s.red(e))}}"tsc"===(f=i(f,x,b)).compiler&&f.minifier&&(f.minifier.js||Object.assign(f.minifier,{js:{type:"terser"}}),f.minifier.css||Object.assign(f.minifier,{css:{type:"cssnano"}})),!1===f.devtool&&(f.sourceMap=!1),!1===f.sourceMap&&(f.devtool=!1),f.fixBrowserRouter&&f.htmlPluginOption&&(f.htmlPluginOption.tags||(f.htmlPluginOption.tags=[]),f.htmlPluginOption.tags.push({textContent:`
|
|
1
|
+
import e from"fs";import t from"path";import o from"readline";import s from"chalk";import{merge as i}from"webpack-merge";import{APPTYPE as n,CUSTOMCONFIG as r,FRAMEWORK as l,PROGRAMPATH as a,jsxImportSource as c,pkgName as m}from"./process-env.js";import{isFunction as p,readConf as u}from"./utils.js";export const ENTRYPATH={mobile:"mobile",site:"site","back-stage":"back-stage","single-spa":"single-spa",library:"library","single-component":"single-component"};let d=[`@moneko/${l}`,"neko-ui","antd","@antv","katex","font-pingfang-sc","font-pingfang-tc","react-photo-view","react-markdown-editor-lite","schema-design","@app"],h={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"}}};"single-component"===n&&(h=!1);let g={seo:!1,mode:"csr",compiler:"swc",bundleAnalyzer:{analyzerMode:"static",reportFilename:"report.html",openAnalyzer:!1},entry:{},minifier:{js:{},css:{}},sourceMap:{filename:"[file].map",publicPath:""},env:{},routeBaseName:"/",publicPath:"/",rem:{designSize:"mobile"===n?375:1680},fallbackCompPath:null,modifyVars:{},prefixCls:"n",alias:{},layoutSider:{},moduleRules:[],prefixJsLoader:[],cssModules:[],importOnDemand:{},proxy:[],cacheDirectory:`${a}/node_modules/.temp_cache`,devServer:{allowedHosts:[".baidu.com"],host:"localhost",port:3e3,https:!1,compress:!1},htmlPluginOption:{template:`./node_modules/${m}/template/index.html`,favicon:`./node_modules/${m}/template/favicon.ico`,tags:[]},assetHtml:[],routerMode:"browser",fixBrowserRouter:!1,plugins:[],splitChunk:h,runtimeChunk:"single-component"!==n&&"single",moduleFederation:[],rulesInclude:{less:d,css:d,js:d,media:d,fonts:d},mdx:{jsxImportSource:c,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};export const log=e=>{o.cursorTo(process.stdout,0),process.stdout.write(e)};let f=g,y=null,x={},b={};try{y=t.join(a,"./config/index.ts"),e.accessSync(y,e.constants.R_OK)}catch(e){y=null}if(y)try{let e=(await u(y,"index")).default;x=p(e)?e(process):e}catch(e){process.stdout.write(s.red(e))}if(r){let o=null;try{o=t.join(a,`./config/${r}.ts`),e.accessSync(o,e.constants.R_OK)}catch(e){o=null}if(null!==o)try{let e=(await u(o,r)).default;b=p(e)?e(process):e}catch(e){process.stdout.write(s.red(e))}}"tsc"===(f=i(f,x,b)).compiler&&f.minifier&&(f.minifier.js||Object.assign(f.minifier,{js:{type:"terser"}}),f.minifier.css||Object.assign(f.minifier,{css:{type:"cssnano"}})),!1===f.devtool&&(f.sourceMap=!1),!1===f.sourceMap&&(f.devtool=!1),f.fixBrowserRouter&&f.htmlPluginOption&&(f.htmlPluginOption.tags||(f.htmlPluginOption.tags=[]),f.htmlPluginOption.tags.push({textContent:`
|
|
2
2
|
(function(l) {
|
|
3
3
|
if (l.search[1] === '/' ) {
|
|
4
4
|
var decoded = l.search.slice(1).split('&').map(function(s) {
|
package/lib/docs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{statSync as e}from"fs";import{dirname as t,join as o}from"path";import{watch as r}from"chokidar";import n from"./generate-api.js";import
|
|
1
|
+
import{statSync as e}from"fs";import{dirname as t,join as o}from"path";import{watch as r}from"chokidar";import n from"./generate-api.js";import i from"./object-listener.js";import{APPTYPE as s,FRAMEWORK as p}from"./process-env.js";import{resolveProgramPath as l}from"./utils.js";import{alias as a}from"./webpack.common.js";let c="@app/comment";export const docs=i({});let m={[c]:{}},d={react:"createElement","solid-js":"createComponent"}[p],f=`() => ${d}(SuspenseComp, { comp: $1 })`,u=`import { ${d} } from "${p}";import { SuspenseComp } from "@moneko/${p}";`;function $(e,r){let i=e.replace(RegExp(`^${a["@pkg"]}`),""),s=t(i).replace(/^\//,""),p=[c,s].join("/"),l=i.split("/").pop()?.replace(/\.tsx?/,".md");if(!l)return;m[c][s]||(m[c][s]={});let $=o(p,l);if("deleted"===r)m[c][s][l]&&delete m[c][s][l];else{let t=n(e);m[$]=t,t?m[c][s][l]=`rr(() => import(/* webpackChunkName: '${$}' */'${$}?raw').then((res) => ({default: ${d}(Dynamic, {text: res.default, component: 'n-md', css: 'table td a {display:inline-flex;align-items:center;gap:2px;}table td a n-img{display:inline-block;overflow:hidden;border-radius:var(--border-radius);inline-size:18px;block-size:18px;}'})})))rr`:m[c][s][l]&&delete m[c][s][l]}let b={};for(let e in m[c])Object.prototype.hasOwnProperty.call(m[c],e)&&(b[e]=Object.values(m[c][e]));let g={...m};delete g[c],Object.assign(docs.data,{...g,"@app/docs":`${u}export default ${JSON.stringify(b).replace(/"rr\((.+?)\)rr"/g,f)}`})}["react","solid-js"].includes(p)||(f="$1",u=""),"solid-js"===p&&(u=`import { Dynamic } from "${p}/web";${u}`),"library"===s&&function(){let t=[],o=r(l("components"),{ignored:[/(^|[\\/\\])\../,/(^|[\\/\\])__tests__([\\/\\]|$)/],persistent:!0,ignoreInitial:!1});function n(t){return/\.tsx?$/.test(t)&&e(t).isFile()}o.on("add",e=>{n(e)&&($(e,"added"),t.push(e))}),o.on("change",e=>{n(e)&&$(e,"change")}),o.on("unlink",e=>{n(e)&&($(e,"deleted"),t.splice(t.indexOf(e),1))}),o.on("ready",()=>{t.forEach(e=>{$(e,"change")})}),process.on("SIGINT",function(){o.close()})}();
|
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";import{alias as l}from"./webpack.common.js";let{ScriptKind:o,ScriptTarget:i,SyntaxKind:u,createSourceFile:c,forEachChild:a,getLeadingCommentRanges:s,isInterfaceDeclaration:f,isQuestionToken:m,isPropertySignature:p,isFunctionTypeNode:g,isUnionTypeNode:$,isMethodSignature:h}=n,b={};function d(e){let t=s(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 y(e){if(!e)return null;let t=e.match(/@since\s+([^\n]+)/);return t?t[1].trim():null}function x(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}${
|
|
1
|
+
import{readFileSync as e}from"fs";import{dirname as t}from"path";import n from"typescript";import{CONFIG as r}from"./common.js";import{alias as l}from"./webpack.common.js";let{ScriptKind:o,ScriptTarget:i,SyntaxKind:u,createSourceFile:c,forEachChild:a,getLeadingCommentRanges:s,isInterfaceDeclaration:f,isQuestionToken:m,isPropertySignature:p,isFunctionTypeNode:g,isUnionTypeNode:$,isMethodSignature:h}=n,b={};function d(e){let t=s(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 y(e){if(!e)return null;let t=e.match(/@since\s+([^\n]+)/);return t?t[1].trim():null}function x(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 j(e){if(!e)return null;let t=e.match(/@ignore\s+([^\n]+)/);return t?t[1].trim():null}let T=/(?<!['"])(unknown|any|void|bigint|object|undefined|null|boolean|number|string|symbol)(?!['"])/g;function k(e,t){if(!e)return null;let n=e.replace(/\b([A-Z][a-zA-Z0-9]*)\b/g,e=>{if(b[e]){let n=`/${[r.routeBaseName,b[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(T,e=>`\\color{#009688}{${e}}`)),n}function w(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 B(e){return e?e.replace(/^@[a-z].+/gm,"").replace(/(\n\s+)+/g,"<br />").replace(/\n/g,"<br />").replace(/(<br \/>)$/g,""):null}export default function E(r){let s=e(r,"utf-8"),T=c(r,s,i.Latest,!0,o.TS),E="";return a(T,e=>{f(e)?E+=function(e){let r=e.name.text;Object.assign(b,{[e.name.text]:t(e.getSourceFile().fileName).replace(l["@pkg"],"")});let o=d(e),i=y(o),c=B(o),a=j(o)?.split("|")||[],s=a.includes("comment"),f=a.includes("initial"),T=a.includes("optional"),E=a.includes("version"),S=a.includes("author"),v=c?`\\color{|4||0.45}{${r}}`:r,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;}">${k(w(e))}</n-tag>`),N=[c,v,i&&`\\color{#52c11b|1||0.9}{${i}}`,F.length>0&&`<sub>\`extends\`</sub> ${F.join(" ")}`].filter(Boolean).join(" "),z=`## ${N}`,K=e.members.filter(e=>p(e)&&e.type?.kind!==u.NeverKeyword||h(e)),q=[];if(K.length){K.forEach(e=>{let t=k(w(h(e)?`(${e.parameters.map(e=>`${e.name.getText()}: ${e.type?.getText()||"any"}`).join(", ")}): ${e.type?.getText()||"any"}`:e.type?.getText()||"any"),!0),n=d(e),r=w(e.name.getText());!r||r.startsWith("\\color")||(h(e)||function(e){if(e.type){if(!$(e.type))return g(e.type);for(let t of e.type.types)if(g(t))return!0}return!1}(e)||t?.includes("=>")?r=`\\color{#f9a913}{${r}}`:/^("|')(.+)("|')$/.test(r)||(r=`\\color{#4c81db}{${r}}`));let l=e.questionToken&&m(e.questionToken);q.push([r,!T&&`\\color{${l?"#f9a913":"#52c11b"}\\|\\|\\|0.9}{${l?"✘":"✔"}}`,!s&&w(B(n)),t,!f&&w(function(e){if(!e)return null;let t=e.match(/@default\s+([^\n]+)/);return t?t[1].trim():null}(n)),!E&&w(y(n)),!S&&(x(n)||x(o))])});let e=!1,t=!1,n=!1,r=!1;q.forEach(l=>{!s&&l[2]&&(r=!0),!f&&l[4]&&(n=!0),!E&&l[5]&&(t=!0),!S&&l[6]&&(e=!0)}),z+="\n";let l=["属性",!T&&"必要",r&&"说明","类型",n&&"默认值",t&&"版本",e&&"作者"].filter(Boolean).join("|");z+=`|${l}|`;let i=[":-",!T&&":-",r&&":-",":-",n&&":-",t&&":-",e&&":-"].filter(Boolean);z+="\n";let u=i.join("|");z+=`|${u}|`,q.forEach(l=>{z+="\n";let o=[l[0]||"-",!T&&(l[1]||"-"),r&&(l[2]||"-"),l[3]||"-",n&&(l[4]||"-"),t&&(l[5]||"-"),e&&(l[6]||"-")].filter(Boolean).join("|");z+=`|${o}|`}),z+="\n"}return z+="\n"}(e):n.isEnumDeclaration(e)&&(E+=function(e){let r=e.name.text;Object.assign(b,{[e.name.text]:t(e.getSourceFile().fileName).replace(l["@pkg"],"")});let o=d(e),i=j(o)?.split("|")||[],u=i.includes("comment"),c=i.includes("version"),a=i.includes("author"),s=`## ${r}`;if(e.members.length){let t=[];e.members.forEach(e=>{let r=w(e.name.getText()),l=d(e),i=w(function(e){let t=e.initializer;return t&&n.isStringLiteral(t)?` '${t.text}'`:null}(e)),s=w(y(l)),f=w(B(l));!r||r.startsWith("\\color")||/^("|')(.+)("|')$/.test(r)||(r=`\\color{#4c81db}{${r}}`),t.push([r,!u&&f,i,!c&&s,!a&&(x(l)||x(o))])});let r=!1,l=!1,i=!1;t.forEach(e=>{!u&&e[1]&&(i=!0),!c&&e[3]&&(l=!0),!a&&e[4]&&(r=!0)}),s+="\n";let f=["属性",i&&"说明","值",l&&"版本",r&&"作者"].filter(Boolean).join("|");s+=`|${f}|`;let m=[":-",i&&":-",":-",l&&":-",r&&":-"].filter(Boolean);s+="\n";let p=m.join("|");s+=`|${p}|`,t.forEach(e=>{s+="\n";let t=[e[0]||"-",i&&(e[1]||"-"),e[2]||"-",l&&(e[3]||"-"),r&&(e[4]||"-")].filter(Boolean).join("|");s+=`|${t}|`})}return s+="\n\n"}(e))}),E}
|
package/lib/virtual-modules.js
CHANGED
|
@@ -1 +1,4 @@
|
|
|
1
|
-
import{accessSync as o,constants as p}from"fs";import{join as
|
|
1
|
+
import{accessSync as o,constants as p}from"fs";import{join as m}from"path";import a from"./app.js";import r from"./common/rem.js";import{CONFIG as e}from"./common.js";import{coverage as t}from"./coverage.js";import{FRAMEWORK as l}from"./process-env.js";import{alias as s}from"./webpack.common.js";let c={...e.virtualModule,"@app":a,"@app/fallback":"export default null","@app/coverage":t,"@app/entry":`${e.normalizeCss?`import "@moneko/${l}/lib/normalize.css";`:""}
|
|
2
|
+
${e.rem?.designSize?r:""}
|
|
3
|
+
await import('@moneko/${l}/lib/entry.js');
|
|
4
|
+
`};e.fallbackCompPath&&Object.assign(c,{"@app/fallback":`import Fallback from "${e.fallbackCompPath}";export default Fallback;`});let i={};try{let a=m(s["@"],"./mdx-scope.ts");o(a,p.R_OK),i='import scope from "@/mdx-scope";export default scope;'}catch(o){i={}}Object.assign(c,{"@app/mdx-scope":i});export default c;
|
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 n from"webpack";import o from"webpackbar";import"./cleanup.js";import{CONFIG as l,
|
|
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 i}from"./common.js";import a from"./define.js";import r from"./done.js";import p from"./html-add-entry-attr.js";import m from"./html-plugin-option.js";import{moduleFederation as c}from"./module-federation.js";import u from"./module.config.js";import{APPTYPE as d,DEV as f,PACKAGENAME as j,PROGRAMPATH as g,hasEslintConfig as h,hasStylelintConfig as b}from"./process-env.js";import{seo as y}from"./seo.js";import{resolveNodeModulesPath as w,resolveProgramPath as x}from"./utils.js";import k from"./virtual-module-plugin.js";import v from"./virtual-modules.js";let{AutomaticPrefetchPlugin:O,DefinePlugin:C,SourceMapDevToolPlugin:$,WatchIgnorePlugin:B}=n,A=[".eslintrc.js",".eslintrc.json",".eslintrc.yaml",".eslintrc.json"],S=[".stylelintrc",".stylelintrc.json",".stylelintrc.yaml",".stylelintrc.yml",".stylelintrc.js","stylelint.config.js","stylelint.config.cjs"],T=e.readdirSync(g),K=!1,L=!1;for(let e=0,t=T.length;e<t;e++)S.includes(T[e])&&(L=!0),A.includes(T[e])&&(K=!0);K||(K=h),L||(L=b);let M=L?(await import("stylelint-webpack-plugin")).default:null,P=K?(await import("eslint-webpack-plugin")).default:null;export const alias={"@":x("src")};Object.assign(alias,l.alias),"library"===d&&Object.assign(alias,{"@":x("site"),"@pkg":x("components"),[j]:x("components")});let F=l.assetHtml.map(e=>({publicPath:"",...e}));export const outputConfig={path:x("library"===d?"docs":"dist"),filename:"js/[name].bundle.js",chunkFilename:"js/[name].chunk.js",assetModuleFilename:"assets/[name][hash][ext][query]",library:{name:j,type:"window"},globalObject:"window",chunkLoadingGlobal:`webpackJsonp_${j}`,pathinfo:f,clean:!0,publicPath:i};let N=w("@app/entry");"single-component"===d&&(Object.assign(alias,{[j]:x("umd")}),N=x(f?"example/index.ts":"src/index.ts"),outputConfig.path=x(f?"dist":"umd"),outputConfig.filename="index.js",outputConfig.globalObject="this",outputConfig.library={export:"default",name:j,type:"umd",umdNamedDefine:!0});let R={main:N};l.entry&&("string"==typeof l.entry?R=l.entry:Object.keys(l.entry)&&Object.assign(R,l.entry)),l.output&&("string"==typeof l.output?outputConfig.path=l.output:Object.keys(l.output)&&Object.assign(outputConfig,l.output));let W=l.routeBaseName.split("/").filter(Boolean).length,_=`${Array(W).fill("..").join("/")+(W?"/":"")}404.html`,{pathSegmentsToKeep:q=W,path:D=_}=l.fixBrowserRouter||{},G={entry:R,stats:"errors-only",infrastructureLogging:{level:"none"},target:"web",plugins:[new O,...c,P&&new P({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(m),l.fixBrowserRouter&&new s({filename:D,inject:!1,templateContent:()=>`<html html><head><title>${m.title}</title><script>var pathSegmentsToKeep = ${q||W};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(F),"single-spa"===d&&new p(e=>!!(e.match(/main\.(.*)\.bundle.js$/)||e.match("main.bundle.js"))),new C(a),new B({paths:[/\.d\.ts$/]}),l.sourceMap&&new $(l.sourceMap),l.bar&&new o(l.bar),new r({done:()=>{!f&&l.seo&&y(),l.done?.(),f||setTimeout(()=>{process.exit(0)},2e3)}}),new k(v),...l.plugins].filter(Boolean),experiments:{topLevelAwait:!0,syncWebAssembly:!0,asyncWebAssembly:!0},resolve:{extensions:[".tsx",".ts",".js",".jsx"],alias:alias,fallback:{path:!1,fs:!1,crypto:!1,assert:!1}},module:u,externals:l.externals,output:outputConfig};export default G;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moneko/core",
|
|
3
|
-
"version": "3.0.0-beta.
|
|
3
|
+
"version": "3.0.0-beta.102",
|
|
4
4
|
"description": "core",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"@swc/helpers": "0.5.1",
|
|
20
20
|
"@teamsupercell/typings-for-css-modules-loader": "2.5.2",
|
|
21
21
|
"add-asset-html-webpack-plugin": "6.0.0",
|
|
22
|
-
"core-js": "3.
|
|
22
|
+
"core-js": "3.32.0",
|
|
23
23
|
"cross-env": "7.0.3",
|
|
24
24
|
"css-loader": "6.8.1",
|
|
25
25
|
"css-minimizer-webpack-plugin": "5.0.1",
|
|
@@ -45,20 +45,20 @@
|
|
|
45
45
|
"webpack-merge": "5.9.0",
|
|
46
46
|
"webpack-virtual-modules": "0.5.0",
|
|
47
47
|
"webpackbar": "5.0.2",
|
|
48
|
-
"xml2js": "0.6.
|
|
48
|
+
"xml2js": "0.6.2"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
|
-
"@moneko/mock": "
|
|
52
|
-
"@moneko/postcss": "
|
|
51
|
+
"@moneko/mock": "1.0.10",
|
|
52
|
+
"@moneko/postcss": "1.0.30",
|
|
53
53
|
"@swc/cli": "0.1.62",
|
|
54
|
-
"@types/js-yaml": "
|
|
55
|
-
"@types/mini-css-extract-plugin": "
|
|
56
|
-
"@types/shelljs": "
|
|
57
|
-
"@types/webpack-bundle-analyzer": "
|
|
58
|
-
"@types/webpack-env": "
|
|
59
|
-
"eslint-config-neko": "
|
|
60
|
-
"shelljs": "
|
|
61
|
-
"stylelint-config-moneko": "
|
|
54
|
+
"@types/js-yaml": "4.0.5",
|
|
55
|
+
"@types/mini-css-extract-plugin": "2.5.1",
|
|
56
|
+
"@types/shelljs": "0.8.12",
|
|
57
|
+
"@types/webpack-bundle-analyzer": "4.6.0",
|
|
58
|
+
"@types/webpack-env": "1.18.1",
|
|
59
|
+
"eslint-config-neko": "1.1.1",
|
|
60
|
+
"shelljs": "0.8.5",
|
|
61
|
+
"stylelint-config-moneko": "1.0.17"
|
|
62
62
|
},
|
|
63
63
|
"files": [
|
|
64
64
|
"lib",
|
package/typings/global.d.ts
CHANGED
|
@@ -110,10 +110,12 @@ export declare type ConfigType<T extends 'tsc' | 'swc' = 'swc'> = {
|
|
|
110
110
|
* @default /
|
|
111
111
|
* */
|
|
112
112
|
publicPath: string;
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
113
|
+
rem?: {
|
|
114
|
+
/** 设计图尺寸, 用于计算rem
|
|
115
|
+
* @default 1680
|
|
116
|
+
* */
|
|
117
|
+
designSize: number;
|
|
118
|
+
} | null;
|
|
117
119
|
/** 自定义降级组件 */
|
|
118
120
|
fallbackCompPath?: string | null;
|
|
119
121
|
/** less 全局变量 */
|
|
@@ -288,6 +290,10 @@ export declare type ConfigType<T extends 'tsc' | 'swc' = 'swc'> = {
|
|
|
288
290
|
* console.log(b); // { age: 12 }
|
|
289
291
|
*/
|
|
290
292
|
virtualModule?: Record<string, string | object>;
|
|
293
|
+
/** 是否使用 normalize css
|
|
294
|
+
* @default true
|
|
295
|
+
*/
|
|
296
|
+
normalizeCss?: boolean;
|
|
291
297
|
};
|
|
292
298
|
export declare interface ModuleFederationOption {
|
|
293
299
|
/** 模块名称,唯一性,不能重名 */
|
|
@@ -450,8 +456,6 @@ export type ProgramInfoType = {
|
|
|
450
456
|
routerMode: 'hash' | 'browser' | 'memory';
|
|
451
457
|
/** 根路由 */
|
|
452
458
|
routeBaseName: string;
|
|
453
|
-
/** 设计尺寸 */
|
|
454
|
-
designSize: number;
|
|
455
459
|
/** 渲染模式 */
|
|
456
460
|
renderMode: 'ssr' | 'csr';
|
|
457
461
|
};
|