@moneko/core 3.43.1 → 3.43.3
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/build/common.mjs +1 -1
- package/lib/config.mjs +1 -1
- package/lib/loader/mdx.cjs +1 -1
- package/lib/loader/react-compiler.cjs +1 -1
- package/lib/loader/react-compiler.d.cts +2 -2
- package/lib/loader/solid.cjs +1 -1
- package/lib/loader/solid.d.cts +1 -1
- package/lib/plugin/html-plugin.mjs +1 -1
- package/lib/vm/render-app.mjs +2 -1
- package/lib/worker/react-compiler.d.mts +20 -0
- package/lib/worker/react-compiler.mjs +1 -0
- package/package.json +3 -3
- package/typings/global.d.ts +7 -0
package/lib/build/common.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"mini-css-extract-plugin";import i from"webpack";import{merge as n}from"webpack-merge";import{commonConfig as t}from"../common.mjs";import{CONFIG as r}from"../config.mjs";import{LightningCssMinifyPlugin as m}from"../plugin/lightningcss-plugin.mjs";import s from"../plugin/swc-minify-plugin.mjs";import{getLightningCssTargets as l}from"../polyfills/targets.mjs";let o=[];r.minifier&&(o.push(new s(r.minifier)),o.push(new m({targets:l()})));let p={maxAssetSize:256e3,maxEntrypointSize:256e3,assetFilter:e=>!e.endsWith(".map")&&!e.endsWith("ce28377f3a428346.js"),...r.performance},a=n(t,{performance:r.performance&&p,plugins:[new e({filename:"style/[contenthash].css",chunkFilename:"style/[contenthash].css",ignoreOrder:!0})],optimization:{splitChunks:r.splitChunk,runtimeChunk:r.runtimeChunk,chunkIds:"deterministic",moduleIds:"deterministic",concatenateModules:!0,emitOnErrors:!1,removeAvailableModules:!0,removeEmptyChunks:!0,mergeDuplicateChunks:!0,minimize:!0,minimizer:o,sideEffects:!0,providedExports:!0}});if(r.splitChunk&&a.plugins?.push(new i.optimize.MinChunkSizePlugin({minChunkSize:
|
|
1
|
+
import e from"mini-css-extract-plugin";import i from"webpack";import{merge as n}from"webpack-merge";import{commonConfig as t}from"../common.mjs";import{CONFIG as r}from"../config.mjs";import{LightningCssMinifyPlugin as m}from"../plugin/lightningcss-plugin.mjs";import s from"../plugin/swc-minify-plugin.mjs";import{getLightningCssTargets as l}from"../polyfills/targets.mjs";let o=[];r.minifier&&(o.push(new s(r.minifier)),o.push(new m({targets:l()})));let p={maxAssetSize:256e3,maxEntrypointSize:256e3,assetFilter:e=>!e.endsWith(".map")&&!e.endsWith("ce28377f3a428346.js"),...r.performance},a=n(t,{performance:r.performance&&p,plugins:[new e({filename:"style/[contenthash].css",chunkFilename:"style/[contenthash].css",ignoreOrder:!0})],optimization:{splitChunks:r.splitChunk,runtimeChunk:r.runtimeChunk,chunkIds:"deterministic",moduleIds:"deterministic",concatenateModules:!0,emitOnErrors:!1,removeAvailableModules:!0,removeEmptyChunks:!0,mergeDuplicateChunks:!0,minimize:!0,minimizer:o,sideEffects:!0,providedExports:!0}});if(r.splitChunk&&a.plugins?.push(new i.optimize.MinChunkSizePlugin({minChunkSize:r.minChunkSize||1e3})),r.bundleAnalyzer){let e=(await import("webpack-bundle-analyzer")).BundleAnalyzerPlugin;a.plugins?.push(new e({analyzerMode:"static",reportFilename:"report.html",openAnalyzer:!1,defaultSizes:"gzip",logLevel:"silent",...r.bundleAnalyzer}))}export default a;
|
package/lib/config.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{relative as e}from"node:path";import o from"node:process";import{fileExists as t}from"@moneko/utils";import{merge as r}from"webpack-merge";import n from"./commom/paths.mjs";import s from"./commom/require.mjs";import i from"./commom/setup-env.mjs";import a from"./options/jsx-dom-expressions.mjs";import l from"./options/split-chunk.mjs";import{isFunction as m,node_modules as p,resolveProgram as c}from"./utils/index.mjs";import{APPTYPE as u,FRAMEWORK as d,frameworkVersion as f,isCI as h,isDev as g,isLibrary as v,isMobile as x,isReact as j,jsxImportSource as C,mainDirectory as P,NODE_ENV as b,PACKAGENAME as
|
|
1
|
+
import{relative as e}from"node:path";import o from"node:process";import{fileExists as t}from"@moneko/utils";import{merge as r}from"webpack-merge";import n from"./commom/paths.mjs";import s from"./commom/require.mjs";import i from"./commom/setup-env.mjs";import a from"./options/jsx-dom-expressions.mjs";import l from"./options/split-chunk.mjs";import{isFunction as m,node_modules as p,resolveProgram as c}from"./utils/index.mjs";import{APPTYPE as u,FRAMEWORK as d,frameworkVersion as f,isCI as h,isDev as g,isLibrary as v,isMobile as x,isReact as j,jsxImportSource as C,mainDirectory as P,NODE_ENV as b,PACKAGENAME as k}from"./process-env.mjs";let w=["@app","@moneko","neko-ui",".cache/http/data","@element-plus","ant-design-vue","element-plus","element-ui","ng-zorro-antd","@mui","@du","@fontsource","@fortawesome","font-pingfang-sc","font-pingfang-tc","katex","react-markdown-editor-lite","react-photo-view","schema-design","monaco-editor"];export function getConfig(e){return delete s.cache[e],new Promise(r=>{if(t(e)){let t=s(e).default;return r(m(t)?t(o):t)}return r({})})}let O=await Promise.all([i(b,u,d,[]),getConfig(n.configPath),getConfig(n.customConfigPath)]),y=O[0],S=O[1],M=O[2],I={strict:!1,devtool:g?"eval-cheap-module-source-map":"cheap-module-source-map",seo:!1,mode:"csr",bundleAnalyzer:!1,polyfill:!1,entry:{},minifier:{},sourceMap:{filename:"[file].map",publicPath:""},env:y,basename:"/",publicPath:"/",rem:{designSize:x?375:1920},fallbackCompPath:null,modifyVars:{},prefixCls:"n",alias:Object.assign({"@":c(P)},j&&f<18?{"react/package.json":p("react/package.json"),"react/jsx-runtime":p("react/jsx-runtime.js"),"react/jsx-dev-runtime":p("react/jsx-dev-runtime.js")}:{}),moduleRules:[],prefixJsLoader:[],cssModules:[],cssModuleDefinition:!0,importOnDemand:{},proxy:{},devServer:{host:"localhost",port:3e3,open:!0},htmlPluginOption:{title:k.toLocaleUpperCase(),favicon:e(n.programPath,`${n.corePath}/options/favicon.ico`)},copy:{},routerMode:"browser",fixBrowserRouter:!1,plugins:[],resolvePlugins:[],overrideResolve:!1,splitChunk:l,runtimeChunk:"single",moduleFederation:[],rulesInclude:{css:w,js:w,media:w,font:w,wasm:[]},mdx:{jsx:!1,development:g,jsxImportSource:C,providerImportSource:`@moneko/${d}/mdx`},jsxDomExpressions:a,bar:{name:"Client",nameColor:"68",msgColor:"242",barBgColor:"15",barColor:"69",quiet:h},normalizeCss:!0,externalsPresets:{},buildHttp:void 0,virtualModule:{},cssExtract:{},externals:["@swc/core"],lazyCompilation:!1,performance:!1,refresh:"solid"!==d,bundleId:"com.moneko.bid",bundles:[],stylelint:{},eslint:{lintDirtyModulesOnly:!1},minChunkSize:1e3};v&&(I.alias=Object.assign(I.alias,{"@pkg":n.componentsPath,[k]:n.componentsPath}));let z=I;(!1===(z=r(z,S,M)).devtool||!1===z.sourceMap)&&(z.sourceMap=!1,z.devtool=!1),z.fixBrowserRouter&&z.htmlPluginOption&&(z.htmlPluginOption.tags||(z.htmlPluginOption.tags=[]),z.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))"})),"true"===o.env.CODESPACES&&(z.devServer.https=!1),!1===z.devServer.https&&"darwin"===o.platform&&(z.devServer.open=!1);export const CONFIG=z;export const PUBLICPATH=CONFIG.publicPath;
|
package/lib/loader/mdx.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e;Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"default",{enumerable:!0,get:function(){return o}});const t=require("@moneko/mdx"),r=(e=require("../commom/log.mjs"))&&e.__esModule?e:{default:e};async function o(e){let o=this.async();this.cacheable&&this.cacheable()
|
|
1
|
+
"use strict";var e;Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"default",{enumerable:!0,get:function(){return o}});const t=require("@moneko/mdx"),r=(e=require("../commom/log.mjs"))&&e.__esModule?e:{default:e};async function o(e){let o=this.async();this.cacheable&&this.cacheable(),(0,t.mdx)({value:e,filepath:this.resourcePath,...this.getOptions()}).then(e=>{o(null,e.code)}).catch(e=>{o(e),(0,r.default)(Error(e))})}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e;Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"default",{enumerable:!0,get:function(){return
|
|
1
|
+
"use strict";var e;Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"default",{enumerable:!0,get:function(){return r}});const t=require("@moneko/eslint/babel-core"),s=require("@moneko/eslint/react-compiler"),o=(e=require("../commom/log.mjs"))&&e.__esModule?e:{default:e};function r(e){let r=this.async();this.cacheable&&this.cacheable();let i=this.getOptions();("annotation"===i.compilationMode?e.includes("use memo")||e.includes("use forget"):e.includes("react")||this.resourcePath.endsWith(".tsx")||this.resourcePath.endsWith(".jsx"))?(0,t.transformAsync)(e,{sourceFileName:this.resourcePath,filename:this.resourcePath,sourceMaps:"inline",plugins:[[s.BabelPluginReactCompiler,i]],cloneInputAst:!1,ast:!1,configFile:!1,babelrc:!1}).then(t=>{null===t?r(Error(`Failed to transform "${this.resourcePath}"`),e):r(null,t.code??void 0,t.map??void 0)}).catch(t=>{t&&((0,o.default)(t),r(t,e))}):r(null,e)}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { transformAsync } from '@moneko/eslint/babel-core';
|
|
2
2
|
import { BabelPluginReactCompiler } from '@moneko/eslint/react-compiler';
|
|
3
3
|
import type { LoaderContext } from 'webpack';
|
|
4
4
|
import log from '../commom/log.mjs';
|
|
@@ -18,4 +18,4 @@ export interface ReactCompilerOption {
|
|
|
18
18
|
gating?: null;
|
|
19
19
|
eslintSuppressionRules?: Record<string, string | boolean | number>;
|
|
20
20
|
}
|
|
21
|
-
export default
|
|
21
|
+
export default function reactCompilerLoader(this: LoaderContext<ReactCompilerOption>, sourceCode: string);
|
package/lib/loader/solid.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e;Object.defineProperty(exports,"__esModule",{value:!0}),function(e,t){for(var n in t)Object.defineProperty(e,n,{enumerable:!0,get:t[n]})}(exports,{custom:function(){return
|
|
1
|
+
"use strict";var e;Object.defineProperty(exports,"__esModule",{value:!0}),function(e,t){for(var n in t)Object.defineProperty(e,n,{enumerable:!0,get:t[n]})}(exports,{custom:function(){return o},default:function(){return i}});const t=require("@moneko/eslint/babel-core"),n=(e=require("solid-refresh/babel"))&&e.__esModule?e:{default:e};async function r(e){let r=this.async();this.cacheable&&this.cacheable();let o=await (0,t.transformAsync)(e,{plugins:[[n.default,{bundler:"webpack5"}]]});r(null,o?.code||void 0,o?.map||void 0)}function o(e){return r.bind(this,e)}const i=r;
|
package/lib/loader/solid.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type TransformOptions
|
|
1
|
+
import { transformAsync, type TransformOptions } from '@moneko/eslint/babel-core';
|
|
2
2
|
import BabelPluginSolidRefresh from 'solid-refresh/babel';
|
|
3
3
|
import type { LoaderContext } from 'webpack';
|
|
4
4
|
declare async function solidLoader(this: LoaderContext<TransformOptions & {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{existsSync as t,readFileSync as e}from"node:fs";import{basename as s,resolve as i}from"node:path";import o from"webpack";export class HtmlPlugin{constructor(t={}){this.AddEntry=/(?:.*\/)?main\.[a-zA-Z0-9]+\.bundle\.js$/,this.faviconPath="",this.name="HtmlPlugin",this.cachedMetaTags=null,this.cachedCustomTags=null,this.options={title:"WebApp",filename:"index.html",inject:"head",...t}}apply(n){n.hooks.compilation.tap(this.name,a=>{a.hooks.processAssets.tap({name:this.name,stage:o.Compilation.PROCESS_ASSETS_STAGE_ADDITIONAL},()=>{let h;if(this.options.favicon){let h=i(n.context,this.options.favicon);if(t(h)){let t=s(this.options.favicon),i=e(h);a.emitAsset(t,new o.sources.RawSource(i),{javascriptModule:!1}),this.faviconPath=(a.outputOptions.publicPath||"")+t}else a.warnings.push(new o.WebpackError(`Favicon file ${h} does not exist`))}if(h=this.options.templateContent?this.options.templateContent(this.options):this.options.template?e(i(n.context,this.options.template),{encoding:"utf-8"}):this.generateDefaultTemplate(),this.options.inject){let t=this.getAssets(a);h=this.injectAssets(h,t,this.options.inject)}let r="function"==typeof this.options.filename?this.options.filename("index"):this.options.filename||"index.html";a.emitAsset(r,new o.sources.RawSource(h),{javascriptModule:!1})})})}generateDefaultTemplate(){let t=this.generateMetaTags()
|
|
1
|
+
import{existsSync as t,readFileSync as e}from"node:fs";import{basename as s,resolve as i}from"node:path";import o from"webpack";export class HtmlPlugin{constructor(t={}){this.AddEntry=/(?:.*\/)?main\.[a-zA-Z0-9]+\.bundle\.js$/,this.faviconPath="",this.name="HtmlPlugin",this.cachedMetaTags=null,this.cachedCustomTags=null,this.options={title:"WebApp",filename:"index.html",inject:"head",...t}}apply(n){n.hooks.compilation.tap(this.name,a=>{a.hooks.processAssets.tap({name:this.name,stage:o.Compilation.PROCESS_ASSETS_STAGE_ADDITIONAL},()=>{let h;if(this.options.favicon){let h=i(n.context,this.options.favicon);if(t(h)){let t=s(this.options.favicon),i=e(h);a.emitAsset(t,new o.sources.RawSource(i),{javascriptModule:!1}),this.faviconPath=(a.outputOptions.publicPath||"")+t}else a.warnings.push(new o.WebpackError(`Favicon file ${h} does not exist`))}if(h=this.options.templateContent?this.options.templateContent(this.options):this.options.template?e(i(n.context,this.options.template),{encoding:"utf-8"}):this.generateDefaultTemplate(),this.options.inject){let t=this.getAssets(a);h=this.injectAssets(h,t,this.options.inject)}let r="function"==typeof this.options.filename?this.options.filename("index"):this.options.filename||"index.html";a.emitAsset(r,new o.sources.RawSource(h),{javascriptModule:!1})})})}generateDefaultTemplate(){let t=this.generateMetaTags();return`<!DOCTYPE html><html><head><meta charset="utf-8">${t}<title>${this.options.title}</title><link rel="icon" type="image/x-icon" href="${this.faviconPath}"></head><body><div id="root"></div></body></html>`}generateMetaTags(){if(null!==this.cachedMetaTags)return this.cachedMetaTags;if(!this.options.meta)return this.cachedMetaTags="","";let t=Object.entries(this.options.meta).map(([t,e])=>{if("string"==typeof e)return`<meta name="${t}" content="${e}">`;if(void 0===e)return"";let s=Object.entries(e).map(([t,e])=>`${t}="${e}"`).join(" ");return`<meta ${s}>`}).join("");return this.cachedMetaTags=t,t}generateCustomTags(){if(null!==this.cachedCustomTags)return this.cachedCustomTags;let t={head:"",body:""};if(!this.options.tags)return this.cachedCustomTags=t,t;let e=[],s=[];return this.options.tags.forEach(t=>{let{tag:i="script",textContent:o="",inject:n=this.options.inject,...a}=t,h=Object.entries(a).filter(([,t])=>null!=t).map(([t,e])=>!0===e?t:`${t}="${e}"`).join(" "),r=`<${i} ${h}>${o}</${i}>`;"head"===n?e.push(r):s.push(r)}),t.head=e.join(""),t.body=s.join(""),this.cachedCustomTags=t,t}getAssets(t){let e={js:[],css:[]},s=t.outputOptions.publicPath||"";for(let i of t.entrypoints.values())for(let t of i.chunks)for(let i of t.files)i.endsWith(".js")?e.js.push(s+i):i.endsWith(".css")&&e.css.push(s+i);return e}injectAssets(t,e,s){let i=e.css.length?e.css.map(t=>`<link href="${t}" rel="stylesheet" />`).join(""):"",o=e.js.length?e.js.map(t=>`<script defer ${this.AddEntry.test(t)?'entry="true" ':""}src="${t}"></script>`).join(""):"",n=this.generateCustomTags(),a=t.split("</head>");if(2===a.length){let[t,e]=a,h=e.split("</body>");return"head"===s?`${t}${i}${o}${n.head}</head>${h[0]}${n.body}</body>${h[1]||""}`:`${t}${n.head}</head>${h[0]}${i}${o}${n.body}</body>${h[1]||""}`}return t}}
|
package/lib/vm/render-app.mjs
CHANGED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { parentPort } from 'node:worker_threads';
|
|
2
|
+
import { transform } from '@moneko/eslint/babel-core';
|
|
3
|
+
import { BabelPluginReactCompiler } from '@moneko/eslint/react-compiler';
|
|
4
|
+
import log from '../commom/log.mjs';
|
|
5
|
+
export interface ReactCompilerOption {
|
|
6
|
+
target?: '17' | '18' | '19';
|
|
7
|
+
sources?(filename: string): boolean;
|
|
8
|
+
compilationMode?: 'annotation' | 'infer' | 'syntax' | 'all';
|
|
9
|
+
logger?: {
|
|
10
|
+
logEvent?: (fileName: string, event: MessageEvent) => void;
|
|
11
|
+
};
|
|
12
|
+
noEmit?: boolean;
|
|
13
|
+
flowSuppressions?: boolean;
|
|
14
|
+
ignoreUseNoForget?: boolean;
|
|
15
|
+
enableReanimatedCheck?: boolean;
|
|
16
|
+
panicThreshold?: string;
|
|
17
|
+
environment?: unknown;
|
|
18
|
+
gating?: null;
|
|
19
|
+
eslintSuppressionRules?: Record<string, string | boolean | number>;
|
|
20
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{parentPort as e}from"node:worker_threads";import{transform as o}from"@moneko/eslint/babel-core";import{BabelPluginReactCompiler as r}from"@moneko/eslint/react-compiler";import s from"../commom/log.mjs";e?.on("message",async({sourceCode:m,resourcePath:l,...n})=>{o(m,{sourceFileName:l,filename:l,sourceMaps:!1,plugins:[[r,n]],cloneInputAst:!1,ast:!1,configFile:!1,babelrc:!1},(o,r)=>{if(o){s(o),e?.postMessage([o,m]);return}if(null===r){e?.postMessage([Error(`Failed to transform "${l}"`),m]);return}e?.postMessage([null,r.code||"",null===r.map?void 0:r.map])})});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moneko/core",
|
|
3
|
-
"version": "3.43.
|
|
3
|
+
"version": "3.43.3",
|
|
4
4
|
"description": "core",
|
|
5
5
|
"main": "lib/index.mjs",
|
|
6
6
|
"type": "module",
|
|
@@ -129,7 +129,7 @@
|
|
|
129
129
|
"style-loader": "4.0.0",
|
|
130
130
|
"swc-loader": "0.2.6",
|
|
131
131
|
"typescript": "5.8.3",
|
|
132
|
-
"webpack": "5.99.
|
|
132
|
+
"webpack": "5.99.6",
|
|
133
133
|
"webpack-hot-middleware": "2.26.1",
|
|
134
134
|
"webpack-merge": "6.0.1",
|
|
135
135
|
"webpack-virtual-modules": "0.6.2"
|
|
@@ -140,7 +140,7 @@
|
|
|
140
140
|
"@types/stylis": "4.2.7",
|
|
141
141
|
"@types/webpack-bundle-analyzer": "4.7.0",
|
|
142
142
|
"@types/webpack-hot-middleware": "2.25.9",
|
|
143
|
-
"sass": "1.
|
|
143
|
+
"sass": "1.87.0",
|
|
144
144
|
"sass-loader": "16.0.5",
|
|
145
145
|
"solid-refresh": "0.7.5",
|
|
146
146
|
"stylis": "4.3.6",
|
package/typings/global.d.ts
CHANGED
|
@@ -514,6 +514,13 @@ export declare type ConfigType = {
|
|
|
514
514
|
*/
|
|
515
515
|
minify?: CssInJsMinifyOption | false;
|
|
516
516
|
};
|
|
517
|
+
/**
|
|
518
|
+
* 最小 Chunk 尺寸
|
|
519
|
+
* @default 1000
|
|
520
|
+
* @description `1000` 打包体积大,速度快;
|
|
521
|
+
* @description `512000` 打包体积小,速度更慢;
|
|
522
|
+
*/
|
|
523
|
+
minChunkSize?: number;
|
|
517
524
|
};
|
|
518
525
|
|
|
519
526
|
/**
|