@moneko/core 3.0.0-beta.101 → 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/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/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
|
};
|