Fix SWC decorator parsing to support TS5 stage-3 decorators - #94274
Fix SWC decorator parsing to support TS5 stage-3 decorators#94274arab971 wants to merge 1 commit into
Conversation
…8360) SWC rejected @decorator syntax at the parser level for TypeScript files unless experimentalDecorators was set in tsconfig. This made TS5 stage-3 decorators impossible even when the transform was correctly configured. - Always enable decorator parsing for .ts/.tsx files in SWC parser options - Use decoratorVersion "2022-03" (stage-3) when experimentalDecorators is not set, matching Turbopack's DecoratorsKind::Ecma behavior - Gate emitDecoratorMetadata on experimentalDecorators being enabled - Add integration test for TS5 decorators in production build
|
@kdy1 I completely understand why that looks off—it looks like a date! However, |
|
Please do not ping me |
What happened here? Why is this PR closed without reviewing? Why cannot contributers ping reviewers? TS 7 has already been RC version, Next.js hasn't fully supported TS 5 ?! Support custom SWC configuration just like Babel, or merge this PR please! |
|
@TechQuery Thank you for your support. I apologize for closing the PR; I was feeling frustrated by the response from the reviewer, as well as the general lack of feedback and reviews over such a long period. I truly appreciate you bringing this to my attention. |
You're welcome, Next.js mainteners are the people who should be blamed. I had similar situation in fixing the broken Vercel serverless template: vercel/examples#835 I think, maybe Vercel is humanless now. If I'm not too busy in the future, I will finish my SSR framework based on Web components standard & fully customable SWC compiler: EasyWebApp/WebSSR#1 |
|
@eps1lon — this PR fixes TS5/TS7 stage-3 decorator support in SWC builds. kdy1 confirmed the SWC convention is correct. Can you take a look? |
|
Any update here? This is the one thing in my project forcing me to use babel...TS5 decorators are awesome but the extra 30+ seconds or so it adds to my Vercel builds is unfortunate. That's with pro enhanced builds too. |
Same to me before. Now I patch every Next.js project to enable SWC manually for speeding up: idea2app/Next-Bootstrap-ts@1b3a5a8 And today, I must update this patch again for 16.3... |
|
@TechQuery So what i can do here nextjs maintainer's only accept and merge PRs of those peoples how already have access of review and write code means to say PRs that consists of any logic and issue solution it's author should also have access to write and review code access this is only case when a PR can be merge otherwise this is not opensource contribution this is only get response back from users and improve your product and dont look at what other peoples are wanted to solve or other stuff |
I have no idea about this... Maybe we should post a Twitter? |
What?
Fix SWC decorator parsing to support TS5 stage-3 decorators. Currently, SWC rejects
@decoratorsyntax at the parser level for TypeScript files unlessexperimentalDecoratorsis set in tsconfig, making TS5 stage-3 decorators impossible.Why?
TypeScript 5 introduced stage-3 decorators as the default (no flag needed). Next.js users adopting TS5 decorators hit a parse error (
Unexpected token '@') because SWC's parser only enabled decorator syntax whenexperimentalDecorators: truewas set. This is the #1 blocker reported in #48360.How?
swc/options.ts): Always enable decorator parsing for.ts/.tsxfiles, regardless ofexperimentalDecoratorsswc/options.ts): UsedecoratorVersion: "2022-03"(stage-3 Ecma proposal) whenexperimentalDecoratorsis not set, matching Turbopack'sDecoratorsKind::Ecmabehaviorwebpack-config.ts): Setdecorators: trueunconditionally; gateemitDecoratorMetadataonexperimentalDecorators(metadata is a legacy-only feature)Fixes #48360
Test plan
test/production/ts5-decorators/— builds a page using TS5 decorators and verifies it renderspnpm test-start-webpack test/production/ts5-decorators/index.test.tspassesManual verification with issue reproduction app