@moneko/core 2.0.1-8.2 → 2.0.1-8.4

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/build/common.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:true});function _export(target,all){for(var name in all)Object.defineProperty(target,name,{enumerable:true,get:all[name]})}_export(exports,{ENTRYPATH:function(){return ENTRYPATH},log:function(){return log},CONFIG:function(){return CONFIG},PUBLICPATH:function(){return PUBLICPATH}});var _fs=_interopRequireDefault(require("fs"));var _path=_interopRequireDefault(require("path"));var _readline=_interopRequireDefault(require("readline"));var _chalk=_interopRequireDefault(require("chalk"));var _webpackMerge=require("webpack-merge");var _processEnv=require("./process-env");var _utils=require("./utils");function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}var _customConf_minifier;var ENTRYPATH={mobile:"mobile",site:"site","back-stage":"back-stage","single-spa":"single-spa",library:"library","single-component":"single-component"};var includeModule=[_processEnv.pkgName,"neko-ui","antd","@antv","katex","font-pingfang-sc","font-pingfang-tc","react-photo-view","react-markdown-editor-lite","schema-design"];var defaultSplitChunk={chunks:"all",minSize:1024,minChunks:1};if(_processEnv.APPTYPE==="single-component"){defaultSplitChunk=false}var defaultConfig={seo:false,mode:"csr",compiler:"swc",bundleAnalyzer:{analyzerMode:"static",reportFilename:"report.html",openAnalyzer:false},entry:{},minifier:{options:{},css:"cssnano"},sourceMap:{filename:"[file].map",publicPath:""},env:{},persistence:"".concat(_processEnv.PACKAGENAME,"-program:").concat(_processEnv.PACKAGEVERSION),routeBaseName:"/",publicPath:"/",designSize:_processEnv.APPTYPE==="mobile"?375:1680,fallbackCompPath:null,modifyVars:{},prefixCls:"n",alias:{},layoutSider:{},moduleRules:[],prefixJsLoader:[],cssModules:[],importOnDemand:{},proxy:[],cacheDirectory:_processEnv.PROGRAMPATH+"/node_modules/.temp_cache",devServer:{allowedHosts:[".baidu.com"],host:"localhost",port:3e3,https:false,compress:false},htmlPluginOption:{template:"./node_modules/".concat(_processEnv.pkgName,"/template/index.html"),favicon:"./node_modules/".concat(_processEnv.pkgName,"/template/favicon.ico"),tags:[]},assetHtml:[],routerMode:"browser",pathSegmentsToKeep:false,plugins:[],splitChunk:defaultSplitChunk,runtimeChunk:_processEnv.APPTYPE==="single-component"?false:"single",moduleFederation:[],rulesInclude:{less:includeModule,css:includeModule,js:includeModule,media:includeModule,fonts:includeModule}};var log=function(msg){_readline.default.cursorTo(process.stdout,0);process.stdout.write(msg)};var customConf=defaultConfig;var configPath=null;var normalConf={};var envConf={};try{configPath=_path.default.join(_processEnv.PROGRAMPATH,"./config/index.ts");_fs.default.accessSync(configPath,_fs.default.constants.R_OK)}catch(error){configPath=null}if(configPath){try{var conf=eval((0,_utils.tfc)(configPath)).default;normalConf=(0,_utils.isFunction)(conf)?conf(process):conf}catch(error){process.stdout.write(_chalk.default.red(error))}}if(_processEnv.CUSTOMCONFIG){var customConfigPath=null;try{customConfigPath=_path.default.join(_processEnv.PROGRAMPATH,"./config/".concat(_processEnv.CUSTOMCONFIG,".ts"));_fs.default.accessSync(customConfigPath,_fs.default.constants.R_OK)}catch(error){customConfigPath=null}if(customConfigPath!==null){try{var conf=eval((0,_utils.tfc)(customConfigPath)).default;envConf=(0,_utils.isFunction)(conf)?conf(process):conf}catch(error){process.stdout.write(_chalk.default.red(error))}}}customConf=(0,_webpackMerge.merge)(customConf,normalConf,envConf);if(!(customConf===null||customConf===void 0?void 0:(_customConf_minifier=customConf.minifier)===null||_customConf_minifier===void 0?void 0:_customConf_minifier.type)){customConf.minifier.type=customConf.compiler==="swc"?"swc":"terser"}if(customConf.devtool===false)customConf.sourceMap=false;if(customConf.sourceMap===false)customConf.devtool=false;if(customConf.pathSegmentsToKeep!==false){if(!customConf.htmlPluginOption.tags){customConf.htmlPluginOption.tags=[]}customConf.htmlPluginOption.tags.push({textContent:"\n (function(l) {\n if (l.search[1] === '/' ) {\n var decoded = l.search.slice(1).split('&').map(function(s) { \n return s.replace(/~and~/g, '&')\n }).join('?');\n window.history.replaceState(null, null,\n l.pathname.slice(0, -1) + decoded + l.hash\n );\n }\n }(window.location))\n "})}var CONFIG=customConf;var PUBLICPATH=CONFIG.publicPath||"/";global.NEKOCLICONFIG={CONFIG:CONFIG,log:log};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});function _export(target,all){for(var name in all)Object.defineProperty(target,name,{enumerable:true,get:all[name]})}_export(exports,{ENTRYPATH:function(){return ENTRYPATH},log:function(){return log},CONFIG:function(){return CONFIG},PUBLICPATH:function(){return PUBLICPATH}});var _fs=_interopRequireDefault(require("fs"));var _path=_interopRequireDefault(require("path"));var _readline=_interopRequireDefault(require("readline"));var _chalk=_interopRequireDefault(require("chalk"));var _webpackMerge=require("webpack-merge");var _processEnv=require("./process-env");var _utils=require("./utils");function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}var _customConf_minifier;var ENTRYPATH={mobile:"mobile",site:"site","back-stage":"back-stage","single-spa":"single-spa",library:"library","single-component":"single-component"};var includeModule=[_processEnv.pkgName,"neko-ui","antd","@antv","katex","font-pingfang-sc","font-pingfang-tc","react-photo-view","react-markdown-editor-lite","schema-design"];var defaultSplitChunk={chunks:"all",minSize:1024,minChunks:1};if(_processEnv.APPTYPE==="single-component"){defaultSplitChunk=false}var defaultConfig={seo:false,mode:"csr",compiler:"swc",bundleAnalyzer:{analyzerMode:"static",reportFilename:"report.html",openAnalyzer:false},entry:{},minifier:{options:{},css:"cssnano"},sourceMap:{filename:"[file].map",publicPath:""},env:{},persistence:"".concat(_processEnv.PACKAGENAME,"-program:").concat(_processEnv.PACKAGEVERSION),routeBaseName:"/",publicPath:"/",designSize:_processEnv.APPTYPE==="mobile"?375:1680,fallbackCompPath:null,modifyVars:{},prefixCls:"n",alias:{},layoutSider:{},moduleRules:[],prefixJsLoader:[],cssModules:[],importOnDemand:{},proxy:[],cacheDirectory:_processEnv.PROGRAMPATH+"/node_modules/.temp_cache",devServer:{allowedHosts:[".baidu.com"],host:"localhost",port:3e3,https:false,compress:false},htmlPluginOption:{template:"./node_modules/".concat(_processEnv.pkgName,"/template/index.html"),favicon:"./node_modules/".concat(_processEnv.pkgName,"/template/favicon.ico"),tags:[]},assetHtml:[],routerMode:"browser",fixBrowserRouter:false,plugins:[],splitChunk:defaultSplitChunk,runtimeChunk:_processEnv.APPTYPE==="single-component"?false:"single",moduleFederation:[],rulesInclude:{less:includeModule,css:includeModule,js:includeModule,media:includeModule,fonts:includeModule}};var log=function(msg){_readline.default.cursorTo(process.stdout,0);process.stdout.write(msg)};var customConf=defaultConfig;var configPath=null;var normalConf={};var envConf={};try{configPath=_path.default.join(_processEnv.PROGRAMPATH,"./config/index.ts");_fs.default.accessSync(configPath,_fs.default.constants.R_OK)}catch(error){configPath=null}if(configPath){try{var conf=eval((0,_utils.tfc)(configPath)).default;normalConf=(0,_utils.isFunction)(conf)?conf(process):conf}catch(error){process.stdout.write(_chalk.default.red(error))}}if(_processEnv.CUSTOMCONFIG){var customConfigPath=null;try{customConfigPath=_path.default.join(_processEnv.PROGRAMPATH,"./config/".concat(_processEnv.CUSTOMCONFIG,".ts"));_fs.default.accessSync(customConfigPath,_fs.default.constants.R_OK)}catch(error){customConfigPath=null}if(customConfigPath!==null){try{var conf=eval((0,_utils.tfc)(customConfigPath)).default;envConf=(0,_utils.isFunction)(conf)?conf(process):conf}catch(error){process.stdout.write(_chalk.default.red(error))}}}customConf=(0,_webpackMerge.merge)(customConf,normalConf,envConf);if(!(customConf===null||customConf===void 0?void 0:(_customConf_minifier=customConf.minifier)===null||_customConf_minifier===void 0?void 0:_customConf_minifier.type)){customConf.minifier.type=customConf.compiler==="swc"?"swc":"terser"}if(customConf.devtool===false)customConf.sourceMap=false;if(customConf.sourceMap===false)customConf.devtool=false;if(customConf.fixBrowserRouter){if(!customConf.htmlPluginOption.tags){customConf.htmlPluginOption.tags=[]}customConf.htmlPluginOption.tags.push({textContent:"\n (function(l) {\n if (l.search[1] === '/' ) {\n var decoded = l.search.slice(1).split('&').map(function(s) { \n return s.replace(/~and~/g, '&')\n }).join('?');\n window.history.replaceState(null, null,\n l.pathname.slice(0, -1) + decoded + l.hash\n );\n }\n }(window.location))\n "})}var CONFIG=customConf;var PUBLICPATH=CONFIG.publicPath||"/";global.NEKOCLICONFIG={CONFIG:CONFIG,log:log};
package/build/seo.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:true});Object.defineProperty(exports,"seo",{enumerable:true,get:function(){return seo}});var _fs=require("fs");var _path=require("path");var _common=require("./common");var _processEnv=require("./process-env");var _webpackCommon=require("./webpack.common");function getLibDocsPages(dir,domain,basename){var results=[];var list=(0,_fs.readdirSync)(dir);list.forEach(function(_file){if(_file==="static"){return false}var file=dir+"/"+_file;var stat=(0,_fs.statSync)(file);if(stat&&stat.isDirectory()){results=results.concat(getLibDocsPages(file,domain,basename))}else if(file.endsWith("README.mdx")){results.push("https://"+domain+basename+file.replace(_processEnv.PROGRAMPATH+"/components/","").replace("/README.mdx",""))}});return results}var seo=function(){var _ref=_common.CONFIG.seo||{},domain=_ref.domain,nojekyll=_ref.nojekyll,path=_ref.path;if(!domain){return}var baseDir=path||(_webpackCommon.outputConfig===null||_webpackCommon.outputConfig===void 0?void 0:_webpackCommon.outputConfig.path)||process.cwd();var call=function(err){if(err){throw err}};(0,_fs.writeFile)((0,_path.join)(baseDir,"CNAME"),domain,"utf-8",call);(0,_fs.writeFile)((0,_path.join)(baseDir,"robots"),"Sitemap: https://".concat(domain).concat(_common.CONFIG.routeBaseName,"sitemap.txt"),"utf-8",call);var sitemap="";switch(_processEnv.APPTYPE){case"library":sitemap=getLibDocsPages((0,_path.join)(_processEnv.PROGRAMPATH,"./components"),domain,_common.CONFIG.routeBaseName).join("\n");break;case"single-component":case"mobile":case"site":case"back-stage":case"single-spa":default:break}(0,_fs.writeFile)((0,_path.join)(baseDir,"sitemap.txt"),sitemap,"utf-8",call);if(nojekyll){(0,_fs.writeFile)((0,_path.join)(baseDir,".nojekyll"),"","utf-8",call)}};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});Object.defineProperty(exports,"seo",{enumerable:true,get:function(){return seo}});var _fs=require("fs");var _path=require("path");var _common=require("./common");var _processEnv=require("./process-env");var _utils=require("./utils");var _webpackCommon=require("./webpack.common");function getLibDocsPages(dir,domain,basename){var results=[];var list=(0,_fs.readdirSync)(dir);list.forEach(function(_file){if(_file==="static"){return false}var file=dir+"/"+_file;var stat=(0,_fs.statSync)(file);if(stat&&stat.isDirectory()){results=results.concat(getLibDocsPages(file,domain,basename))}else if(file.endsWith("README.mdx")){results.push("https://"+domain+basename+file.replace(_processEnv.PROGRAMPATH+"/components/","").replace("/README.mdx",""))}});return results}var seo=function(){var _ref=_common.CONFIG.seo||{},domain=_ref.domain,nojekyll=_ref.nojekyll,path=_ref.path;if(!domain){return}var baseDir=path&&(0,_utils.resolveProgramPath)(path)||(_webpackCommon.outputConfig===null||_webpackCommon.outputConfig===void 0?void 0:_webpackCommon.outputConfig.path)||process.cwd();var call=function(err){if(err){throw err}};(0,_fs.writeFile)((0,_path.join)(baseDir,"CNAME"),domain,"utf-8",call);(0,_fs.writeFile)((0,_path.join)(baseDir,"robots"),"Sitemap: https://".concat(domain).concat(_common.CONFIG.routeBaseName,"sitemap.txt"),"utf-8",call);var sitemap="";switch(_processEnv.APPTYPE){case"library":sitemap=getLibDocsPages((0,_path.join)(_processEnv.PROGRAMPATH,"./components"),domain,_common.CONFIG.routeBaseName).join("\n");break;case"single-component":case"mobile":case"site":case"back-stage":case"single-spa":default:break}(0,_fs.writeFile)((0,_path.join)(baseDir,"sitemap.txt"),sitemap,"utf-8",call);if(nojekyll){(0,_fs.writeFile)((0,_path.join)(baseDir,".nojekyll"),"","utf-8",call)}};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:true});function _export(target,all){for(var name in all)Object.defineProperty(target,name,{enumerable:true,get:all[name]})}_export(exports,{outputConfig:function(){return outputConfig},default:function(){return _default}});var _fs=_interopRequireDefault(require("fs"));var _path=_interopRequireDefault(require("path"));var _addAssetHtmlWebpackPlugin=_interopRequireDefault(require("add-asset-html-webpack-plugin"));var _htmlWebpackPlugin=_interopRequireDefault(require("html-webpack-plugin"));var _webpack=require("webpack");var _webpackbar=_interopRequireDefault(require("webpackbar"));var _common=require("./common");var _done=_interopRequireDefault(require("./done"));var _envFlags=_interopRequireDefault(require("./envFlags"));var _htmlAddEntryAttr=_interopRequireDefault(require("./html-add-entry-attr"));var _htmlPluginOption=_interopRequireDefault(require("./html-plugin-option"));var _moduleFederation=require("./module-federation");var _moduleConfig=_interopRequireDefault(require("./module.config"));var _processEnv=require("./process-env");var _seo=require("./seo");var _utils=require("./utils");function _arrayLikeToArray(arr,len){if(len==null||len>arr.length)len=arr.length;for(var i=0,arr2=new Array(len);i<len;i++)arr2[i]=arr[i];return arr2}function _arrayWithoutHoles(arr){if(Array.isArray(arr))return _arrayLikeToArray(arr)}function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true})}else{obj[key]=value}return obj}function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}function _iterableToArray(iter){if(typeof Symbol!=="undefined"&&iter[Symbol.iterator]!=null||iter["@@iterator"]!=null)return Array.from(iter)}function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _objectSpread(target){for(var i=1;i<arguments.length;i++){var source=arguments[i]!=null?arguments[i]:{};var ownKeys=Object.keys(source);if(typeof Object.getOwnPropertySymbols==="function"){ownKeys=ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym){return Object.getOwnPropertyDescriptor(source,sym).enumerable}))}ownKeys.forEach(function(key){_defineProperty(target,key,source[key])})}return target}function _toConsumableArray(arr){return _arrayWithoutHoles(arr)||_iterableToArray(arr)||_unsupportedIterableToArray(arr)||_nonIterableSpread()}function _unsupportedIterableToArray(o,minLen){if(!o)return;if(typeof o==="string")return _arrayLikeToArray(o,minLen);var n=Object.prototype.toString.call(o).slice(8,-1);if(n==="Object"&&o.constructor)n=o.constructor.name;if(n==="Map"||n==="Set")return Array.from(n);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray(o,minLen)}var eslintrc=[".eslintrc.js",".eslintrc.json",".eslintrc.yaml",".eslintrc.json"];var stylelintrc=[".stylelintrc",".stylelintrc.json",".stylelintrc.yaml",".stylelintrc.yml",".stylelintrc.js","stylelint.config.js","stylelint.config.cjs"];var rootFiles=_fs.default.readdirSync(_processEnv.PROGRAMPATH);var hasEslint=false,hasStylelint=false;for(var i=0,len=rootFiles.length;i<len;i++){if(stylelintrc.includes(rootFiles[i])){hasStylelint=true}if(eslintrc.includes(rootFiles[i])){hasEslint=true}}if(!hasEslint){hasEslint=_processEnv.hasEslintConfig}if(!hasStylelint){hasStylelint=_processEnv.hasStylelintConfig}var StylelintPlugin=hasStylelint?require("stylelint-webpack-plugin"):null;var ESLintPlugin=hasEslint?require("eslint-webpack-plugin"):null;var alias={"@":(0,_utils.resolveProgramPath)("src")};Object.assign(alias,_common.CONFIG.alias);if(_processEnv.APPTYPE==="library"){Object.assign(alias,_defineProperty({"@":(0,_utils.resolveProgramPath)("site"),"@pkg":(0,_utils.resolveProgramPath)("components")},_processEnv.PACKAGENAME,(0,_utils.resolveProgramPath)("components")))}var assetHtmlOption=_common.CONFIG.assetHtml.map(function(item){return _objectSpread({publicPath:""},item)});var outputConfig={path:(0,_utils.resolveProgramPath)(_processEnv.APPTYPE==="library"?"docs":"dist"),filename:"js/[name].bundle.js",chunkFilename:"js/[name].chunk.js",assetModuleFilename:"assets/[name].[hash][ext]",library:_processEnv.PACKAGENAME,libraryTarget:"window",globalObject:"window",chunkLoadingGlobal:"webpackJsonp_".concat(_processEnv.PACKAGENAME),pathinfo:false,clean:true,publicPath:_common.PUBLICPATH};var mainEntry=_path.default.join(__dirname,"../lib/packages/".concat(_common.ENTRYPATH[_processEnv.APPTYPE],"/index.js"));if(_processEnv.APPTYPE==="single-component"){Object.assign(alias,_defineProperty({},_processEnv.PACKAGENAME,(0,_utils.resolveProgramPath)("umd")));mainEntry=(0,_utils.resolveProgramPath)(_processEnv.DEV?"example/index.ts":"src/index.ts");outputConfig.path=(0,_utils.resolveProgramPath)(_processEnv.DEV?"dist":"umd");outputConfig.filename="index.js";outputConfig.library=_processEnv.PACKAGENAME;outputConfig.libraryTarget="umd";outputConfig.libraryExport="default"}var entryMap={main:mainEntry};if(_common.CONFIG.entry){if(typeof _common.CONFIG.entry==="string"){entryMap=_common.CONFIG.entry}else if(Object.keys(_common.CONFIG.entry)){Object.assign(entryMap,_common.CONFIG.entry)}}if(_common.CONFIG.output){if(typeof _common.CONFIG.output==="string"){outputConfig.path=_common.CONFIG.output}else if(Object.keys(_common.CONFIG.output)){Object.assign(outputConfig,_common.CONFIG.output)}}var dirDeep=_common.CONFIG.routeBaseName.split("/").filter(Boolean).length;var page404=Array(dirDeep).fill("..").join("/")+(dirDeep?"/":"")+"404.html";var config={entry:entryMap,stats:"errors-only",infrastructureLogging:{level:"none"},target:"web",plugins:[new _webpack.AutomaticPrefetchPlugin].concat(_toConsumableArray(_moduleFederation.moduleFederation),[ESLintPlugin&&new ESLintPlugin({threads:true,extensions:["js","md","mdx","cjs","ejs","mjs","jsx","ts","tsx","json","html","coffee","vue"]}),StylelintPlugin&&new StylelintPlugin({fix:true,threads:true,extensions:["css","scss","sass","less","ts","tsx","js","jsx"],exclude:["node_modules/","es/","lib/","docs/","coverage/","dist/"]}),new _htmlWebpackPlugin.default(_htmlPluginOption.default),_common.CONFIG.pathSegmentsToKeep!==false&&new _htmlWebpackPlugin.default({filename:page404,inject:false,templateContent:function(){return"<html html><head><title>".concat(_htmlPluginOption.default.title,"</title><script>var pathSegmentsToKeep = ").concat(_common.CONFIG.pathSegmentsToKeep,";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 _addAssetHtmlWebpackPlugin.default(assetHtmlOption),_processEnv.APPTYPE==="single-spa"&&new _htmlAddEntryAttr.default(function(src){return!!(src.match(/main\.(.*)\.bundle.js$/)||src.match("main.bundle.js"))}),new _webpack.DefinePlugin(_envFlags.default),new _webpack.WatchIgnorePlugin({paths:[/\.d\.ts$/]}),_common.CONFIG.sourceMap&&new _webpack.SourceMapDevToolPlugin(_common.CONFIG.sourceMap),new _webpackbar.default({name:"编译中",color:"#6f42c1"}),new _done.default({done:function(){var _CONFIG_done;if(!_processEnv.DEV&&_common.CONFIG.seo){(0,_seo.seo)()}(_CONFIG_done=_common.CONFIG.done)===null||_CONFIG_done===void 0?void 0:_CONFIG_done.call(_common.CONFIG)}})],_toConsumableArray(_common.CONFIG.plugins)).filter(Boolean),experiments:{topLevelAwait:true,syncWebAssembly:true,asyncWebAssembly:true},resolve:{extensions:[".tsx",".ts",".js",".jsx"],alias:alias,fallback:{path:false,fs:false,crypto:false,assert:false}},module:_moduleConfig.default,externals:_common.CONFIG.externals,output:outputConfig};var _default=config;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});function _export(target,all){for(var name in all)Object.defineProperty(target,name,{enumerable:true,get:all[name]})}_export(exports,{outputConfig:function(){return outputConfig},default:function(){return _default}});var _fs=_interopRequireDefault(require("fs"));var _path=require("path");var _addAssetHtmlWebpackPlugin=_interopRequireDefault(require("add-asset-html-webpack-plugin"));var _htmlWebpackPlugin=_interopRequireDefault(require("html-webpack-plugin"));var _webpack=require("webpack");var _webpackbar=_interopRequireDefault(require("webpackbar"));var _common=require("./common");var _done=_interopRequireDefault(require("./done"));var _envFlags=_interopRequireDefault(require("./envFlags"));var _htmlAddEntryAttr=_interopRequireDefault(require("./html-add-entry-attr"));var _htmlPluginOption=_interopRequireDefault(require("./html-plugin-option"));var _moduleFederation=require("./module-federation");var _moduleConfig=_interopRequireDefault(require("./module.config"));var _processEnv=require("./process-env");var _seo=require("./seo");var _utils=require("./utils");function _arrayLikeToArray(arr,len){if(len==null||len>arr.length)len=arr.length;for(var i=0,arr2=new Array(len);i<len;i++)arr2[i]=arr[i];return arr2}function _arrayWithoutHoles(arr){if(Array.isArray(arr))return _arrayLikeToArray(arr)}function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true})}else{obj[key]=value}return obj}function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}function _iterableToArray(iter){if(typeof Symbol!=="undefined"&&iter[Symbol.iterator]!=null||iter["@@iterator"]!=null)return Array.from(iter)}function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _objectSpread(target){for(var i=1;i<arguments.length;i++){var source=arguments[i]!=null?arguments[i]:{};var ownKeys=Object.keys(source);if(typeof Object.getOwnPropertySymbols==="function"){ownKeys=ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym){return Object.getOwnPropertyDescriptor(source,sym).enumerable}))}ownKeys.forEach(function(key){_defineProperty(target,key,source[key])})}return target}function _toConsumableArray(arr){return _arrayWithoutHoles(arr)||_iterableToArray(arr)||_unsupportedIterableToArray(arr)||_nonIterableSpread()}function _unsupportedIterableToArray(o,minLen){if(!o)return;if(typeof o==="string")return _arrayLikeToArray(o,minLen);var n=Object.prototype.toString.call(o).slice(8,-1);if(n==="Object"&&o.constructor)n=o.constructor.name;if(n==="Map"||n==="Set")return Array.from(n);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray(o,minLen)}var eslintrc=[".eslintrc.js",".eslintrc.json",".eslintrc.yaml",".eslintrc.json"];var stylelintrc=[".stylelintrc",".stylelintrc.json",".stylelintrc.yaml",".stylelintrc.yml",".stylelintrc.js","stylelint.config.js","stylelint.config.cjs"];var rootFiles=_fs.default.readdirSync(_processEnv.PROGRAMPATH);var hasEslint=false,hasStylelint=false;for(var i=0,len=rootFiles.length;i<len;i++){if(stylelintrc.includes(rootFiles[i])){hasStylelint=true}if(eslintrc.includes(rootFiles[i])){hasEslint=true}}if(!hasEslint){hasEslint=_processEnv.hasEslintConfig}if(!hasStylelint){hasStylelint=_processEnv.hasStylelintConfig}var StylelintPlugin=hasStylelint?require("stylelint-webpack-plugin"):null;var ESLintPlugin=hasEslint?require("eslint-webpack-plugin"):null;var alias={"@":(0,_utils.resolveProgramPath)("src")};Object.assign(alias,_common.CONFIG.alias);if(_processEnv.APPTYPE==="library"){Object.assign(alias,_defineProperty({"@":(0,_utils.resolveProgramPath)("site"),"@pkg":(0,_utils.resolveProgramPath)("components")},_processEnv.PACKAGENAME,(0,_utils.resolveProgramPath)("components")))}var assetHtmlOption=_common.CONFIG.assetHtml.map(function(item){return _objectSpread({publicPath:""},item)});var outputConfig={path:(0,_utils.resolveProgramPath)(_processEnv.APPTYPE==="library"?"docs":"dist"),filename:"js/[name].bundle.js",chunkFilename:"js/[name].chunk.js",assetModuleFilename:"assets/[name].[hash][ext]",library:_processEnv.PACKAGENAME,libraryTarget:"window",globalObject:"window",chunkLoadingGlobal:"webpackJsonp_".concat(_processEnv.PACKAGENAME),pathinfo:false,clean:true,publicPath:_common.PUBLICPATH};var mainEntry=(0,_path.join)(__dirname,"../lib/packages/".concat(_common.ENTRYPATH[_processEnv.APPTYPE],"/index.js"));if(_processEnv.APPTYPE==="single-component"){Object.assign(alias,_defineProperty({},_processEnv.PACKAGENAME,(0,_utils.resolveProgramPath)("umd")));mainEntry=(0,_utils.resolveProgramPath)(_processEnv.DEV?"example/index.ts":"src/index.ts");outputConfig.path=(0,_utils.resolveProgramPath)(_processEnv.DEV?"dist":"umd");outputConfig.filename="index.js";outputConfig.library=_processEnv.PACKAGENAME;outputConfig.libraryTarget="umd";outputConfig.libraryExport="default"}var entryMap={main:mainEntry};if(_common.CONFIG.entry){if(typeof _common.CONFIG.entry==="string"){entryMap=_common.CONFIG.entry}else if(Object.keys(_common.CONFIG.entry)){Object.assign(entryMap,_common.CONFIG.entry)}}if(_common.CONFIG.output){if(typeof _common.CONFIG.output==="string"){outputConfig.path=_common.CONFIG.output}else if(Object.keys(_common.CONFIG.output)){Object.assign(outputConfig,_common.CONFIG.output)}}var dirDeep=_common.CONFIG.routeBaseName.split("/").filter(Boolean).length;var page404=Array(dirDeep).fill("..").join("/")+(dirDeep?"/":"")+"404.html";var _ref=_common.CONFIG.fixBrowserRouter||{},_ref_pathSegmentsToKeep=_ref.pathSegmentsToKeep,pathSegmentsToKeep=_ref_pathSegmentsToKeep===void 0?dirDeep:_ref_pathSegmentsToKeep,_ref_path=_ref.path,path=_ref_path===void 0?page404:_ref_path;var config={entry:entryMap,stats:"errors-only",infrastructureLogging:{level:"none"},target:"web",plugins:[new _webpack.AutomaticPrefetchPlugin].concat(_toConsumableArray(_moduleFederation.moduleFederation),[ESLintPlugin&&new ESLintPlugin({threads:true,extensions:["js","md","mdx","cjs","ejs","mjs","jsx","ts","tsx","json","html","coffee","vue"]}),StylelintPlugin&&new StylelintPlugin({fix:true,threads:true,extensions:["css","scss","sass","less","ts","tsx","js","jsx"],exclude:["node_modules/","es/","lib/","docs/","coverage/","dist/"]}),new _htmlWebpackPlugin.default(_htmlPluginOption.default),_common.CONFIG.fixBrowserRouter&&new _htmlWebpackPlugin.default({filename:path,inject:false,templateContent:function(){return"<html html><head><title>".concat(_htmlPluginOption.default.title,"</title><script>var pathSegmentsToKeep = ").concat(pathSegmentsToKeep||dirDeep,";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 _addAssetHtmlWebpackPlugin.default(assetHtmlOption),_processEnv.APPTYPE==="single-spa"&&new _htmlAddEntryAttr.default(function(src){return!!(src.match(/main\.(.*)\.bundle.js$/)||src.match("main.bundle.js"))}),new _webpack.DefinePlugin(_envFlags.default),new _webpack.WatchIgnorePlugin({paths:[/\.d\.ts$/]}),_common.CONFIG.sourceMap&&new _webpack.SourceMapDevToolPlugin(_common.CONFIG.sourceMap),new _webpackbar.default({name:"编译中",color:"#6f42c1"}),new _done.default({done:function(){var _CONFIG_done;if(!_processEnv.DEV&&_common.CONFIG.seo){(0,_seo.seo)()}(_CONFIG_done=_common.CONFIG.done)===null||_CONFIG_done===void 0?void 0:_CONFIG_done.call(_common.CONFIG)}})],_toConsumableArray(_common.CONFIG.plugins)).filter(Boolean),experiments:{topLevelAwait:true,syncWebAssembly:true,asyncWebAssembly:true},resolve:{extensions:[".tsx",".ts",".js",".jsx"],alias:alias,fallback:{path:false,fs:false,crypto:false,assert:false}},module:_moduleConfig.default,externals:_common.CONFIG.externals,output:outputConfig};var _default=config;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moneko/core",
3
- "version": "2.0.18.2",
3
+ "version": "2.0.18.4",
4
4
  "description": "core",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {
@@ -147,14 +147,22 @@ export declare type ConfigType<T = 'tsc'> = {
147
147
  /** 路由模式
148
148
  * @description
149
149
  * 当在不支持 browserRouter 的环境(GitHub pages)使用 browserRouter,
150
- * 则需要添加设置 pathSegmentsToKeep: 1 // 数值根据情况而定
150
+ * 则需要添加设置 fixBrowserRouter
151
151
  * @default 'browser'
152
152
  * */
153
153
  routerMode: 'hash' | 'browser' | 'memory';
154
154
  /** 在不支持 browserRouter 的环境(GitHub pages)使用 browserRouter
155
- * @default false
156
155
  */
157
- pathSegmentsToKeep: false | number;
156
+ fixBrowserRouter?:
157
+ | false
158
+ | {
159
+ /** 在不支持 browserRouter 的环境(GitHub pages)使用 browserRouter
160
+ * @default 1
161
+ */
162
+ pathSegmentsToKeep: number;
163
+ /** 文件输出路径 */
164
+ path?: string;
165
+ };
158
166
  /** webpack 插件 */
159
167
  plugins: WebpackPluginInstance[];
160
168
  /** 对生产chunk进行拆分 */