@moneko/core 4.10.0 → 4.10.2-beta.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/bin/utils/setup-swcrc.mjs +1 -1
- package/lib/index.d.mts +0 -1
- package/lib/loader/react-compiler.cjs +1 -1
- package/lib/loader/react-compiler.d.cts +83 -27
- package/lib/options/swcrc.mjs +1 -1
- package/lib/utils/fetch-module-federation-dts.mjs +1 -1
- package/package.json +5 -5
- package/typings/global.d.ts +2 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
import{swcImportOnDemandConfig as e}from"../../commom/transfer-import-on-demand.mjs";import o from"../../options/reslove.mjs";import{cwd as r}from"./config.mjs";export async function getSwcOption(){let{CONFIG:t}=await import("../../config.mjs");return{module:{type:"es6"},minify:!0,jsc:{minify:{format:{comments:!1},ecma:2015,compress:{drop_console:!0,drop_debugger:!0,global_defs:{"@alert":"console.log"},pure_funcs:["console.log","console.warn","console.error","console.info"],ecma:2015,toplevel:!1,module:!1,ie8:!1,keep_classnames:void 0,keep_fnames:!1,top_retain:[],keep_infinity:!0},mangle:!0},parser:{syntax:"typescript",decorators:!0,dynamicImport:!0,tsx:!0},loose:!0,target:"es2022",transform:{legacyDecorator:!0,decoratorMetadata:!0,react:{runtime:"automatic",throwIfNamespace:!0,useBuiltins:!0,refresh:!1,development:!1}},experimental:{plugins:[[o.rawImport,{rootDir:r}],[o.transformImports,e(t.importOnDemand||{})]].filter(Boolean)}},sourceMaps:!0,exclude:["__tests__/","examples/","\\.d\\.ts$"]}}
|
|
1
|
+
import{swcImportOnDemandConfig as e}from"../../commom/transfer-import-on-demand.mjs";import o from"../../options/reslove.mjs";import{cwd as r}from"./config.mjs";export async function getSwcOption(){let{CONFIG:t}=await import("../../config.mjs");return{module:{type:"es6"},minify:!0,jsc:{minify:{format:{comments:!1},ecma:2015,compress:{drop_console:!0,drop_debugger:!0,global_defs:{"@alert":"console.log"},pure_funcs:["console.log","console.warn","console.error","console.info"],ecma:2015,toplevel:!1,module:!1,ie8:!1,keep_classnames:void 0,keep_fnames:!1,top_retain:[],keep_infinity:!0},mangle:!0},parser:{syntax:"typescript",decorators:!0,dynamicImport:!0,tsx:!0},loose:!0,target:"es2022",transform:{legacyDecorator:!0,decoratorMetadata:!0,react:{runtime:"automatic",throwIfNamespace:!0,useBuiltins:!0,refresh:!1,development:!1},reactCompiler:t.reactCompiler&&{panicThreshold:"none",..."object"==typeof t.reactCompiler?t.reactCompiler:{}}},experimental:{plugins:[[o.rawImport,{rootDir:r}],[o.transformImports,e(t.importOnDemand||{})]].filter(Boolean)}},sourceMaps:!0,exclude:["__tests__/","examples/","\\.d\\.ts$"]}}
|
package/lib/index.d.mts
CHANGED
|
@@ -15,7 +15,6 @@ export * as Rule from './commom/rule.mjs';
|
|
|
15
15
|
export { default as timer } from './commom/timer.mjs';
|
|
16
16
|
export { type MockConfiguration, type ProxyFuncType, type RequestFormData, yApiMock, type YApiOption, type YApiOptionBySchema, yApiSchemaMock } from './dev/mock.mjs';
|
|
17
17
|
export { convertUriToFileName, type HarvesterGenerateParams, type HarvesterOptions, type ProxyConfig, type ProxyItem } from './dev/proxy.mjs';
|
|
18
|
-
export type { ReactCompilerOption } from './loader/react-compiler.cjs';
|
|
19
18
|
export * from './mcp/module-federation/common.mjs';
|
|
20
19
|
export { type JsxDomExpressions, default as jsxDomExpressions } from './options/jsx-dom-expressions.mjs';
|
|
21
20
|
export { type OptimizationSplitChunksOptions, default as splitChunk } from './options/split-chunk.mjs';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
@@ -1,27 +1,83 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import type {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
1
|
+
// import { join } from 'node:path';
|
|
2
|
+
// import { Worker } from 'node:worker_threads';
|
|
3
|
+
// import type { TransformOptions } from '@moneko/eslint/babel-core';
|
|
4
|
+
// import type { PluginOptions } from '@moneko/eslint/react-compiler';
|
|
5
|
+
// import type { LoaderContext } from 'webpack';
|
|
6
|
+
// import { isBuild } from '../process-env.mjs';
|
|
7
|
+
// export interface ReactCompilerOption extends Partial<PluginOptions> {
|
|
8
|
+
// /**
|
|
9
|
+
// * 指定 React 的主要版本
|
|
10
|
+
// * @description
|
|
11
|
+
// * ReactCompiler 与 React 19+ 配合使用效果最佳;
|
|
12
|
+
// *
|
|
13
|
+
// * 将 ReactCompiler 与 React 17、18 一起使用需要安装额外的 `react-compiler-runtime` 依赖项;
|
|
14
|
+
// */
|
|
15
|
+
// target: '17' | '18' | '19';
|
|
16
|
+
// /** 编译模式
|
|
17
|
+
// * @description annotation 注释模式: 通过 "use memo"、"use no memo" 手动指定启用优化
|
|
18
|
+
// * @example
|
|
19
|
+
// * export default function Home() {
|
|
20
|
+
// * 'use memo';
|
|
21
|
+
// * // ...
|
|
22
|
+
// * }
|
|
23
|
+
// * export default function About() {
|
|
24
|
+
// * 'use no memo';
|
|
25
|
+
// * // ...
|
|
26
|
+
// * }
|
|
27
|
+
// */
|
|
28
|
+
// compilationMode: 'annotation' | 'infer' | 'syntax' | 'all';
|
|
29
|
+
// }
|
|
30
|
+
// const worker = new Worker(join(__dirname, '../worker/react-compiler.mjs'));
|
|
31
|
+
// worker.setMaxListeners(0);
|
|
32
|
+
// function reactCompilerLoader(
|
|
33
|
+
// this: LoaderContext<ReactCompilerOption>,
|
|
34
|
+
// sourceCode: string,
|
|
35
|
+
// inputSourceMap?: TransformOptions['inputSourceMap'],
|
|
36
|
+
// ): string | Buffer | void {
|
|
37
|
+
// const isDev = this._compiler?.options.mode === 'development';
|
|
38
|
+
// if (!isDev || isBuild) {
|
|
39
|
+
// this._compiler?.hooks.done.tap('react-compiler-loader', () => {
|
|
40
|
+
// worker.terminate();
|
|
41
|
+
// });
|
|
42
|
+
// }
|
|
43
|
+
// const filename = this.resourcePath;
|
|
44
|
+
// const options = this.getOptions();
|
|
45
|
+
// let needRC: boolean;
|
|
46
|
+
// if (filename.endsWith('.d.ts') || filename.endsWith('.json')) {
|
|
47
|
+
// return sourceCode;
|
|
48
|
+
// }
|
|
49
|
+
// if (options.compilationMode === 'annotation') {
|
|
50
|
+
// needRC = sourceCode.includes('use memo') || sourceCode.includes('use forget');
|
|
51
|
+
// } else {
|
|
52
|
+
// needRC = sourceCode.includes('react') || filename.endsWith('.tsx') || filename.endsWith('.jsx');
|
|
53
|
+
// }
|
|
54
|
+
// if (!needRC) {
|
|
55
|
+
// return sourceCode;
|
|
56
|
+
// }
|
|
57
|
+
// const call = this.async();
|
|
58
|
+
// if (this.cacheable) {
|
|
59
|
+
// this.cacheable();
|
|
60
|
+
// }
|
|
61
|
+
// worker.postMessage({
|
|
62
|
+
// sourceCode,
|
|
63
|
+
// filename,
|
|
64
|
+
// inputSourceMap,
|
|
65
|
+
// options: options,
|
|
66
|
+
// });
|
|
67
|
+
// function callback(out: [filename: string, err: Error | null, code: string, map: string]) {
|
|
68
|
+
// if (filename === out[0]) {
|
|
69
|
+
// call(out[1], out[2], out[3]);
|
|
70
|
+
// worker.removeListener('message', callback);
|
|
71
|
+
// }
|
|
72
|
+
// }
|
|
73
|
+
// worker.addListener('message', callback);
|
|
74
|
+
// }
|
|
75
|
+
// export function custom(
|
|
76
|
+
// this: LoaderContext<ReactCompilerOption>,
|
|
77
|
+
// sourceCode: string,
|
|
78
|
+
// inputSourceMap?: TransformOptions['inputSourceMap'],
|
|
79
|
+
// ): typeof reactCompilerLoader {
|
|
80
|
+
// return reactCompilerLoader.bind(this, sourceCode, inputSourceMap);
|
|
81
|
+
// }
|
|
82
|
+
// export default reactCompilerLoader;
|
|
83
|
+
export { };
|
package/lib/options/swcrc.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{merge as e}from"webpack-merge";import r from"../commom/paths.mjs";import{swcImportOnDemandConfig as o}from"../commom/transfer-import-on-demand.mjs";import{CONFIG as t}from"../config.mjs";import m,{coreJsVersion as s}from"../polyfills/polyfills.mjs";import{isDev as p,isReact as a,jsxImportSource as i}from"../process-env.mjs";import c from"./reslove.mjs";let l={include:m(),mode:"entry",coreJs:s};export default((m,s={})=>e({module:{type:"es6",resolveFully:!0},sync:!0,jsc:{parser:{syntax:"typescript",tsx:a,decorators:!0,dynamicImport:!0},loose:!0,target:t.polyfill?void 0:"es2017",externalHelpers:!1,keepClassNames:!0,transform:{legacyDecorator:!0,decoratorMetadata:!0,react:{runtime:t.reactJsxRuntime||"automatic",throwIfNamespace:!0,refresh:a&&p,development:p,importSource:i},reactCompiler:{panicThreshold:p?void 0:"none",...t.reactCompiler
|
|
1
|
+
import{merge as e}from"webpack-merge";import r from"../commom/paths.mjs";import{swcImportOnDemandConfig as o}from"../commom/transfer-import-on-demand.mjs";import{CONFIG as t}from"../config.mjs";import m,{coreJsVersion as s}from"../polyfills/polyfills.mjs";import{isDev as p,isReact as a,jsxImportSource as i}from"../process-env.mjs";import c from"./reslove.mjs";let l={include:m(),mode:"entry",coreJs:s};export default((m,s={})=>e({module:{type:"es6",resolveFully:!0},sync:!0,jsc:{parser:{syntax:"typescript",tsx:a,decorators:!0,dynamicImport:!0},loose:!0,target:t.polyfill?void 0:"es2017",externalHelpers:!1,keepClassNames:!0,transform:{legacyDecorator:!0,decoratorMetadata:!0,react:{runtime:t.reactJsxRuntime||"automatic",throwIfNamespace:!0,refresh:a&&p,development:p,importSource:i},reactCompiler:t.reactCompiler&&{panicThreshold:p?void 0:"none",..."object"==typeof t.reactCompiler?t.reactCompiler:{}},optimizer:{simplify:!1}},experimental:{emitAssertForImportAttributes:!0,cacheRoot:r.swcCachePath,plugins:[!!(t.importOnDemand&&Object.keys(t.importOnDemand).length)&&[c.transformImports,o(t.importOnDemand)]].filter(Boolean)}},env:t.polyfill?l:void 0,sourceMaps:!0,parseMap:!0},"function"==typeof t.swcrc?t.swcrc(p):t.swcrc||{},s));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{updateFile as
|
|
1
|
+
import{updateFile as t}from"@moneko/utils";import e from"../commom/log.mjs";import r from"../commom/require.mjs";import{CACHE_NAME as o}from"../process-env.mjs";import{mf_vm as m}from"../vm/mf.mjs";import{extractMfModules as s}from"./dts.mjs";import{node_modules as p}from"./index.mjs";async function i(n,a,f=[]){try{let{request:e}=r("@moneko/request"),i=`${n.startsWith("//")?`http:${n}`:n}/module-federation.d.ts`,l=await e(i,{responseType:"text",rejectUnauthorized:!1});s(l).forEach(t=>{m.has(t)||m.setData(t,{type:".ts",source:()=>`export * from '${t}'`})}),t(p("@types",o,`${a}.d.ts`),function(t,e,r){let o=r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),m=e.filter(Boolean).map(t=>t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).sort((t,e)=>e.length-t.length);if(!m.length)return t;let s=RegExp(`(["'])${o}:(${m.join("|")})(?=/|["'])`,"g");return t.replace(s,(t,e,r)=>`${e}${r}`)}(l,f,`_${a}_`))}catch(t){e(t)}}export default i;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moneko/core",
|
|
3
|
-
"version": "4.10.0",
|
|
3
|
+
"version": "4.10.2-beta.0",
|
|
4
4
|
"description": "@moneko/core",
|
|
5
5
|
"main": "lib/index.mjs",
|
|
6
6
|
"type": "module",
|
|
@@ -130,7 +130,7 @@
|
|
|
130
130
|
"homepage": "https://moneko-o.github.io/neko-ui/@moneko/config",
|
|
131
131
|
"license": "MIT",
|
|
132
132
|
"dependencies": {
|
|
133
|
-
"@jsonjoy.com/fs-node": "4.
|
|
133
|
+
"@jsonjoy.com/fs-node": "4.66.1",
|
|
134
134
|
"@moneko/convert": "1.3.0",
|
|
135
135
|
"@moneko/eslint": "1.11.2",
|
|
136
136
|
"@moneko/mdx": "1.0.3",
|
|
@@ -139,17 +139,17 @@
|
|
|
139
139
|
"@moneko/stylelint": "1.8.3",
|
|
140
140
|
"@moneko/transform-imports": "1.5.0",
|
|
141
141
|
"@moneko/utils": "0.3.3",
|
|
142
|
-
"@swc/core": "1.15.
|
|
142
|
+
"@swc/core": "1.15.47",
|
|
143
143
|
"browserslist": "4.28.7",
|
|
144
144
|
"core-js": "3.49.0",
|
|
145
145
|
"core-js-compat": "3.49.0",
|
|
146
146
|
"husky": "9.1.7",
|
|
147
|
-
"less": "4.8.
|
|
147
|
+
"less": "4.8.1",
|
|
148
148
|
"less-loader": "12.3.3",
|
|
149
149
|
"lightningcss": "1.33.0",
|
|
150
150
|
"swc-loader": "0.2.7",
|
|
151
151
|
"typescript": "6.0.3",
|
|
152
|
-
"webpack": "5.109.
|
|
152
|
+
"webpack": "5.109.2",
|
|
153
153
|
"webpack-hot-middleware": "2.26.1",
|
|
154
154
|
"webpack-merge": "6.0.1"
|
|
155
155
|
},
|
package/typings/global.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { MdxOptions } from '@moneko/mdx';
|
|
2
|
-
import type { Config as SwcConfig, JsMinifyOptions as SwcMinifyOptions } from '@swc/core';
|
|
2
|
+
import type { Config as SwcConfig, JsMinifyOptions as SwcMinifyOptions, ReactCompilerOptions } from '@swc/core';
|
|
3
3
|
import type { PluginOptions as MiniCssExtractPluginOptions } from 'mini-css-extract-plugin';
|
|
4
4
|
import type { MinifyOptions as TerserMinifyOptions } from 'terser';
|
|
5
5
|
import type {
|
|
@@ -26,7 +26,6 @@ import type { ESLintOption } from '../lib/plugin/eslint.mjs';
|
|
|
26
26
|
import type { StylelintOption } from '../lib/plugin/stylelint.mjs';
|
|
27
27
|
import type { SwcImportOnDemandTransform } from '../lib/commom/transfer-import-on-demand.mjs';
|
|
28
28
|
import type { CssInJsMinifyOption } from '../lib/commom/css-in-js-minify.mjs';
|
|
29
|
-
import type { ReactCompilerOption } from '../lib/loader/react-compiler.cjs';
|
|
30
29
|
import type { CompressionPluginOptions } from '../lib/plugin/compression.mjs';
|
|
31
30
|
import type { JsxDomExpressions } from '../lib/options/jsx-dom-expressions.mjs';
|
|
32
31
|
import type { ProxyConfig } from '../lib/dev/proxy.mjs';
|
|
@@ -498,7 +497,7 @@ export declare type ConfigType = {
|
|
|
498
497
|
* @description 需要 react 17+
|
|
499
498
|
* @default false
|
|
500
499
|
*/
|
|
501
|
-
reactCompiler?: false |
|
|
500
|
+
reactCompiler?: false | ReactCompilerOptions;
|
|
502
501
|
/** stylelint 配置
|
|
503
502
|
* @description 为 false 时关闭
|
|
504
503
|
*/
|