Does turbopack support the newer @decorators syntax? #81438
-
SummaryHi, I'm trying to use turbopack with a legacy project that uses mobx + decorators. Mobx supports "2022.3/Stage 3" decorators which does not require the tsconfig "experimentalDecorators" flag. However, when I run my project I get a compilation error, the reason given being:
It points to the following file, which contains a common pattern in my code base:
I can't find any documentation on turbopack on if this is supported and I cannot remove accessor as it's required by mobx. The only thing I can see as a potential route is to use a babel-loader with turbopack, but again can't find much documentation on that. Any pointers are greatly appreciated. Thanks. Additional informationNo response ExampleNo response |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
|
Turbopack currently has limited support for the newest @decorators syntax, especially the newer Stage 3 decorators proposal that includes things like accessor. The error message you’re seeing: indicates that Turbopack’s Rust-based compiler does not yet support this accessor decorator syntax. What you need to know: experimentalDecorators flag in tsconfig is not relevant to Turbopack’s internal parser, since it uses SWC or its own Rust parser. Currently, Turbopack does not support Babel loaders/plugins directly, so using babel-loader as a fallback isn’t straightforward. Workarounds: Stick to next dev or Webpack-based builds for now if you need Stage 3 decorator support, as those use Babel which has better support. Track Turbopack’s GitHub repo and roadmap for upcoming support for these newer decorator features. Alternatively, you might try to precompile the problematic files with Babel or tsc before Turbopack handles them, but this adds complexity. Summary |
Beta Was this translation helpful? Give feedback.
Turbopack currently has limited support for the newest @decorators syntax, especially the newer Stage 3 decorators proposal that includes things like accessor. The error message you’re seeing:
indicates that Turbopack’s Rust-based compiler does not yet support this accessor decorator syntax.
What you need to know:
Turbopack is still evolving, and while it supports a wide range of TypeScript and JavaScript features, some newer or more experimental syntax, like Stage 3 decorators with accessor, are not fully implemented yet.
experimentalDecorators flag in tsconfig is not relevant to Turbopack’s internal parser, since it uses SWC or it…