feat(core): support decorators version 2023-11#7394
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces support for the 2023-11 decorator version, aligning with the November 2023 Stage 3 proposal. The implementation includes updates to the SWC and Babel plugins, type definitions, and documentation in both English and Chinese. Additionally, the @swc/helpers dependency has been upgraded to version 0.5.20, and comprehensive E2E and unit tests have been added. Review feedback identified minor typos in the reference URLs within the documentation that should be corrected to avoid unnecessary redirects.
Deploying rsbuild with
|
| Latest commit: |
8d1ffbd
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://6d25c047.rsbuild-v2.pages.dev |
| Branch Preview URL: | https://codex-feat-decorators-2023-1.rsbuild-v2.pages.dev |
There was a problem hiding this comment.
Pull request overview
Adds a new source.decorators.version: '2023-11' option to Rsbuild, updates SWC/Babel snapshots and E2E coverage, and documents the new option in both English and Chinese docs.
Changes:
- Extend
Decorators.versiontype and document'2023-11'in EN/ZH docs. - Update SWC decorator config wiring and add unit/E2E tests + snapshots for
'2023-11'. - Bump
@swc/helpersand refreshpnpm-lock.yamlsnapshots.
Reviewed changes
Copilot reviewed 12 out of 13 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| website/docs/zh/guide/basic/typescript.mdx | Mentions '2023-11' as an available decorators version. |
| website/docs/zh/config/source/decorators.mdx | Documents '2023-11' in the decorators config reference (ZH). |
| website/docs/en/guide/basic/typescript.mdx | Mentions '2023-11' as an available decorators version. |
| website/docs/en/config/source/decorators.mdx | Documents '2023-11' in the decorators config reference (EN). |
| pnpm-lock.yaml | Lockfile updates reflecting dependency graph changes (incl. @swc/helpers). |
| packages/plugin-babel/tests/index.test.ts | Adds a snapshot test ensuring Babel is configured for decorators version: '2023-11'. |
| packages/plugin-babel/tests/snapshots/index.test.ts.snap | Snapshot update for Babel decorators '2023-11'. |
| packages/core/tests/swc.test.ts | Adds a snapshot test for SWC config when using decorators '2023-11'. |
| packages/core/tests/snapshots/swc.test.ts.snap | Snapshot update for SWC decorators '2023-11'. |
| packages/core/src/types/config.ts | Extends Decorators.version union to include '2023-11'. |
| packages/core/src/plugins/swc.ts | Updates SWC decorator config application logic for '2023-11'. |
| packages/core/package.json | Bumps @swc/helpers to ^0.5.20. |
| e2e/cases/syntax-es/decorator-config/index.test.ts | Adds E2E cases for '2023-11' (with and without Babel plugin). |
Files not reviewed (1)
- pnpm-lock.yaml: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| case '2022-03': | ||
| case '2023-11': | ||
| swcConfig.jsc.transform.legacyDecorator = false; | ||
| swcConfig.jsc.transform.decoratorVersion = '2022-03'; | ||
| // TODO `@swc/types` does not include `2023-11` yet. | ||
| (swcConfig.jsc.transform.decoratorVersion as string) = version; |
There was a problem hiding this comment.
builtin:swc-loader/SWC does not currently implement a working transform for decoratorVersion: '2023-11' (it can crash when that code path is hit). Setting swcConfig.jsc.transform.decoratorVersion to the user-provided '2023-11' risks breaking builds at runtime.
Suggestion: avoid passing '2023-11' into SWC until it’s supported. Either (a) throw a clear error when source.decorators.version === '2023-11' and SWC is the active transformer, recommending using the Babel plugin for 2023-11, or (b) map '2023-11' to '2022-03' for SWC and warn that semantics may differ.
Summary
This PR adds support for the
2023-11decorators version in Rsbuild core, keeps Babel and SWC snapshots aligned with the new config, and updates the English and Chinese docs to document the option.Related Links