@moneko/core 3.1.5 → 3.2.0
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 -2
- package/lib/config.d.ts +1 -2
- package/lib/config.js +1 -1
- package/lib/html-plugin-option.js +1 -1
- package/lib/index.d.ts +4 -1
- package/lib/index.js +1 -1
- package/lib/minify.d.ts +1 -1
- package/lib/module.config.js +3 -3
- package/lib/paths.d.ts +1 -0
- package/lib/paths.js +1 -1
- package/lib/polyfills/replace-children.d.ts +1 -0
- package/lib/polyfills/replace-children.js +3 -0
- package/lib/process-env.d.ts +14 -2
- package/lib/process-env.js +7 -1
- package/lib/prod.js +2 -2
- package/package.json +3 -3
- package/typings/global.d.ts +31 -0
package/lib/common.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
import e from"fs";import t from"add-asset-html-webpack-plugin";import s from"html-webpack-plugin";import
|
|
2
|
-
NODE_ENV:process.env.NODE_ENV})}),new D({paths:[/\.d\.ts$/]}),l.sourceMap&&new P(l.sourceMap),l.bar&&new n(l.bar),new i({done:()=>{!y&&l.seo&&w(),l.done?.(),y||setTimeout(()=>{process.exit(0)},2e3)}}),new v(C),...l.plugins].filter(Boolean),experiments:{topLevelAwait:!0,syncWebAssembly:!0,asyncWebAssembly:!0},resolve:{extensions:[".tsx",".ts",".js",".jsx"],alias:l.alias,fallback:{path:!1,fs:!1,crypto:!1,assert:!1}},module:c,externals:l.externals,output:outputConfig};
|
|
1
|
+
import e from"fs";import t from"add-asset-html-webpack-plugin";import s from"html-webpack-plugin";import l from"webpack";import o from"webpackbar";import"./cleanup.js";import{CONFIG as n,PUBLICPATH as r}from"./config.js";import i from"./done.js";import a from"./html-add-entry-attr.js";import p from"./html-plugin-option.js";import{moduleFederation as c}from"./module-federation.js";import m from"./module.config.js";import u from"./paths.js";import{CUSTOMCONFIG as f,PACKAGENAME as d,PACKAGEVERSION as h,hasEslintConfig as j,hasStylelintConfig as y,isDev as g,isLibrary as b,isMicro as w}from"./process-env.js";import{seo as x}from"./seo.js";import{resolveNodeModulesPath as k,resolveProgramPath as v}from"./utils.js";import C from"./virtual-module-plugin.js";import $ from"./virtual-modules.js";let{AutomaticPrefetchPlugin:O,DefinePlugin:P,SourceMapDevToolPlugin:M,WatchIgnorePlugin:S}=l,B=[".eslintrc.js",".eslintrc.json",".eslintrc.yaml",".eslintrc.json"],D=[".stylelintrc",".stylelintrc.json",".stylelintrc.yaml",".stylelintrc.yml",".stylelintrc.js","stylelint.config.js","stylelint.config.cjs"],T=e.readdirSync(u.programPath),A=!1,H=!1;for(let e=0,t=T.length;e<t;e++)D.includes(T[e])&&(H=!0),B.includes(T[e])&&(A=!0);A||(A=j),H||(H=y);let K=H?(await import("stylelint-webpack-plugin")).default:null,L=A?(await import("eslint-webpack-plugin")).default:null,F=n.assetHtml.map(e=>({publicPath:"",...e}));export const outputConfig={path:v(b?"docs":"dist"),filename:"js/[name].bundle.js",chunkFilename:`js/[${g?"name":"chunkhash"}].js`,assetModuleFilename:e=>{let t=e.filename;return t&&t.endsWith("?url")&&/(?:webworker|worker)(\.|\b).*\.(js|ts)\b/.test(t.replace("?url",""))?"worker/[name][ext]":"assets/[name][hash][ext]"},library:{name:d,type:"window"},globalObject:"window",chunkLoadingGlobal:`webpackJsonp_${d}`,pathinfo:g,clean:!0,publicPath:r,asyncChunks:!0,charset:!0};let J={main:k("@app/entry")};n.polyfill&&Object.assign(J,{"dom-polyfills":[`${u.corePath}/polyfills/replace-children.js`]}),n.entry&&("string"==typeof n.entry?J={main:n.entry}:Object.keys(n.entry)&&Object.assign(J,n.entry)),n.output&&("string"==typeof n.output?outputConfig.path=n.output:Object.keys(n.output)&&Object.assign(outputConfig,n.output));let R=n.basename.split("/").filter(Boolean).length,U=`${Array(R).fill("..").join("/")+(R?"/":"")}404.html`,{pathSegmentsToKeep:W=R,path:_=U}=n.fixBrowserRouter||{},z=!1;n.cacheDirectory&&(z={type:"filesystem",store:"pack",allowCollectingMemory:!0,cacheDirectory:n.cacheDirectory,memoryCacheUnaffected:!0,name:`${f||"default"}-${g?"development":"production"}`,version:h});export const clientConfig={entry:J,stats:"errors-only",cache:z,infrastructureLogging:{level:"none"},target:"web",externalsPresets:n.externalsPresets,plugins:[new O,...c,L&&new L({fix:!0,threads:!0,extensions:["js","md","mdx","cjs","ejs","mjs","jsx","ts","tsx","json","html","coffee","vue"]}),K&&new K({fix:!0,threads:!0,extensions:["css","scss","sass","less","ts","tsx","js","jsx"],exclude:["node_modules/","es/","lib/","docs/","coverage/","dist/"]}),n.htmlPluginOption&&new s(p),n.fixBrowserRouter&&new s({filename:_,inject:!1,templateContent:()=>`<html html><head><title>${p.title}</title><script>var pathSegmentsToKeep = ${W||R};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),w&&new a(e=>!!(e.match(/main\.(.*)\.bundle.js$/)||e.match("main.bundle.js"))),new P({"process.env":JSON.stringify(n.env)}),new S({paths:[/\.d\.ts$/]}),n.sourceMap&&new M(n.sourceMap),n.bar&&new o(n.bar),new i({done:()=>{!g&&n.seo&&x(),n.done?.(),g||setTimeout(()=>{process.exit(0)},2e3)}}),new C($),...n.plugins].filter(Boolean),experiments:{topLevelAwait:!0,asyncWebAssembly:!0,cacheUnaffected:!0,layers:!0,lazyCompilation:g&&{imports:!1,entries:!1},buildHttp:n.buildHttp,backCompat:!0,futureDefaults:!1,css:!1,outputModule:!1},resolve:{extensions:[".tsx",".ts",".js",".jsx",".wasm"],alias:n.alias,fallback:{path:!1,fs:!1,crypto:!1,assert:!1}},module:m,externals:n.externals,output:outputConfig};
|
package/lib/config.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare const ENTRYPATH: Record<AppType, string>;
|
|
1
|
+
import type { ConfigType } from '.';
|
|
3
2
|
export declare const log: (msg: string) => void;
|
|
4
3
|
export declare const CONFIG: ConfigType<"swc">;
|
|
5
4
|
export declare const PUBLICPATH: string;
|
package/lib/config.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{accessSync as e,constants as t}from"fs";import o from"readline";import s from"chalk";import{merge as r}from"webpack-merge";import i from"./paths.js";import{APPTYPE as a,CUSTOMCONFIG as l,FRAMEWORK as n,PACKAGENAME as c,
|
|
1
|
+
import{accessSync as e,constants as t}from"fs";import o from"readline";import s from"chalk";import{merge as r}from"webpack-merge";import i from"./paths.js";import{APPTYPE as a,CUSTOMCONFIG as l,FRAMEWORK as n,PACKAGENAME as c,coreName as m,jsxImportSource as p}from"./process-env.js";import{isFunction as u,readConf as d,resolveProgramPath as h}from"./utils.js";let f=["@moneko/core",`@moneko/${n}`,"neko-ui","antd","@antv","katex","font-pingfang-sc","font-pingfang-tc","react-photo-view","react-markdown-editor-lite","schema-design","@app"],g={library:{"@":h("site"),"@pkg":h("components"),[c]:h("components")},mobile:{},site:{},backstage:{},micro:{}},x={seo:!1,mode:"csr",compiler:"swc",bundleAnalyzer:!1,polyfill:!1,entry:{},minifier:{js:{},css:{}},sourceMap:{filename:"[file].map",publicPath:""},env:{NODE_ENV:process.env.NODE_ENV},basename:"/",publicPath:"/",rem:{designSize:"mobile"===a?375:1680},fallbackCompPath:null,modifyVars:{},prefixCls:"n",alias:Object.assign({"@":h("src")},g[a]),moduleRules:[],prefixJsLoader:[],cssModules:[],importOnDemand:{},proxy:[],cacheDirectory:i.webpackCachePath,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:{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"}}},runtimeChunk:"single",moduleFederation:[],rulesInclude:{less:f,css:f,js:f,media:f,fonts:f,wasm:[]},mdx:{jsxImportSource:p,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,externalsPresets:{},buildHttp:{allowedUris:[],lockfileLocation:`${i.httpCachePath}/http.lock`,cacheLocation:`${i.httpCachePath}/data`,upgrade:!0}};export const log=e=>{o.cursorTo(process.stdout,0),process.stdout.write(e)};let C=x,w=null,b={},y={};try{w=i.defaultConfigPath,e(w,t.R_OK)}catch(e){w=null}if(w)try{let e=(await d(w,"index")).default;b=u(e)?e(process):e}catch(e){process.stdout.write(s.red(e))}if(l){let o=null;try{o=`${i.programPath}/config/${l}.ts`,e(o,t.R_OK)}catch(e){o=null}if(null!==o)try{let e=(await d(o,l)).default;y=u(e)?e(process):e}catch(e){process.stdout.write(s.red(e))}}"tsc"===(C=r(C,b,y)).compiler&&C.minifier&&(C.minifier.js||Object.assign(C.minifier,{js:{type:"terser"}}),C.minifier.css||Object.assign(C.minifier,{css:{type:"cssnano"}})),!1===C.devtool&&(C.sourceMap=!1),!1===C.sourceMap&&(C.devtool=!1),C.fixBrowserRouter&&C.htmlPluginOption&&(C.htmlPluginOption.tags||(C.htmlPluginOption.tags=[]),C.htmlPluginOption.tags.push({textContent:"(function(l) {if (l.search[1] === '/' ) {var decoded = l.search.slice(1).split('&').map(function(s) {return s.replace(/~and~/g, '&')}).join('?');window.history.replaceState(null, null,l.pathname.slice(0, -1) + decoded + l.hash);}}(window.location))"}));export const CONFIG=C;export const PUBLICPATH=CONFIG.publicPath||"/";export let hasCustomRouter=!1;try{e(`${CONFIG.alias["@"]}/router/index.ts`,t.R_OK),hasCustomRouter=!0}catch(e){hasCustomRouter=!1}global.NEKOCLICONFIG={CONFIG,log};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{merge as e}from"webpack-merge";import t from"./app.js";import{CONFIG as i}from"./config.js";import o from"./paths.js";import{PACKAGENAME as a,
|
|
1
|
+
import{merge as e}from"webpack-merge";import t from"./app.js";import{CONFIG as i}from"./config.js";import o from"./paths.js";import{PACKAGENAME as a,coreName as r}from"./process-env.js";let{template:p,favicon:m,...n}=Object.assign({template:`node_modules/${r}/template/index.html`,favicon:`node_modules/${r}/template/favicon.ico`},i.htmlPluginOption||{}),l=e({title:i.env?.PROJECTNAME||a.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:t.description||""},tags:[],template:`${o.programPath}/${p}`,favicon:`${o.programPath}/${m}`},n);export default l;
|
package/lib/index.d.ts
CHANGED
|
@@ -1 +1,4 @@
|
|
|
1
|
-
export
|
|
1
|
+
export { default as paths } from './paths.js';
|
|
2
|
+
export { CUSTOMCONFIG, FRAMEWORKNAME, PACKAGENAME, PACKAGEVERSION, coreName, isDev, isLibrary, isMicro, } from './process-env.js';
|
|
3
|
+
export { realResolve, resolveNodeModulesPath, resolveProgramPath } from './utils.js';
|
|
4
|
+
export type * from '../typings/global.d.ts';
|
package/lib/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export{default as paths}from"./paths.js";export{CUSTOMCONFIG,FRAMEWORKNAME,PACKAGENAME,PACKAGEVERSION,coreName,isDev,isLibrary,isMicro}from"./process-env.js";export{realResolve,resolveNodeModulesPath,resolveProgramPath}from"./utils.js";
|
package/lib/minify.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import TerserPlugin from 'terser-webpack-plugin';
|
|
2
|
-
import type { MinifierType, SwcOptions, TerserOptions } from '
|
|
2
|
+
import type { MinifierType, SwcOptions, TerserOptions } from '.';
|
|
3
3
|
import type { JsMinifyOptions } from '@swc/core';
|
|
4
4
|
type MinifyObject = {
|
|
5
5
|
terser: {
|
package/lib/module.config.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import e from"mini-css-extract-plugin";import s from"mini-svg-data-uri";import{CONFIG as
|
|
2
|
-
auto:e=>{for(let s=0,
|
|
3
|
-
localIdentName:"[path][name]__[local]",exportLocalsConvention:"dashesOnly"},importLoaders:2}}
|
|
1
|
+
import e from"mini-css-extract-plugin";import s from"mini-svg-data-uri";import{CONFIG as t,PUBLICPATH as o}from"./config.js";import{hasPkg as r}from"./has-pkg.js";import l from"./modify-vars.js";import a from"./paths.js";import{FRAMEWORK as i,isDev as n,isLibrary as c,isMicro as m}from"./process-env.js";import p from"./swcrc.js";import d from"./tsloader.config.js";import{resolveNodeModulesPath as u,resolveProgramPath as f}from"./utils.js";let y={loader:`${a.corePath}/loader/css-unicode.cjs`},x=m?o:"../",$={loader:e.loader,options:{publicPath:"/"!==x?x:"../"}},g=r("@moneko/postcss")&&{loader:"postcss-loader",options:{postcssOptions:await import("@moneko/postcss")}};n&&($="style-loader");let j=[...t.cssModules,`@moneko/${i}`,"neko-ui"].map(u),w=[...["src/styles/variables.less","src/styles/mixins.less","site/styles/variables.less","site/styles/mixins.less"].map(f)],v=["components","example","mock","site","src","server"].map(f),b=[$,n&&{loader:"@teamsupercell/typings-for-css-modules-loader",options:{verifyOnly:!n}},{loader:"css-loader",options:{modules:{// 根据文件名觉得是否启用cssModules | 排除 node_modules 和 *global.css 和 *global.less
|
|
2
|
+
auto:e=>{for(let s=0,t=j.length;s<t;s++)if(e&&e?.includes(j[s]))return/(.*(?<!\.?global\.(le|c)ss)$)/i.test(e);return/(^(?!.*node_modules))(.*(?<!\.?global\.(le|c)ss)$)/i.test(e)},// localIdentName: isDev ? '[path][name]__[local]' : '[hash:base64]',
|
|
3
|
+
localIdentName:"[path][name]__[local]",exportLocalsConvention:"dashesOnly"},importLoaders:2}},g,y,{loader:"less-loader",options:{sourceMap:!!t.sourceMap,lessOptions:{modifyVars:l,javascriptEnabled:!0}}},{loader:"style-resources-loader",options:{patterns:w}}].filter(Boolean),h={loader:"tsc"===t.compiler?"ts-loader":"swc-loader",options:"tsc"===t.compiler?d:p(n)},I=v.concat(t.rulesInclude?.media?.map(u)||[]),k=v.concat(t.rulesInclude?.fonts?.map(u)||[]),O=v.concat(t.rulesInclude?.less?.map(u)||[]),B=v.concat(t.rulesInclude?.css?.map(u)||[]),L=v.concat(t.rulesInclude?.js?.map(u)||[]),M=v.concat(t.rulesInclude?.wasm?.map(u)||[]),P={rules:[c&&{test:/\.mdx?$/i,include:[f("components")],exclude:[/(.+)\/examples\/(.+).mdx?$/i],enforce:"pre",use:[{loader:`${a.corePath}/loader/frontmatter.cjs`}]},{oneOf:[{resourceQuery:/raw/i,type:"asset/source"},{resourceQuery:/url/i,type:"asset/resource",generator:{filename:e=>{let s=e.filename;return s&&s.endsWith("wasm?url")?"wasm/[name][ext]":"assets/[name][ext]"}}},{test:/\.wasm$/i,type:"webassembly/async",include:M},{test:/\.txt$/i,type:"asset/source"},{test:/\.ico$/i,type:"asset/inline",include:I},{test:/\.svg$/i,type:"asset/inline",generator:{dataUrl:e=>s("string"!=typeof e?e.toString():e)},include:I},{test:/\.(gif|png|jpe?g|mp4)$/i,type:"asset",dependency:{not:["url"]},generator:{filename:"assets/images/[name][ext]"},include:I},{test:/\.(eot|ttf|otf|woff|woff2)$/i,type:"asset",dependency:{not:["url"]},generator:{filename:"assets/fonts/[name][ext]"},include:k},{test:/\.less$/i,use:b,include:O},{test:/\.css$/i,use:[$,"css-loader",g,y].filter(Boolean),include:B},{test:/\.(cj|mj|t|j)s(|x)$/i,use:[...t.prefixJsLoader,h].filter(Boolean),include:L},{test:/\.mdx?$/i,use:[...t.prefixJsLoader,h,{loader:"@mdx-js/loader",options:t.mdx}].filter(Boolean),include:v,exclude:[/(.+)\/examples\/(.+).mdx?$/i]},{test:/\.mdx?$/i,type:"asset/source",include:[/(.+)\/examples\/(.+).mdx?$/i]},{type:"asset/source",include:[/(.+)\/examples\/(.+).*?$/i]}]},...t.moduleRules].filter(e=>"object"==typeof e)};export default P;
|
package/lib/paths.d.ts
CHANGED
package/lib/paths.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{existsSync as e,mkdirSync as o}from"fs";import a from"url";let
|
|
1
|
+
import{existsSync as e,mkdirSync as o}from"fs";import a from"url";let t=process.cwd(),c=`${t}/node_modules/.cache/.mo`;e(c)||o(c,{recursive:!0});export default{corePath:a.fileURLToPath(new URL(".",import.meta.url)),programPath:t,webpackCachePath:`${t}/node_modules/.temp_cache`,cachePath:c,httpCachePath:`${t}/node_modules/.cache/http`,swcCachePath:`${t}/node_modules/.swc`,defaultConfigPath:`${t}/config/index.ts`,coveragePath:`${t}/coverage/clover.xml`,pagesPath:`${t}/src/pages`,componentsPath:`${t}/components`};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
declare function replaceChildrenPolyfill(...nodes: (string | Node)[]): void;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
function e(...t){/**
|
|
2
|
+
* @ts-ignore */// eslint-disable-next-line consistent-this, no-invalid-this, @typescript-eslint/no-this-alias
|
|
3
|
+
let o=this,r=t.length,l=Array(r);for(let e=0;e<r;e++)l[e]=t[e];for(;o.firstChild;)o.removeChild(o.firstChild);l.forEach(function(e){"string"==typeof e?o.appendChild(document.createTextNode(e)):o.appendChild(e)})}Element.prototype.replaceChildren||(Element.prototype.replaceChildren=e),ShadowRoot.prototype.replaceChildren||(ShadowRoot.prototype.replaceChildren=e);
|
package/lib/process-env.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AppType, Framework } from '
|
|
1
|
+
import type { AppType, Framework } from '.';
|
|
2
2
|
export declare const APPTYPE: AppType;
|
|
3
3
|
export declare const FRAMEWORK: Framework;
|
|
4
4
|
export declare const isLibrary: boolean;
|
|
@@ -7,11 +7,23 @@ export declare const isReact: boolean;
|
|
|
7
7
|
export declare const isSolid: boolean;
|
|
8
8
|
export declare const jsxImportSource: string;
|
|
9
9
|
export declare const createElement: string;
|
|
10
|
+
/** 框架名称 */
|
|
10
11
|
export declare const FRAMEWORKNAME: string;
|
|
12
|
+
/** 应用名称 */
|
|
11
13
|
export declare const PACKAGENAME: string;
|
|
14
|
+
/** 版本号 */
|
|
12
15
|
export declare const PACKAGEVERSION: string;
|
|
13
|
-
|
|
16
|
+
/** core 包名 */
|
|
17
|
+
export declare const coreName: string;
|
|
18
|
+
/** 是否为本地开发环境 */
|
|
14
19
|
export declare const isDev: boolean;
|
|
20
|
+
/** 附加启动配置名称
|
|
21
|
+
* @example
|
|
22
|
+
* 当通过以下命令启动时, 此时 CUSTOMCONFIG 为 test
|
|
23
|
+
* ```sh
|
|
24
|
+
* npm run start --config=test
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
15
27
|
export declare const CUSTOMCONFIG: string | undefined;
|
|
16
28
|
export declare const hasEslintConfig: boolean;
|
|
17
29
|
export declare const hasStylelintConfig: boolean;
|
package/lib/process-env.js
CHANGED
|
@@ -1 +1,7 @@
|
|
|
1
|
-
import{readFileSync as e}from"fs";import o from"./paths.js";import t from"./yarn-argv.js";export const APPTYPE=process.env.APPTYPE;export const FRAMEWORK=process.env.FRAMEWORK;export const isLibrary="library"===APPTYPE;export const isMicro="micro"===APPTYPE;export const isReact="react"===FRAMEWORK;export const isSolid="solid"===FRAMEWORK;export const jsxImportSource={react:"react",solid:"solid-js/h"}[FRAMEWORK];export const createElement={react:"createElement",solid:"createComponent"}[FRAMEWORK]
|
|
1
|
+
import{readFileSync as e}from"fs";import o from"./paths.js";import t from"./yarn-argv.js";export const APPTYPE=process.env.APPTYPE;export const FRAMEWORK=process.env.FRAMEWORK;export const isLibrary="library"===APPTYPE;export const isMicro="micro"===APPTYPE;export const isReact="react"===FRAMEWORK;export const isSolid="solid"===FRAMEWORK;export const jsxImportSource={react:"react",solid:"solid-js/h"}[FRAMEWORK];export const createElement={react:"createElement",solid:"createComponent"}[FRAMEWORK];/** 框架名称 */export const FRAMEWORKNAME={react:"react",solid:"solid-js"}[FRAMEWORK];/** 应用名称 */export const PACKAGENAME=process.env.npm_package_name;/** 版本号 */export const PACKAGEVERSION=process.env.npm_package_version;let s=e(`${o.corePath}/../package.json`,{encoding:"utf-8"});/** core 包名 */export const coreName=JSON.parse(s).name;/** 是否为本地开发环境 */export const isDev="development"===process.env.NODE_ENV;/** 附加启动配置名称
|
|
2
|
+
* @example
|
|
3
|
+
* 当通过以下命令启动时, 此时 CUSTOMCONFIG 为 test
|
|
4
|
+
* ```sh
|
|
5
|
+
* npm run start --config=test
|
|
6
|
+
* ```
|
|
7
|
+
*/export const CUSTOMCONFIG=process.env.npm_config_config||t.config;let n=Object.keys(process.env);export const hasEslintConfig=-1!==n.findIndex(e=>e.startsWith("npm_package_eslintConfig_"));export const hasStylelintConfig=-1!==n.findIndex(e=>e.startsWith("npm_package_stylelint_"));
|
package/lib/prod.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import e from"css-minimizer-webpack-plugin";import i from"mini-css-extract-plugin";import n from"terser-webpack-plugin";import m from"webpack";import{BundleAnalyzerPlugin as o}from"webpack-bundle-analyzer";import{merge as
|
|
1
|
+
import e from"css-minimizer-webpack-plugin";import i from"mini-css-extract-plugin";import n from"terser-webpack-plugin";import m from"webpack";import{BundleAnalyzerPlugin as o}from"webpack-bundle-analyzer";import{merge as s}from"webpack-merge";import{clientConfig as r}from"./common.js";import{CONFIG as t}from"./config.js";import{getMinifyOption as p}from"./minify.js";let{optimize:l}=m,{cssnanoMinify:u,swcMinify:a}=e,c="swc"===t.compiler,f=[];t.minifier&&(t.minifier.js&&f.push(new n(p(t.minifier.js?.type||(c?"swc":"terser"),t.minifier.js?.options))),t.minifier.css&&f.push(new e({minify:{swc:a,cssnano:u}[t.minifier.css?.type||(c?"swc":"cssnano")],minimizerOptions:t.minifier.css?.options})));let d={splitChunks:t.splitChunk,runtimeChunk:t.runtimeChunk,chunkIds:"named",moduleIds:"named",// parent chunk中解决了的chunk会被删除
|
|
2
2
|
removeAvailableModules:!0,// 删除空的chunks
|
|
3
3
|
removeEmptyChunks:!0,// 合并重复的chunk
|
|
4
|
-
mergeDuplicateChunks:!0,minimize:!0,minimizer:f},k=r
|
|
4
|
+
mergeDuplicateChunks:!0,mangleWasmImports:!0,minimize:!0,minimizer:f},k=s(r,{devtool:!1===t.devtool||t.devtool?t.devtool:"cheap-module-source-map",mode:"production",optimization:d,plugins:[// 压缩 css
|
|
5
5
|
new i({filename:"style/[name].bundle.css",chunkFilename:"style/[name].chunk.css",experimentalUseImportModule:!0}),t.bundleAnalyzer&&new o(t.bundleAnalyzer),t.splitChunk&&new l.MinChunkSizePlugin({minChunkSize:1e4})].filter(Boolean)});export default[k];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moneko/core",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.2.0",
|
|
4
4
|
"description": "core",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -12,9 +12,9 @@
|
|
|
12
12
|
"author": "moneko",
|
|
13
13
|
"license": "MIT",
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@mdx-js/loader": "
|
|
15
|
+
"@mdx-js/loader": "3.0.0",
|
|
16
16
|
"@soda/friendly-errors-webpack-plugin": "1.8.1",
|
|
17
|
-
"@swc/core": "1.3.
|
|
17
|
+
"@swc/core": "1.3.95",
|
|
18
18
|
"@swc/css": "0.0.28",
|
|
19
19
|
"@swc/helpers": "0.5.3",
|
|
20
20
|
"@teamsupercell/typings-for-css-modules-loader": "2.5.2",
|
package/typings/global.d.ts
CHANGED
|
@@ -219,6 +219,7 @@ export declare type ConfigType<T extends 'tsc' | 'swc' = 'swc'> = {
|
|
|
219
219
|
js?: string[];
|
|
220
220
|
media?: string[];
|
|
221
221
|
fonts?: string[];
|
|
222
|
+
wasm?: string[];
|
|
222
223
|
};
|
|
223
224
|
/** bundle分析
|
|
224
225
|
* @default false
|
|
@@ -280,7 +281,37 @@ export declare type ConfigType<T extends 'tsc' | 'swc' = 'swc'> = {
|
|
|
280
281
|
*/
|
|
281
282
|
normalizeCss?: boolean;
|
|
282
283
|
externalsPresets?: ExternalsPresets;
|
|
284
|
+
/** 允许构建以http(s):协议开头的远程资源 */
|
|
285
|
+
buildHttp?: HttpUriOptions | (string | RegExp | ((uri: string) => boolean))[];
|
|
283
286
|
};
|
|
287
|
+
/**
|
|
288
|
+
* 用于构建 http 资源的选项
|
|
289
|
+
*/
|
|
290
|
+
declare interface HttpUriOptions {
|
|
291
|
+
/** 允许的 URI 列表 */
|
|
292
|
+
allowedUris: (string | RegExp | ((uri: string) => boolean))[];
|
|
293
|
+
/**
|
|
294
|
+
* 存储锁定文件条目的资源内容的位置。
|
|
295
|
+
* 也可以通过传递 false 来禁用存储。
|
|
296
|
+
*/
|
|
297
|
+
cacheLocation?: string | false;
|
|
298
|
+
/**
|
|
299
|
+
* 冻结; 设置后, 任何会导致锁定文件或任何资源内容修改的行为都将导致错误。
|
|
300
|
+
*/
|
|
301
|
+
frozen?: boolean;
|
|
302
|
+
/**
|
|
303
|
+
* 锁定文件的位置
|
|
304
|
+
*/
|
|
305
|
+
lockfileLocation?: string;
|
|
306
|
+
/**
|
|
307
|
+
* 代理配置,可用于指定用于 HTTP 请求的代理服务器
|
|
308
|
+
*/
|
|
309
|
+
proxy?: string;
|
|
310
|
+
/**
|
|
311
|
+
* 升级, 设置后,将获取现有锁定文件条目的资源,并在资源内容更改时升级条目。
|
|
312
|
+
*/
|
|
313
|
+
upgrade?: boolean;
|
|
314
|
+
}
|
|
284
315
|
export declare interface ModuleFederationOption {
|
|
285
316
|
/** 模块名称,唯一性,不能重名 */
|
|
286
317
|
name: string;
|