Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changeset/tiny-parrots-relate.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---

---
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
"@tsconfig/node20": "^20.1.5",
"@tsconfig/strictest": "^2.0.5",
"@types/node": "^22.15.18",
"@vitest/coverage-v8": "^3.1.3",
"@vitest/coverage-v8": "^3.1.4",
"@vitest/eslint-plugin": "^1.2.0",
"@vitest/ui": "^3.1.3",
"@vitest/ui": "^3.1.4",
"cspell": "^9.0.1",
"dprint": "^0.50.0",
"eslint": "^9.27.0",
Expand All @@ -45,7 +45,7 @@
"turbo": "^2.5.3",
"typescript": "^5.8.3",
"typescript-eslint": "^8.32.1",
"vitest": "^3.1.3"
"vitest": "^3.1.4"
},
"packageManager": "[email protected]",
"engines": {
Expand Down
6 changes: 3 additions & 3 deletions packages/react/runtime/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@
"@lynx-js/react-transform": "workspace:*",
"@types/react": "^18.3.21",
"@vitejs/plugin-react": "4.4.1",
"@vitest/coverage-v8": "^3.1.3",
"@vitest/ui": "^3.1.3",
"@vitest/coverage-v8": "^3.1.4",
"@vitest/ui": "^3.1.4",
"esbuild": "^0.25.4",
"pretty-format": "^29.7.0",
"vitest": "^3.1.3"
"vitest": "^3.1.4"
},
"peerDependencies": {
"@types/react": "^18.0.0"
Expand Down
23 changes: 23 additions & 0 deletions packages/react/transform/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,33 @@ export interface DarkModeConfig {
*/
themeExpr: string
}
/**
* {@inheritdoc CompatVisitorConfig.addComponentElement}
* @public
*/
export interface AddComponentElementConfig {
/**
* @public
* Whether to only add component element during compilation
*
* @example
*
* Note that this only take effects on `Component` imported from {@link CompatVisitorConfig.oldRuntimePkg}.
*
* ```js
* import { defineConfig } from '@lynx-js/rspeedy'
* import { pluginReactLynx } from '@lynx-js/react-rsbuild-plugin'
*
* export default defineConfig({
* plugins: [
* pluginReactLynx({
* compat: {
* addComponentElement: { compilerOnly: true }
* },
* })
* ],
* })
* ```
*/
compilerOnly: boolean
}
Expand Down
21 changes: 21 additions & 0 deletions packages/react/transform/src/swc_plugin_compat/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,32 @@ pub struct DarkModeConfig {
pub theme_expr: String,
}

/// {@inheritdoc CompatVisitorConfig.addComponentElement}
/// @public
#[napi(object)]
#[derive(Clone, Debug)]
pub struct AddComponentElementConfig {
/// @public
/// Whether to only add component element during compilation
///
/// @example
///
/// Note that this only take effects on `Component` imported from {@link CompatVisitorConfig.oldRuntimePkg}.
///
/// ```js
/// import { defineConfig } from '@lynx-js/rspeedy'
/// import { pluginReactLynx } from '@lynx-js/react-rsbuild-plugin'
///
/// export default defineConfig({
/// plugins: [
/// pluginReactLynx({
/// compat: {
/// addComponentElement: { compilerOnly: true }
/// },
/// })
/// ],
/// })
/// ```
pub compiler_only: bool,
}

Expand Down
2 changes: 1 addition & 1 deletion packages/rspeedy/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
"type-fest": "^4.41.0",
"typia": "9.3.0",
"typia-rspack-plugin": "2.0.1",
"vitest": "^3.1.3",
"vitest": "^3.1.4",
"webpack": "^5.99.8"
},
"peerDependencies": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"@lynx-js/rspeedy": "workspace:*",
"@testing-library/jest-dom": "^6.6.3",
"jsdom": "^26.1.0",
"vitest": "^3.1.3"
"vitest": "^3.1.4"
},
"engines": {
"node": ">=18"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"@types/react": "^18.3.21",
"jsdom": "^26.1.0",
"typescript": "~5.8.3",
"vitest": "^3.1.3"
"vitest": "^3.1.4"
},
"engines": {
"node": ">=18"
Expand Down
3 changes: 3 additions & 0 deletions packages/rspeedy/plugin-react/api-extractor.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,7 @@
*/
{
"extends": "../../../api-extractor.json",
"bundledPackages": [
"@lynx-js/react-transform",
],
}
50 changes: 44 additions & 6 deletions packages/rspeedy/plugin-react/etc/react-rsbuild-plugin.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,45 @@

```ts

import type { CompatVisitorConfig } from '@lynx-js/react/transform';
import type { DefineDceVisitorConfig } from '@lynx-js/react/transform';
import type { ExtractStrConfig } from '@lynx-js/react-webpack-plugin';
import type { JsxTransformerConfig } from '@lynx-js/react/transform';
import { LAYERS } from '@lynx-js/react-webpack-plugin';
import type { RsbuildPlugin } from '@rsbuild/core';
import type { ShakeVisitorConfig } from '@lynx-js/react/transform';

// @public
export interface AddComponentElementConfig {
compilerOnly: boolean
}

// @public
export interface CompatVisitorConfig {
addComponentElement: boolean | AddComponentElementConfig
additionalComponentAttributes: Array<string>
componentsPkg: Array<string>
// Warning: (ae-forgotten-export) The symbol "DarkModeConfig" needs to be exported by the entry point index.d.ts
//
// @deprecated (undocumented)
darkMode?: boolean | DarkModeConfig
disableDeprecatedWarning: boolean
newRuntimePkg: string
oldRuntimePkg: Array<string>
// @deprecated
removeComponentAttrRegex?: string
// @deprecated
simplifyCtorLikeReactLynx2: boolean
// @internal (undocumented)
target: 'LEPUS' | 'JS' | 'MIXED'
}

// @public
export interface DefineDceVisitorConfig {
define: Record<string, string>
}

// @public
export interface ExtractStrConfig {
// @internal (undocumented)
extractedStrArr?: Array<string>
strLength: number
}

export { LAYERS }

Expand Down Expand Up @@ -40,12 +72,18 @@ export interface PluginReactLynxOptions {
experimental_isLazyBundle?: boolean;
extractStr?: Partial<ExtractStrConfig> | boolean;
firstScreenSyncTiming?: 'immediately' | 'jsReady';
jsx?: Partial<JsxTransformerConfig> | undefined;
pipelineSchedulerConfig?: number;
removeDescendantSelectorScope?: boolean;
shake?: Partial<ShakeVisitorConfig> | undefined;
// @deprecated
targetSdkVersion?: string;
}

// @public
export interface ShakeVisitorConfig {
pkgName: Array<string>
removeCallParams: Array<string>
retainProp: Array<string>
}

```
1 change: 1 addition & 0 deletions packages/rspeedy/plugin-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
},
"devDependencies": {
"@lynx-js/react": "workspace:*",
"@lynx-js/react-transform": "workspace:*",
"@lynx-js/rspeedy": "workspace:*",
"@lynx-js/vitest-setup": "workspace:*",
"@microsoft/api-extractor": "catalog:",
Expand Down
7 changes: 6 additions & 1 deletion packages/rspeedy/plugin-react/rslib.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { TypiaRspackPlugin } from 'typia-rspack-plugin'

export default defineConfig({
lib: [
{ format: 'esm', syntax: 'es2022', dts: true },
{ format: 'esm', syntax: 'es2022', dts: { bundle: true } },
],
source: {
entry: {
Expand All @@ -14,6 +14,11 @@ export default defineConfig({
},
tsconfigPath: './tsconfig.build.json',
},
output: {
externals: [
'@rsbuild/core',
],
},
tools: {
rspack: {
plugins: [
Expand Down
8 changes: 8 additions & 0 deletions packages/rspeedy/plugin-react/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,12 @@
export { pluginReactLynx } from './pluginReactLynx.js'
export type { PluginReactLynxOptions } from './pluginReactLynx.js'

export type {
AddComponentElementConfig,
CompatVisitorConfig,
DefineDceVisitorConfig,
ExtractStrConfig,
ShakeVisitorConfig,
} from '@lynx-js/react-transform'

export { LAYERS } from '@lynx-js/react-webpack-plugin'
6 changes: 4 additions & 2 deletions packages/rspeedy/plugin-react/src/pluginReactLynx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ import type { RsbuildPlugin } from '@rsbuild/core'
import type {
CompatVisitorConfig,
DefineDceVisitorConfig,
ExtractStrConfig,
JsxTransformerConfig,
ShakeVisitorConfig,
} from '@lynx-js/react/transform'
import type { ExtractStrConfig } from '@lynx-js/react-webpack-plugin'
} from '@lynx-js/react-transform'
import type { ExposedAPI } from '@lynx-js/rspeedy'

import { applyAlias } from './alias.js'
Expand Down Expand Up @@ -238,6 +238,8 @@ export interface PluginReactLynxOptions {

/**
* The `jsx` option controls how JSX is transformed.
*
* @internal
*/
jsx?: Partial<JsxTransformerConfig> | undefined

Expand Down
2 changes: 1 addition & 1 deletion packages/tools/vitest-setup/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"types": "index.ts",
"devDependencies": {
"path-serializer": "^0.4.0",
"vitest": "^3.1.3",
"vitest": "^3.1.4",
"webpack": "^5.99.8"
},
"engines": {
Expand Down
2 changes: 1 addition & 1 deletion packages/web-platform/web-rsbuild-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"@types/loader-utils": "^2.0.6",
"@types/webpack": "^5.28.5",
"typescript": "^5.8.3",
"vitest": "^3.1.3"
"vitest": "^3.1.4"
},
"peerDependencies": {
"@lynx-js/web-core": ">0.13.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,11 @@
import type { CompatVisitorConfig } from '@lynx-js/react/transform';
import type { Compiler } from '@rspack/core';
import type { DefineDceVisitorConfig } from '@lynx-js/react/transform';
import { ExtractStrConfig } from '@lynx-js/react/transform';
import type { JsxTransformerConfig } from '@lynx-js/react/transform';
import type { ShakeVisitorConfig } from '@lynx-js/react/transform';

// @public
export interface ExtractStrConfig {
strLength: number;
}
export { ExtractStrConfig }

// Warning: (ae-missing-release-tag) "LAYERS" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
Expand Down
18 changes: 1 addition & 17 deletions packages/webpack/react-webpack-plugin/src/ReactWebpackPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { createRequire } from 'node:module';
import type { Chunk, Compilation, Compiler } from '@rspack/core';
import invariant from 'tiny-invariant';

import type { ExtractStrConfig } from '@lynx-js/react/transform';
import { LynxTemplatePlugin } from '@lynx-js/template-webpack-plugin';
import { RuntimeGlobals } from '@lynx-js/webpack-runtime-globals';

Expand All @@ -16,23 +17,6 @@ import { createLynxProcessEvalResultRuntimeModule } from './LynxProcessEvalResul

const require = createRequire(import.meta.url);

/**
* The options for extractStr.
*
* @public
*/
export interface ExtractStrConfig {
/**
* The minimum length of string literals to be extracted.
*
* @defaultValue `20`
*
* @public
*/
strLength: number;
/** @internal */
extractedStrArr?: string[];
}
/**
* The options for ReactWebpackPlugin
*
Expand Down
6 changes: 2 additions & 4 deletions packages/webpack/react-webpack-plugin/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,8 @@
*/

export { ReactWebpackPlugin } from './ReactWebpackPlugin.js';
export type {
ReactWebpackPluginOptions,
ExtractStrConfig,
} from './ReactWebpackPlugin.js';
export type { ReactWebpackPluginOptions } from './ReactWebpackPlugin.js';
export type { ExtractStrConfig } from '@lynx-js/react/transform';

export { LAYERS } from './layer.js';

Expand Down
Loading