@moneko/core 3.0.0-beta.86 → 3.0.0-beta.88
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/lib/webpack.common.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/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 o from"webpack";import n from"webpackbar";import"./cleanup.js";import{CONFIG as l,ENTRYPATH as i,PUBLICPATH as a}from"./common.js";import r from"./define.js";import"./docs.js";import p from"./done.js";import m from"./html-add-entry-attr.js";import c from"./html-plugin-option.js";import{moduleFederation as u}from"./module-federation.js";import d from"./module.config.js";import{APPTYPE as f,DEV as j,FRAMEWORK as g,PACKAGENAME as h,PROGRAMPATH as b,hasEslintConfig as y,hasStylelintConfig as w}from"./process-env.js";import"./routes.js";import{seo as x}from"./seo.js";import{resolveNodeModulesPath as k,resolveProgramPath as v}from"./utils.js";import O from"./virtual-module-plugin.js";import C from"./virtual-modules.js";let P=[".eslintrc.js",".eslintrc.json",".eslintrc.yaml",".eslintrc.json"],$=[".stylelintrc",".stylelintrc.json",".stylelintrc.yaml",".stylelintrc.yml",".stylelintrc.js","stylelint.config.js","stylelint.config.cjs"],A=e.readdirSync(b),B=!1,S=!1;for(let e=0,t=A.length;e<t;e++)$.includes(A[e])&&(S=!0),P.includes(A[e])&&(B=!0);B||(B=y),S||(S=w);let T=S?(await import("stylelint-webpack-plugin")).default:null,M=B?(await import("eslint-webpack-plugin")).default:null;export const alias={"@":v("src")};Object.assign(alias,l.alias),"library"===f&&Object.assign(alias,{"@":v("site"),"@pkg":v("components"),[h]:v("components")});let D=l.assetHtml.map(e=>({publicPath:"",...e}));export const outputConfig={path:v("library"===f?"docs":"dist"),filename:"js/[name].bundle.js",chunkFilename:"js/[name].chunk.js",assetModuleFilename:"assets/[name][hash][ext][query]",library:{name:h,type:"window"},globalObject:"window",chunkLoadingGlobal:`webpackJsonp_${h}`,pathinfo:j,clean:!0,publicPath:a};let K=k(`@moneko/${g}/lib/packages/${i[f]}/index.js`);"single-component"===f&&(Object.assign(alias,{[h]:v("umd")}),K=v(j?"example/index.ts":"src/index.ts"),outputConfig.path=v(j?"dist":"umd"),outputConfig.filename="index.js",outputConfig.globalObject="this",outputConfig.library={export:"default",name:h,type:"umd",umdNamedDefine:!0});let L={main:K};l.entry&&("string"==typeof l.entry?L=l.entry:Object.keys(l.entry)&&Object.assign(L,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,F=`${Array(W).fill("..").join("/")+(W?"/":"")}404.html`,{pathSegmentsToKeep:N=W,path:R=F}=l.fixBrowserRouter||{},_={entry:L,stats:"errors-only",infrastructureLogging:{level:"none"},target:"web",plugins:[new o.AutomaticPrefetchPlugin,...u,M&&new M({fix:!0,threads:!0,extensions:["js","md","mdx","cjs","ejs","mjs","jsx","ts","tsx","json","html","coffee","vue"]}),T&&new T({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(c),l.fixBrowserRouter&&new s({filename:R,inject:!1,templateContent:()=>`<html html><head><title>${c.title}</title><script>var pathSegmentsToKeep = ${N||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(D),"single-spa"===f&&new m(e=>!!(e.match(/main\.(.*)\.bundle.js$/)||e.match("main.bundle.js"))),new o.DefinePlugin(r),new o.WatchIgnorePlugin({paths:[/\.d\.ts$/]}),l.sourceMap&&new o.SourceMapDevToolPlugin(l.sourceMap),l.bar&&new n(l.bar),new p({done:()=>{!j&&l.seo&&x(),l.done?.(),j||setTimeout(()=>{process.exit(0)},
|
|
1
|
+
import e from"fs";import t from"add-asset-html-webpack-plugin";import s from"html-webpack-plugin";import o from"webpack";import n from"webpackbar";import"./cleanup.js";import{CONFIG as l,ENTRYPATH as i,PUBLICPATH as a}from"./common.js";import r from"./define.js";import"./docs.js";import p from"./done.js";import m from"./html-add-entry-attr.js";import c from"./html-plugin-option.js";import{moduleFederation as u}from"./module-federation.js";import d from"./module.config.js";import{APPTYPE as f,DEV as j,FRAMEWORK as g,PACKAGENAME as h,PROGRAMPATH as b,hasEslintConfig as y,hasStylelintConfig as w}from"./process-env.js";import"./routes.js";import{seo as x}from"./seo.js";import{resolveNodeModulesPath as k,resolveProgramPath as v}from"./utils.js";import O from"./virtual-module-plugin.js";import C from"./virtual-modules.js";let P=[".eslintrc.js",".eslintrc.json",".eslintrc.yaml",".eslintrc.json"],$=[".stylelintrc",".stylelintrc.json",".stylelintrc.yaml",".stylelintrc.yml",".stylelintrc.js","stylelint.config.js","stylelint.config.cjs"],A=e.readdirSync(b),B=!1,S=!1;for(let e=0,t=A.length;e<t;e++)$.includes(A[e])&&(S=!0),P.includes(A[e])&&(B=!0);B||(B=y),S||(S=w);let T=S?(await import("stylelint-webpack-plugin")).default:null,M=B?(await import("eslint-webpack-plugin")).default:null;export const alias={"@":v("src")};Object.assign(alias,l.alias),"library"===f&&Object.assign(alias,{"@":v("site"),"@pkg":v("components"),[h]:v("components")});let D=l.assetHtml.map(e=>({publicPath:"",...e}));export const outputConfig={path:v("library"===f?"docs":"dist"),filename:"js/[name].bundle.js",chunkFilename:"js/[name].chunk.js",assetModuleFilename:"assets/[name][hash][ext][query]",library:{name:h,type:"window"},globalObject:"window",chunkLoadingGlobal:`webpackJsonp_${h}`,pathinfo:j,clean:!0,publicPath:a};let K=k(`@moneko/${g}/lib/packages/${i[f]}/index.js`);"single-component"===f&&(Object.assign(alias,{[h]:v("umd")}),K=v(j?"example/index.ts":"src/index.ts"),outputConfig.path=v(j?"dist":"umd"),outputConfig.filename="index.js",outputConfig.globalObject="this",outputConfig.library={export:"default",name:h,type:"umd",umdNamedDefine:!0});let L={main:K};l.entry&&("string"==typeof l.entry?L=l.entry:Object.keys(l.entry)&&Object.assign(L,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,F=`${Array(W).fill("..").join("/")+(W?"/":"")}404.html`,{pathSegmentsToKeep:N=W,path:R=F}=l.fixBrowserRouter||{},_={entry:L,stats:"errors-only",infrastructureLogging:{level:"none"},target:"web",plugins:[new o.AutomaticPrefetchPlugin,...u,M&&new M({fix:!0,threads:!0,extensions:["js","md","mdx","cjs","ejs","mjs","jsx","ts","tsx","json","html","coffee","vue"]}),T&&new T({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(c),l.fixBrowserRouter&&new s({filename:R,inject:!1,templateContent:()=>`<html html><head><title>${c.title}</title><script>var pathSegmentsToKeep = ${N||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(D),"single-spa"===f&&new m(e=>!!(e.match(/main\.(.*)\.bundle.js$/)||e.match("main.bundle.js"))),new o.DefinePlugin(r),new o.WatchIgnorePlugin({paths:[/\.d\.ts$/]}),l.sourceMap&&new o.SourceMapDevToolPlugin(l.sourceMap),l.bar&&new n(l.bar),new p({done:()=>{!j&&l.seo&&x(),l.done?.(),j||setTimeout(()=>{process.exit(0)},32)}}),new O(C),...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:d,externals:l.externals,output:outputConfig};export default _;
|
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
|
/** 模块名称,唯一性,不能重名 */
|