@moneko/core 3.0.0-beta.4 → 3.0.0-beta.6
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.d.ts +1 -1
- package/build/common.js +12 -1
- package/build/coverage.d.ts +1 -1
- package/build/coverage.js +1 -1
- package/build/done.js +1 -1
- package/build/envFlags.js +1 -1
- package/build/has-pkg.js +1 -1
- package/build/html-add-entry-attr.js +1 -1
- package/build/html-plugin-option.d.ts +1 -1
- package/build/html-plugin-option.js +1 -1
- package/build/index.d.ts +2 -2
- package/build/index.js +1 -1
- package/build/minify.d.ts +1 -1
- package/build/minify.js +1 -1
- package/build/modifyVars.js +1 -1
- package/build/module-federation.js +1 -1
- package/build/module.config.js +1 -1
- package/build/process-env.d.ts +1 -1
- package/build/process-env.js +1 -1
- package/build/resolver-sync.js +1 -1
- package/build/seo.js +1 -1
- package/build/swcrc.js +1 -1
- package/build/tsloader.config.js +1 -1
- package/build/utils.js +1 -1
- package/build/webpack.common.js +1 -1
- package/build/webpack.dev.js +4 -1
- package/build/webpack.prod.js +1 -1
- package/build/yarn-argv.js +1 -1
- package/package.json +3 -2
package/build/common.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AppType, ConfigType } from '../typings/global';
|
|
1
|
+
import type { AppType, ConfigType } from '../typings/global.d.ts';
|
|
2
2
|
export declare const ENTRYPATH: Record<AppType, string>;
|
|
3
3
|
export declare const log: (msg: string) => void;
|
|
4
4
|
export declare const CONFIG: ConfigType<"swc">;
|
package/build/common.js
CHANGED
|
@@ -1 +1,12 @@
|
|
|
1
|
-
import fs from"fs";import path from"path";import readline from"readline";import chalk from"chalk";import{merge}from"webpack-merge";import{APPTYPE,CUSTOMCONFIG,pkgName,PROGRAMPATH}from"./process-env";import{tfc,isFunction}from"./utils";export
|
|
1
|
+
import fs from"fs";import path from"path";import readline from"readline";import chalk from"chalk";import{merge}from"webpack-merge";import{APPTYPE,CUSTOMCONFIG,pkgName,PROGRAMPATH}from"./process-env.js";import{tfc,isFunction}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 includeModule=[pkgName,"neko-ui","antd","@antv","katex","font-pingfang-sc","font-pingfang-tc","react-photo-view","react-markdown-editor-lite","schema-design"],defaultSplitChunk={chunks:"all",minSize:1024,minChunks:1};"single-component"===APPTYPE&&(defaultSplitChunk=!1);let defaultConfig={seo:!1,mode:"csr",compiler:"swc",bundleAnalyzer:{analyzerMode:"static",reportFilename:"report.html",openAnalyzer:!1},entry:{},minifier:{},sourceMap:{filename:"[file].map",publicPath:""},env:{},routeBaseName:"/",publicPath:"/",designSize:"mobile"===APPTYPE?375:1680,fallbackCompPath:null,modifyVars:{},prefixCls:"n",alias:{},layoutSider:{},moduleRules:[],prefixJsLoader:[],cssModules:[],importOnDemand:{},proxy:[],cacheDirectory:PROGRAMPATH+"/node_modules/.temp_cache",devServer:{allowedHosts:[".baidu.com"],host:"localhost",port:3e3,https:!1,compress:!1},htmlPluginOption:{template:`./node_modules/${pkgName}/template/index.html`,favicon:`./node_modules/${pkgName}/template/favicon.ico`,tags:[]},assetHtml:[],routerMode:"browser",fixBrowserRouter:!1,plugins:[],splitChunk:defaultSplitChunk,runtimeChunk:"single-component"!==APPTYPE&&"single",moduleFederation:[],rulesInclude:{less:includeModule,css:includeModule,js:includeModule,media:includeModule,fonts:includeModule}};export const log=e=>{readline.cursorTo(process.stdout,0),process.stdout.write(e)};let customConf=defaultConfig,configPath=null,normalConf={},envConf={};try{configPath=path.join(PROGRAMPATH,"./config/index.ts"),fs.accessSync(configPath,fs.constants.R_OK)}catch(error){configPath=null}if(configPath)try{let conf=eval(tfc(configPath)).default;normalConf=isFunction(conf)?conf(process):conf}catch(error){process.stdout.write(chalk.red(error))}if(CUSTOMCONFIG){let customConfigPath=null;try{customConfigPath=path.join(PROGRAMPATH,`./config/${CUSTOMCONFIG}.ts`),fs.accessSync(customConfigPath,fs.constants.R_OK)}catch(error){customConfigPath=null}if(null!==customConfigPath)try{let conf=eval(tfc(customConfigPath)).default;envConf=isFunction(conf)?conf(process):conf}catch(error){process.stdout.write(chalk.red(error))}}customConf=merge(customConf,normalConf,envConf),!1===customConf.devtool&&(customConf.sourceMap=!1),!1===customConf.sourceMap&&(customConf.devtool=!1),customConf.fixBrowserRouter&&(customConf.htmlPluginOption.tags||(customConf.htmlPluginOption.tags=[]),customConf.htmlPluginOption.tags.push({textContent:`
|
|
2
|
+
(function(l) {
|
|
3
|
+
if (l.search[1] === '/' ) {
|
|
4
|
+
var decoded = l.search.slice(1).split('&').map(function(s) {
|
|
5
|
+
return s.replace(/~and~/g, '&')
|
|
6
|
+
}).join('?');
|
|
7
|
+
window.history.replaceState(null, null,
|
|
8
|
+
l.pathname.slice(0, -1) + decoded + l.hash
|
|
9
|
+
);
|
|
10
|
+
}
|
|
11
|
+
}(window.location))
|
|
12
|
+
`}));export const CONFIG=customConf;export const PUBLICPATH=CONFIG.publicPath||"/";global.NEKOCLICONFIG={CONFIG,log};
|
package/build/coverage.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { CoverageType, ProjectCoverageType } from '../typings/global';
|
|
1
|
+
import type { CoverageType, ProjectCoverageType } from '../typings/global.d.ts';
|
|
2
2
|
export declare const coverage: Record<string, CoverageType & Partial<ProjectCoverageType>>;
|
package/build/coverage.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{readFileSync as
|
|
1
|
+
import{readFileSync as e,accessSync as r,constants as c}from"fs";import{join as o}from"path";import{Parser as t}from"xml2js";import{PACKAGENAME as a,PROGRAMPATH as s}from"./process-env.js";export const coverage={};try{let i=o(s,"./coverage/clover.xml");r(i,c.R_OK);let m=new t({explicitArray:!1,async:!1}),p=e(i,{encoding:"utf-8"});m.parseString(p,(e,r)=>{if(!e){let e=r.coverage.project.metrics.$,c=r.coverage.project.package;Object.assign(coverage,{[a]:e}),c.forEach(e=>{Object.assign(coverage,{[e.$.name]:e.metrics.$})})}})}catch(e){}
|
package/build/done.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
export default class{constructor(o){this.options=Object.assign({},o)}apply(o){let t=this;o.hooks.done.tap("DoneWebpackPlugin",function(){t.options.done?.()})}};
|
package/build/envFlags.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import i from"fs";import r from"path";import{CONFIG as e}from"./common.js";import{coverage as t}from"./coverage.js";import o from"./html-plugin-option.js";import{APPTYPE as s,NODE_ENV as n,PACKAGENAME as a,programInfo as f,PROGRAMPATH as c,hasAntd as m,hasReact as p}from"./process-env.js";import{toUpperCaseString as l}from"./utils.js";let g=p?require("react/package.json").version:"18",y=parseFloat(g)>=18?"react-dom/client":"react-dom",S="library"===s?"site":"src",N=!1;try{let e=r.join(c,"./src/index.ts");i.accessSync(e,i.constants.R_OK),N=e}catch(i){N=!1}let O={projectName:JSON.stringify(l(a)),projectCoverage:JSON.stringify(t),providerConfig:JSON.stringify({prefixCls:e.prefixCls,iconPrefixCls:e.prefixCls+"-icon",theme:e.theme}),fallbackCompPath:JSON.stringify(e.fallbackCompPath),ReactDOMPath:JSON.stringify(y),favicon:JSON.stringify(o.favicon),hasLocales:JSON.stringify(i.existsSync(r.join(c,`./${S}/locales`))),hasPersist:JSON.stringify(i.existsSync(r.join(c,`./${S}/persist.ts`))),layoutSider:JSON.stringify(e.layoutSider),hasAntd:JSON.stringify(m),APPTYPE:JSON.stringify(s),APPENTRY:JSON.stringify(N),programInfo:JSON.stringify({...f,routeBaseName:e.routeBaseName,designSize:e.designSize,routerMode:e.routerMode,renderMode:e.mode}),"process.env":JSON.stringify({NODE_ENV:n,iconfont:e.iconfont,...e.env})};export default O;
|
package/build/has-pkg.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{accessSync as o,constants as r}from"fs";import t from"path";import{PROGRAMPATH as
|
|
1
|
+
import{accessSync as o,constants as r}from"fs";import t from"path";import{PROGRAMPATH as e}from"./process-env.js";export function hasPkg(m){let n=!1;try{let p=t.join(e,`./node_modules/${m}/package.json`);o(p,r.R_OK),n=!0}catch(o){n=!1}return n}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
export default class{constructor(t){this.entryMatchCallback=t}apply(t){t.hooks.compilation.tap("AddEntryAttributeWebpackPlugin",a=>{let e=t.options.plugins.map(({constructor:t})=>t).find(t=>t&&"HtmlWebpackPlugin"===t.name);if(e){let t=e.getHooks(a);t.alterAssetTagGroups.tap("AddEntryAttributeWebpackPlugin",t=>(t.headTags.forEach(t=>{"script"===t.tagName&&"string"==typeof t.attributes?.src&&this.entryMatchCallback(t.attributes.src)&&(t.attributes.entry=!0)}),t))}})}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"path";import{merge as t}from"webpack-merge";import{CONFIG as i}from"./common";import{PROGRAMPATH as o,PACKAGENAME as r,programInfo as a}from"./process-env";
|
|
1
|
+
import e from"path";import{merge as t}from"webpack-merge";import{CONFIG as i}from"./common.js";import{PROGRAMPATH as o,PACKAGENAME as r,programInfo as a}from"./process-env.js";let{template:p,favicon:m,...n}=i.htmlPluginOption,l=t({title:i.env?.PROJECTNAME||r.toLocaleUpperCase()||"Title",filename:"index.html",hash:!1,minify:{collapseWhitespace:!0,removeComments:!0,removeRedundantAttributes:!1,removeScriptTypeAttributes:!1,removeStyleLinkTypeAttributes:!1,removeAttributeQuotes:!0,useShortDoctype:!0},meta:{charset:"UTF-8","X-UA-Compatible":{"http-equiv":"X-UA-Compatible",content:"IE=edge,Chrome=1"},HandheldFriendly:"true",MobileOptimized:"320","screen-orientation":"portrait","x5-orientation":"portrait",browsermode:"application","x5-page-mode":"app","msapplication-tap-highlight":"no",viewport:"width=device-width,initial-scale=1,maximum-scale=1,minimum-scale=1,user-scalable=no","apple-mobile-web-app-capable":"yes",renderer:"webkit",description:a.description||""},tags:[],template:e.join(o,p),favicon:e.join(o,m)},n);export default l;
|
package/build/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './process-env';
|
|
2
|
-
export * from './utils';
|
|
1
|
+
export * from './process-env.js';
|
|
2
|
+
export * from './utils.js';
|
package/build/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export*from"./process-env";export*from"./utils";
|
|
1
|
+
export*from"./process-env.js";export*from"./utils.js";
|
package/build/minify.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import TerserPlugin from 'terser-webpack-plugin';
|
|
2
|
-
import type { MinifierType, SwcOptions, TerserOptions } from '../typings/global';
|
|
2
|
+
import type { MinifierType, SwcOptions, TerserOptions } from '../typings/global.d.ts';
|
|
3
3
|
import type { JsMinifyOptions } from '@swc/core/types';
|
|
4
4
|
type MinifyObject = {
|
|
5
5
|
terser: {
|
package/build/minify.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"terser-webpack-plugin";import{merge as
|
|
1
|
+
import e from"terser-webpack-plugin";import{merge as o}from"webpack-merge";import{swcMinifyOption as r}from"./swcrc.js";export const minify={terser:{minify:e.terserMinify,terserOptions:{ecma:2015,parse:{},compress:{global_defs:{"@alert":"console.log"},drop_console:!0,drop_debugger:!0,pure_funcs:["console.log","console.warn","console.error","console.info"]},toplevel:!1,mangle:!0,module:!1,format:{comments:!1},ie8:!1,keep_classnames:void 0,keep_fnames:!1,safari10:!1},extractComments:!1},swc:{minify:e.swcMinify,terserOptions:r}};export const getMinifyOption=(e,r={})=>{let s=minify[e];return Object.assign(s,{terserOptions:o(s.terserOptions,r)})};
|
package/build/modifyVars.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{CONFIG as i}from"./common";import o from"./html-plugin-option";
|
|
1
|
+
import{CONFIG as i}from"./common.js";import o from"./html-plugin-option.js";let f=i.prefixCls||"n",n={};Object.assign(n,{"@prefix-cls":f,"@ant-prefix":f,"@iconfont-css-prefix":f+"-icon","@favicon":JSON.stringify(o.favicon)},i.modifyVars||{});export default n;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import e from"external-remotes-plugin";import{NormalModuleReplacementPlugin as r}from"webpack";import t from"webpack/lib/container/ModuleFederationPlugin.js";import{CONFIG as o}from"./common.js";import{resolve as i}from"./utils.js";let s={},a={},l={};export const moduleFederation=o.moduleFederation?.map(e=>{if(Array.isArray(e.remotes))for(let r=0,t=e.remotes.length;r<t;r++){let t=e.remotes[r],o=t.alias||t.name,i=t.filename||"remote_entry.js";if(l[o]=`${t.name}@${t.host}/${i}`,Array.isArray(t.library))for(let e=0,r=t.library.length;e<r;e++)s[t.library[e]]=`${o}/${t.library[e]}`}if(Array.isArray(e.exposes))for(let r=0,t=e.exposes.length;r<t;r++){let t=e.exposes[r];"string"==typeof t?a[`./${t}`]=i(t):"[object Object]"===Object.prototype.toString.call(t)&&(a[`./${t.name}`]=i(t.path))}return new t({filename:"remote_entry.js",...e,remotes:l,exposes:a})});moduleFederation.length&&(moduleFederation.push(new e),moduleFederation.push(new r(/(.*)/,e=>{s[e.request]&&(e.request=s[e.request])})));
|
package/build/module.config.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import e from"mini-css-extract-plugin";import s from"mini-svg-data-uri";import{CONFIG as o,PUBLICPATH as t}from"./common.js";import{hasPkg as r}from"./has-pkg.js";import l from"./modifyVars.js";import{APPTYPE as a,DEV as i,pkgName as c}from"./process-env.js";import n from"./swcrc.js";import p from"./tsloader.config.js";import{resolveNodeModulesPath as m,resolveProgramPath as u}from"./utils.js";let d="single-spa"===a?t:"../",f={loader:e.loader,options:{publicPath:"/"!==d?d:"../"}},y=r("@moneko/postcss")&&{loader:"postcss-loader",options:{postcssOptions:require("@moneko/postcss")}};i&&(f="style-loader");let x=[...o.cssModules,c,"neko-ui"].map(m),g=[m(`${c}/lib/styles/eval/*.less`),...["src/styles/variables/*.less","src/styles/mixins/*.less","site/styles/variables/*.less","site/styles/mixins/*.less"].map(u)],j=["components","example","mock","site","src"].map(u),$=[f,{loader:"css-loader",options:{modules:{auto:e=>{for(let s=0,o=x.length;s<o;s++)if(e&&e?.includes(x[s]))return/(.*(?<!\.global\.(le|c)ss)$)/i.test(e);return/(^(?!.*node_modules))(.*(?<!\.global\.(le|c)ss)$)/i.test(e)},localIdentName:"[path][name]__[local]",exportLocalsConvention:"dashesOnly"},importLoaders:2}},y,"css-unicode-loader",{loader:"less-loader",options:{sourceMap:!!o.sourceMap,lessOptions:{modifyVars:l,javascriptEnabled:!0}}},{loader:"style-resources-loader",options:{patterns:g}}].filter(Boolean),b={loader:"tsc"===o.compiler?"ts-loader":"swc-loader",options:"tsc"===o.compiler?p:n(i)},h={rules:[{oneOf:[{resourceQuery:/raw/,type:"asset/source"},{resourceQuery:/\.wasm$/,type:"webassembly/async"},{test:/\.less$/,use:$,include:j.concat(o.rulesInclude?.less?.map(m)||[])},{test:/\.css$/,use:[f,"css-loader",y,"css-unicode-loader"].filter(Boolean),include:j.concat(o.rulesInclude?.css?.map(m)||[])},{test:/\.(gif|png|jpe?g|ico|mp4)$/i,type:"asset",generator:{filename:"assets/images/[name][ext][query]"},include:j.concat(o.rulesInclude?.media?.map(m)||[])},{test:/\.(eot|ttf|otf|woff(|2))$/,type:"asset",generator:{filename:"assets/fonts/[name][ext][query]"},include:j.concat(o.rulesInclude?.fonts?.map(m)||[])},{test:/\.svg$/,type:"asset/inline",generator:{dataUrl:e=>s("string"!=typeof e?e.toString():e)}},{test:/\.txt$/,type:"asset/source"},{test:/\.(cj|mj|t|j)s(|x)$/,use:[...o.prefixJsLoader,b].filter(Boolean),include:j.concat(o.rulesInclude?.js?.map(m)||[])},{test:/\.mdx?$/,use:[...o.prefixJsLoader,b,{loader:"@mdx-js/loader",options:{jsxImportSource:"solid-js/h",rehypePlugins:[[require("@mapbox/rehype-prism"),{ignore:!0}],require("rehype-accessible-emojis").rehypeAccessibleEmojis,require("rehype-figure")],remarkPlugins:[]}}].filter(Boolean),include:j,exclude:[/(.+)\/examples\/(.+).mdx?$/i]},{test:/\.mdx?$/,type:"asset/source",include:[/(.+)\/examples\/(.+).mdx?$/i]},{type:"asset/source",include:[/(.+)\/examples\/(.+).*?$/i]}]},...o.moduleRules]};export default h;
|
package/build/process-env.d.ts
CHANGED
package/build/process-env.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{hasPkg as e}from"./has-pkg";import{resolveProgramPath as
|
|
1
|
+
import{hasPkg as e}from"./has-pkg.js";import{resolveProgramPath as o}from"./utils.js";import r from"./yarn-argv.js";export const APPTYPE=process.env.APPTYPE;export const PROGRAMPATH=process.cwd();export const PACKAGENAME=process.env.npm_package_name;export const PACKAGEVERSION=process.env.npm_package_version;export const pkgName=require("../package.json").name;export const NODE_ENV=process.env.NODE_ENV;export const CUSTOMCONFIG=process.env.npm_config_config||r.config;export const DEV="development"===process.env.NODE_ENV;export let hasEslintConfig=!!Object.keys(process.env).filter(e=>e.startsWith("npm_package_eslintConfig_")).length;export let hasStylelintConfig=!!Object.keys(process.env).filter(e=>e.startsWith("npm_package_stylelint_")).length;export const hasReact=e("react");export const hasAntd=e("antd");export const programInfo={name:PACKAGENAME,version:PACKAGEVERSION,type:APPTYPE,description:process.env.npm_package_description,author:{name:process.env.npm_package_author_name,email:process.env.npm_package_author_email,url:process.env.npm_package_author_url},repository:{type:process.env.npm_package_repository_type,url:process.env.npm_package_repository_url,directory:process.env.npm_package_repository_directory}};if(parseInt(process.versions.node)>14){let{description:e,author:r,repository:s,eslintConfig:n,stylelint:t}=require(o("package.json"));programInfo.author="string"==typeof r?{name:r}:r,programInfo.repository="string"==typeof r?{url:s}:s,programInfo.description=e,hasEslintConfig=!!n,hasStylelintConfig=!!t}
|
package/build/resolver-sync.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import*as e from"fs";import{CachedInputFileSystem as s,ResolverFactory as o}from"enhanced-resolve";
|
|
1
|
+
import*as e from"fs";import{CachedInputFileSystem as s,ResolverFactory as o}from"enhanced-resolve";let n=o.createResolver({fileSystem:new s(e,4e3),conditionNames:["node"],extensions:[".js",".json",".node"],useSyncFileSystemCalls:!0,mainFields:["esm","module","main"]});export default n;
|
package/build/seo.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{existsSync as t,mkdirSync as o,writeFile as
|
|
1
|
+
import{existsSync as t,mkdirSync as o,writeFile as e,readdirSync as r,statSync as s}from"fs";import{join as m}from"path";import{CONFIG as p}from"./common.js";import{APPTYPE as i,PROGRAMPATH as n}from"./process-env.js";import{resolveProgramPath as c}from"./utils.js";import{outputConfig as f}from"./webpack.common.js";export const seo=()=>{let{domain:a,nojekyll:u,path:l}=p.seo||{};if(!a)return;let h=l&&c(l)||f?.path||process.cwd(),j=t=>{if(t)throw t};t(h)||o(h),e(m(h,"CNAME"),a,"utf-8",j),e(m(h,"robots"),`Sitemap: https://${a}${p.routeBaseName}sitemap.txt`,"utf-8",j);let E="";"library"===i&&(E=(function t(o,e,m){let p=[],i=r(o);return i.forEach(function(r){if("static"===r)return!1;let i=o+"/"+r,c=s(i);c&&c.isDirectory()?p=p.concat(t(i,e,m)):i.endsWith("README.mdx")&&p.push("https://"+e+m+i.replace(n+"/components/","").replace("/README.mdx",""))}),p})(m(n,"./components"),a,p.routeBaseName).join("\n")),e(m(h,"sitemap.txt"),E,"utf-8",j),u&&e(m(h,".nojekyll"),"","utf-8",j)};
|
package/build/swcrc.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{merge as e}from"webpack-merge";import{CONFIG as o}from"./common";import r from"./envFlags";
|
|
1
|
+
import{merge as e}from"webpack-merge";import{CONFIG as o}from"./common.js";import r from"./envFlags.js";let t={env:{targets:["last 2 version","> 0.5%","ie 11","not dead"],mode:"entry",coreJs:"3"}};export const swcMinifyOption={compress:{top_retain:[],keep_infinity:!0,global_defs:{"@alert":"console.log"},pure_funcs:["console.log","console.warn","console.error","console.info"],toplevel:!1,drop_console:!0,drop_debugger:!0,module:!1,ecma:2015,ie8:!1,keep_classnames:void 0,keep_fnames:!1},mangle:!0};export default((s=!1)=>{let n={module:{type:"es6",ignoreDynamic:!0,strict:!0,strictMode:!0,lazy:!0,noInterop:!0},jsc:{parser:{syntax:"typescript",decorators:!0,dynamicImport:!0,tsx:!0},loose:!0,target:"es2022",externalHelpers:!0,transform:{legacyDecorator:!0,decoratorMetadata:!0,react:{runtime:"automatic",throwIfNamespace:!0,useBuiltins:!0,refresh:s,development:s},constModules:{globals:{"env-flags":r}},optimizer:{simplify:!1}},experimental:{plugins:[["swc-plugin-another-transform-imports",function(e){for(let o=0,r=Object.keys(e),t=r.length;o<t;o++)e[r[o]].transform=`${r[o]}/${e[r[o]].transform}`,e[r[o]].style&&(e[r[o]].style=`${r[o]}/${e[r[o]].style}`);return e}(o.importOnDemand||{})]]}},sourceMaps:!0,parseMap:!0},a=Object.assign(n,!s&&t);return o.swcrc&&(a=e(a,"function"==typeof o.swcrc?o.swcrc(s):o.swcrc)),a});
|
package/build/tsloader.config.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import fs from"fs";import transformerFactory from"ts-import-plugin";import merge from"webpack-merge";import{CONFIG}from"./common";import{tfc,isFunction,resolveProgramPath}from"./utils";
|
|
1
|
+
import fs from"fs";import transformerFactory from"ts-import-plugin";import merge from"webpack-merge";import{CONFIG}from"./common.js";import{tfc,isFunction,resolveProgramPath}from"./utils.js";let importOnDemand=[];Array.isArray(CONFIG.importOnDemand)&&Object.assign(importOnDemand,CONFIG.importOnDemand.map(r=>transformerFactory(r)));let beforeTransformers=[...importOnDemand],tsLoaderConfig={transpileOnly:!0,getCustomTransformers:()=>({before:beforeTransformers})};try{let customTsloaderConfigPath=resolveProgramPath("tsloader.config.ts");fs.accessSync(customTsloaderConfigPath,fs.constants.R_OK);let customTsloaderConfig=eval(tfc(customTsloaderConfigPath)).default;tsLoaderConfig=merge(tsLoaderConfig,isFunction(customTsloaderConfig)?customTsloaderConfig(process):customTsloaderConfig)}catch(error){}export default tsLoaderConfig;
|
package/build/utils.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{networkInterfaces}from"os";import path from"path";import{transformFileSync}from"@swc/core";import resolverSync from"./resolver-sync.js";let swcOption={inputSourceMap:!1,sourceMaps:!1,module:{type:"commonjs"},jsc:{parser:{syntax:"typescript"},loose:!1}};export const tfc=filepath=>{let out=transformFileSync(filepath,swcOption).code||"{}";try{return eval(out)}catch(error){return out}};export function toUpperCaseString(e){return e?.replace(/\b\w/g,e=>e.toUpperCase()).replace(/\./g," ")}export function getIPAdress(){let e=networkInterfaces();for(let t in e)if(Object.prototype.hasOwnProperty.call(e,t)){let r=e[t];for(let e=0;e<r.length;e++){let t=r[e];if("IPv4"===t.family&&"127.0.0.1"!==t.address&&!t.address.startsWith("169.254")&&!t.internal)return t.address}}}export function resolveProgramPath(e){return path.resolve(process.cwd(),"./"+e)}export const resolveNodeModulesPath=e=>resolveProgramPath(`node_modules/${e}`);export const resolve=e=>resolverSync.resolveSync({},process.cwd(),e)||e;let funcTag="[object Function]",asyncTag="[object AsyncFunction]",genTag="[object GeneratorFunction]",proxyTag="[object Proxy]";export function isObject(e){let t=typeof e;return null!==e&&("object"==t||"function"==t)}export function isFunction(e){if(!isObject(e))return!1;let t=Object.prototype.toString.call(e);return t==funcTag||t==asyncTag||t==genTag||t==proxyTag}
|
package/build/webpack.common.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import e from"fs";import{join as t}from"path";import s from"url";import n from"add-asset-html-webpack-plugin";import o from"html-webpack-plugin";import{DefinePlugin as l,WatchIgnorePlugin as i,SourceMapDevToolPlugin as r,AutomaticPrefetchPlugin as a}from"webpack";import p from"webpackbar";import{CONFIG as m,ENTRYPATH as c,PUBLICPATH as u}from"./common.js";import f from"./done.js";import d from"./envFlags.js";import g from"./html-add-entry-attr.js";import j from"./html-plugin-option.js";import{moduleFederation as h}from"./module-federation.js";import b from"./module.config.js";import{APPTYPE as y,DEV as w,hasEslintConfig as x,hasStylelintConfig as k,PACKAGENAME as C,PROGRAMPATH as v}from"./process-env.js";import{seo as O}from"./seo.js";import{resolveProgramPath as T}from"./utils.js";let $=[".eslintrc.js",".eslintrc.json",".eslintrc.yaml",".eslintrc.json"],B=[".stylelintrc",".stylelintrc.json",".stylelintrc.yaml",".stylelintrc.yml",".stylelintrc.js","stylelint.config.js","stylelint.config.cjs"],L=e.readdirSync(v),A=!1,R=!1;for(let e=0,t=L.length;e<t;e++)B.includes(L[e])&&(R=!0),$.includes(L[e])&&(A=!0);A||(A=x),R||(R=k);let S=R?require("stylelint-webpack-plugin"):null,F=A?require("eslint-webpack-plugin"):null,K={"@":T("src")};Object.assign(K,m.alias),"library"===y&&Object.assign(K,{"@":T("site"),"@pkg":T("components"),[C]:T("components")});let M=m.assetHtml.map(e=>({publicPath:"",...e}));export const outputConfig={path:T("library"===y?"docs":"dist"),filename:"js/[name].bundle.js",chunkFilename:"js/[name].chunk.js",assetModuleFilename:"assets/[name].[hash][ext]",library:C,libraryTarget:"window",globalObject:"window",chunkLoadingGlobal:`webpackJsonp_${C}`,pathinfo:!1,clean:!0,publicPath:u};let P=s.fileURLToPath(new URL(".",import.meta.url)),q=t(P,`../lib/packages/${c[y]}/index.js`);"single-component"===y&&(Object.assign(K,{[C]:T("umd")}),q=T(w?"example/index.ts":"src/index.ts"),outputConfig.path=T(w?"dist":"umd"),outputConfig.filename="index.js",outputConfig.library=C,outputConfig.libraryTarget="umd",outputConfig.libraryExport="default");let U={main:q};m.entry&&("string"==typeof m.entry?U=m.entry:Object.keys(m.entry)&&Object.assign(U,m.entry)),m.output&&("string"==typeof m.output?outputConfig.path=m.output:Object.keys(m.output)&&Object.assign(outputConfig,m.output));let W=m.routeBaseName.split("/").filter(Boolean).length,_=Array(W).fill("..").join("/")+(W?"/":"")+"404.html",{pathSegmentsToKeep:E=W,path:G=_}=m.fixBrowserRouter||{},H={entry:U,stats:"errors-only",infrastructureLogging:{level:"none"},target:"web",plugins:[new a,...h,F&&new F({threads:!0,extensions:["js","md","mdx","cjs","ejs","mjs","jsx","ts","tsx","json","html","coffee","vue"]}),S&&new S({fix:!0,threads:!0,extensions:["css","scss","sass","less","ts","tsx","js","jsx"],exclude:["node_modules/","es/","lib/","docs/","coverage/","dist/"]}),new o(j),m.fixBrowserRouter&&new o({filename:G,inject:!1,templateContent:()=>`<html html><head><title>${j.title}</title><script>var pathSegmentsToKeep = ${E||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 n(M),"single-spa"===y&&new g(e=>!!(e.match(/main\.(.*)\.bundle.js$/)||e.match("main.bundle.js"))),new l(d),new i({paths:[/\.d\.ts$/]}),m.sourceMap&&new r(m.sourceMap),new p({name:"编译中",color:"#6f42c1"}),new f({done:()=>{!w&&m.seo&&O(),m.done?.()}}),...m.plugins].filter(Boolean),experiments:{topLevelAwait:!0,syncWebAssembly:!0,asyncWebAssembly:!0},resolve:{extensions:[".tsx",".ts",".js",".jsx"],alias:K,fallback:{path:!1,fs:!1,crypto:!1,assert:!1}},module:b,externals:m.externals,output:outputConfig};export default H;
|
package/build/webpack.dev.js
CHANGED
|
@@ -1 +1,4 @@
|
|
|
1
|
-
import e from"@soda/friendly-errors-webpack-plugin";import
|
|
1
|
+
import e from"@soda/friendly-errors-webpack-plugin";import o from"chalk";import{getPort as r}from"portfinder";import{HotModuleReplacementPlugin as t}from"webpack";import{merge as s}from"webpack-merge";import{CONFIG as p}from"./common.js";import{hasPkg as l}from"./has-pkg.js";import{hasReact as i}from"./process-env.js";import{getIPAdress as a,resolveProgramPath as m}from"./utils.js";import n from"./webpack.common.js";let c=l("@moneko/mock"),d=c?require("@moneko/mock").default:null,v=i?require("@pmmmwh/react-refresh-webpack-plugin").default:null,h=!1;p.cacheDirectory&&(h={type:"filesystem",allowCollectingMemory:!0,cacheDirectory:p.cacheDirectory});let u=!1===p.devtool||p.devtool?p.devtool:"eval-cheap-module-source-map",f=new Promise(l=>{r({port:p.devServer.port,stopPort:9999},(r,f)=>{let w=[];p.devServer.port!==f&&w.push(`Port ${o.yellow(p.devServer.port)} is in use, trying ${o.green(f)} instead`),p.devServer.port=f;let g="/"===p.routeBaseName,k=p.devServer.https?"https:":"http:",y=g?"":p.routeBaseName,$=s(n,{devtool:u,mode:"development",cache:h,devServer:{headers:{"Access-Control-Allow-Origin":"*"},compress:p.devServer.compress,host:"0.0.0.0",port:f,historyApiFallback:g||{index:y,disableDotRule:!0},https:p.devServer.https,proxy:p.proxy,allowedHosts:p.devServer.allowedHosts,client:{progress:!1,logging:"info",overlay:!1},static:{watch:{ignored:e=>e.endsWith(".d.ts")}},setupMiddlewares:(e,o)=>{if(!o)throw Error("webpack-dev-server is not defined");return o.app&&c&&d(o.app,m("mock/")),e},open:!1,hot:!0},plugins:[new t,i&&new v,new e({compilationSuccessInfo:{messages:[`You application is running here:
|
|
2
|
+
|
|
3
|
+
local: ${o.cyan(`${k}//${p.devServer.host}:${f}${y}`)}
|
|
4
|
+
network: ${o.cyan(`${k}//${a()}:${f}${y}`)}`],notes:w},clearConsole:!0})].filter(Boolean)});l($)})});export default f;
|
package/build/webpack.prod.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import e,{cssnanoMinify as i,swcMinify as n}from"css-minimizer-webpack-plugin";import
|
|
1
|
+
import e,{cssnanoMinify as i,swcMinify as n}from"css-minimizer-webpack-plugin";import m from"mini-css-extract-plugin";import o from"terser-webpack-plugin";import{optimize as r}from"webpack";import{BundleAnalyzerPlugin as s}from"webpack-bundle-analyzer";import{merge as t}from"webpack-merge";import{CONFIG as c}from"./common.js";import{getMinifyOption as l}from"./minify.js";import p from"./webpack.common.js";let a="swc"===c.compiler?"swc":"terser",u="swc"===c.compiler?"swc":"cssnano",d={splitChunks:c.splitChunk,runtimeChunk:c.runtimeChunk,chunkIds:"named",moduleIds:"named",removeAvailableModules:!0,removeEmptyChunks:!0,mergeDuplicateChunks:!0,minimize:!0,minimizer:[new o(l(c.minifier.js?.type||a,c.minifier.js?.options)),new e({minify:{swc:n,cssnano:i}[c.minifier.css?.type||u],minimizerOptions:c.minifier.css?.options})]},f=!1;c.cacheDirectory&&(f={type:"filesystem",allowCollectingMemory:!0,cacheDirectory:c.cacheDirectory});export default t(p,{devtool:!1===c.devtool||c.devtool?c.devtool:"cheap-module-source-map",mode:"production",cache:f,optimization:d,plugins:[new m({filename:"style/[name].bundle.css",chunkFilename:"style/[name].chunk.css",experimentalUseImportModule:!0}),c.bundleAnalyzer&&new s(c.bundleAnalyzer),c.splitChunk&&new r.MinChunkSizePlugin({minChunkSize:1e4})].filter(Boolean)});
|
package/build/yarn-argv.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
let e=JSON.parse(process.env.npm_config_argv||"{}")?.original,a={};e?.forEach(e=>{let r=e.split("=");Object.assign(a,{[r[0]]:r[1]||!0})});export default a;
|
package/package.json
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moneko/core",
|
|
3
|
-
"version": "3.0.0-beta.
|
|
3
|
+
"version": "3.0.0-beta.6",
|
|
4
4
|
"description": "core",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
|
+
"type": "module",
|
|
6
7
|
"scripts": {
|
|
7
8
|
"build": "npm run build-conf && npm run build-src && npm run build:types",
|
|
8
|
-
"build-conf": "swc config -d build -C module.type=
|
|
9
|
+
"build-conf": "swc config -d build -C module.type=nodenext -C jsc.target=esnext -C jsc.loose=true -C jsc.minify.mangle=true -C jsc.minify.compress=true -C minify=true --copy-files",
|
|
9
10
|
"build-src": "swc src -d lib -C module.type=es6 -C jsc.loose=true -C jsc.minify.mangle=true -C jsc.minify.compress=true -C minify=true --copy-files",
|
|
10
11
|
"build:types": "tsc && tsc --project cli.json",
|
|
11
12
|
"postbuild": "node ./copy.js ./prefix ./lib",
|