rolldown: [Bug]: passes TypeScript experimental decorators as-is

Reproduction link or steps

  1. Open https://stackblitz.com/edit/github-6jajke-stx58g?file=rolldown.config.mjs
  2. npm run build runs automatically.
  3. The output contains experimental decorators as-is.

What is expected?

Either

  • Throw an error that says “experimental decorators are not supported yet”
  • Read the tsconfig and transform experimental decorators to valid JS if enabled

What is actually happening?

Experimental decorators are passes as-is even if it’s not a valid JS.

System Info

Stackblitz

  System:
    OS: Linux 5.0 undefined
    CPU: (8) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Memory: 0 Bytes / 0 Bytes
    Shell: 1.0 - /bin/jsh
  Binaries:
    Node: 18.20.3 - /usr/local/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 10.2.3 - /usr/local/bin/npm
    pnpm: 8.15.6 - /usr/local/bin/pnpm
  npmPackages:
    rolldown: https://pkg.pr.new/rolldown@351d2c7 => 0.13.2

Any additional comments?

Faced this while trying rolldown with Vite.

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 4
  • Comments: 35 (13 by maintainers)

Commits related to this issue

Most upvoted comments

Can you share which version and the example config? I still haven’t got it to work but we use TypeDI. Shouldn’t make a difference tho ):

I got the version from the stackblitz example. rolldown: 1.0.0-beta.3-commit.1910872

It seems to not be active without rolldown resolving the tsconfig file. "experimentalDecorators": true, probably activates the transform. So you need to add this to your rolldown.config.ts:

export default defineConfig({
  resolve: {
    tsconfigFilename: 'tsconfig.json',
  }
});

and also tsconfig.json (you probably already have this)

{
	"compilerOptions": {
		"experimentalDecorators": true,
		"emitDecoratorMetadata": true,
	}
}

You will probably also need @oxc-project/runtime. I got warnings that rolldown could not resolve those modules. It will then externalize these modules and not bundle the needed helpers, so you might need to add this dependency as well.

That’s awesome to hear. I think this is the last blocker for us to try out rolldown without SWC. Is there an issue or PR I can subscribe?

https://github.com/oxc-project/oxc/pull/9057

Yeah, we are waiting oxc to support this

the oxc has already finished experimental decorator transformation, try next nightly.

@IWANABETHATGUY @sapphi-red @yyx990803 @any updates? 😞

oxc team is focus on lowering to es6, so maybe they don’t have enough bandwidth to support this for now.

For more advanced projects the decorators are the basic feature to use so I think that should be part of the v1 of the rolldown 😞

Yeah, we will discuss the priority after oxc team finishes es6 target lowering.

@IWANABETHATGUY do we have any kind of EOT for this issue?

oxc team did not have enough bandwidth to work on this, they may start working this task after finish es2015 target lowering.