@moneko/core 3.0.0-beta.86 → 3.0.0-beta.87
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/common.js +1 -1
- package/lib/virtual-modules.d.ts +1 -33
- package/lib/virtual-modules.js +1 -1
- package/package.json +1 -1
- package/typings/global.d.ts +15 -0
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"}};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:"/",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:`
|
|
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.d.ts
CHANGED
|
@@ -1,34 +1,2 @@
|
|
|
1
|
-
declare const virtualModules:
|
|
2
|
-
'@app': {
|
|
3
|
-
base: string;
|
|
4
|
-
designSize: number;
|
|
5
|
-
routerMode: "browser" | "hash" | "memory";
|
|
6
|
-
mode: "csr" | "ssr";
|
|
7
|
-
locales: boolean;
|
|
8
|
-
favicon: string | false | undefined;
|
|
9
|
-
prefixCls: string | undefined;
|
|
10
|
-
theme: import("./index.js").Theme | undefined;
|
|
11
|
-
type: import("./index.js").AppType;
|
|
12
|
-
persist: boolean;
|
|
13
|
-
projectName: string;
|
|
14
|
-
iconfont: {
|
|
15
|
-
scriptUrl?: string | string[] | undefined;
|
|
16
|
-
extraCommonProps?: Record<string, any> | undefined;
|
|
17
|
-
} | undefined;
|
|
18
|
-
name: string;
|
|
19
|
-
version: string;
|
|
20
|
-
description: string | undefined;
|
|
21
|
-
author: {
|
|
22
|
-
name: string | undefined;
|
|
23
|
-
email: string | undefined;
|
|
24
|
-
url: string | undefined;
|
|
25
|
-
};
|
|
26
|
-
repository: {
|
|
27
|
-
type: string | undefined;
|
|
28
|
-
url: string | undefined;
|
|
29
|
-
directory: string | undefined;
|
|
30
|
-
};
|
|
31
|
-
};
|
|
32
|
-
'@app/fallback': string;
|
|
33
|
-
};
|
|
1
|
+
declare const virtualModules: Record<string, string | object>;
|
|
34
2
|
export default virtualModules;
|
package/lib/virtual-modules.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{accessSync as
|
|
1
|
+
import{accessSync as o,constants as p}from"fs";import{join as a}from"path";import t from"./app.js";import{CONFIG as r}from"./common.js";import{coverage as e}from"./coverage.js";import{APPTYPE as l,PROGRAMPATH as m}from"./process-env.js";let c={...r.virtualModule,"@app":t,"@app/fallback":"export default null"};if(r.fallbackCompPath&&Object.assign(c,{"@app/fallback":`import Fallback from "${r.fallbackCompPath}";export default Fallback;`}),"library"===l){let t={};try{let r=a(m,"./site/mdx-scope.ts");o(r,p.R_OK),t='import scope from "@/mdx-scope";export default scope;'}catch(o){t={}}Object.assign(c,{"@app/coverage":e,"@app/mdx-scope":t})}export default c;
|
package/package.json
CHANGED
package/typings/global.d.ts
CHANGED
|
@@ -273,6 +273,21 @@ export declare type ConfigType<T extends 'tsc' | 'swc' = 'swc'> = {
|
|
|
273
273
|
hydratable?: boolean;
|
|
274
274
|
};
|
|
275
275
|
bar?: Partial<State> | false;
|
|
276
|
+
/** 虚拟模块
|
|
277
|
+
* @example
|
|
278
|
+
* const conf = {
|
|
279
|
+
* virtualModule: {
|
|
280
|
+
* 'custom-module-1': 'export default { name: "user1" };'
|
|
281
|
+
* 'custom-module-2': { age: 12 }
|
|
282
|
+
* }
|
|
283
|
+
* }
|
|
284
|
+
* // 使用
|
|
285
|
+
* import a from 'custom-module-1';
|
|
286
|
+
* import b from 'custom-module-2';
|
|
287
|
+
* console.log(a); // { name: "user1" }
|
|
288
|
+
* console.log(b); // { age: 12 }
|
|
289
|
+
*/
|
|
290
|
+
virtualModule?: Record<string, string | object>;
|
|
276
291
|
};
|
|
277
292
|
export declare interface ModuleFederationOption {
|
|
278
293
|
/** 模块名称,唯一性,不能重名 */
|