@moneko/core 4.10.0 → 4.10.1

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.
@@ -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";Object.defineProperty(exports,"__esModule",{value:!0});var e=exports,t={get custom(){return c},get default(){return d}};for(var r in t)Object.defineProperty(e,r,{enumerable:!0,get:Object.getOwnPropertyDescriptor(t,r).get});let s=require("node:path"),i=require("node:worker_threads"),o=require("../process-env.mjs"),n=new i.Worker((0,s.join)(__dirname,"../worker/react-compiler.mjs"));function a(e,t){(this._compiler?.options.mode!=="development"||o.isBuild)&&this._compiler?.hooks.done.tap("react-compiler-loader",()=>{n.terminate()});let r=this.resourcePath,s=this.getOptions();if(r.endsWith(".d.ts")||r.endsWith(".json")||!("annotation"===s.compilationMode?e.includes("use memo")||e.includes("use forget"):e.includes("react")||r.endsWith(".tsx")||r.endsWith(".jsx")))return e;let i=this.async();this.cacheable&&this.cacheable(),n.postMessage({sourceCode:e,filename:r,inputSourceMap:t,options:s}),n.addListener("message",function e(t){r===t[0]&&(i(t[1],t[2],t[3]),n.removeListener("message",e))})}function c(e,t){return a.bind(this,e,t)}n.setMaxListeners(0);let d=a;
1
+ "use strict";
@@ -1,27 +1,83 @@
1
- import type { TransformOptions } from '@moneko/eslint/babel-core';
2
- import type { PluginOptions } from '@moneko/eslint/react-compiler';
3
- import type { LoaderContext } from 'webpack';
4
- export interface ReactCompilerOption extends Partial<PluginOptions> {
5
- /**
6
- * 指定 React 的主要版本
7
- * @description
8
- * ReactCompiler 与 React 19+ 配合使用效果最佳;
9
- *
10
- * 将 ReactCompiler 与 React 17、18 一起使用需要安装额外的 `react-compiler-runtime` 依赖项;
11
- */ target: '17' | '18' | '19';
12
- /** 编译模式
13
- * @description annotation 注释模式: 通过 "use memo""use no memo" 手动指定启用优化
14
- * @example
15
- * export default function Home() {
16
- * 'use memo';
17
- * // ...
18
- * }
19
- * export default function About() {
20
- * 'use no memo';
21
- * // ...
22
- * }
23
- */ compilationMode: 'annotation' | 'infer' | 'syntax' | 'all';
24
- }
25
- declare function reactCompilerLoader(this: LoaderContext<ReactCompilerOption>, sourceCode: string, inputSourceMap?: TransformOptions['inputSourceMap']): string | Buffer | void;
26
- export declare function custom(this: LoaderContext<ReactCompilerOption>, sourceCode: string, inputSourceMap?: TransformOptions['inputSourceMap']): typeof reactCompilerLoader;
27
- export default reactCompilerLoader;
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 1718 一起使用需要安装额外的 `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 { };
@@ -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||{}},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
+ 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));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moneko/core",
3
- "version": "4.10.0",
3
+ "version": "4.10.1",
4
4
  "description": "@moneko/core",
5
5
  "main": "lib/index.mjs",
6
6
  "type": "module",
@@ -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 | ReactCompilerOption;
500
+ reactCompiler?: false | ReactCompilerOptions;
502
501
  /** stylelint 配置
503
502
  * @description 为 false 时关闭
504
503
  */