rolldown: [Bug]: Metadata is not fully decorated

Reproduction link or steps

https://stackblitz.com/edit/github-n16h8yyc

Run npm i and npm run start to get the dist files.

What is expected?

Metadata should be fully decorated.

What is actually happening?

Rolldown does not decorate the metadata.

Image

As you can see, Rolldown is missing the design metadata on the classes.

OXC does not have the design:type, the design:paramtype check is different, and the _define_property inside constructor is missing when compared to the SWC output either (that might be a separate issue though).

System Info

System:
    OS: macOS 15.3.1
    CPU: (12) arm64 Apple M2 Pro
    Memory: 1.64 GB / 32.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 22.14.0 - ~/.proto/shims/node
    Yarn: 4.6.0 - ~/.proto/shims/yarn
    npm: 10.9.2 - ~/.proto/shims/npm
    pnpm: 10.4.1 - ~/.proto/shims/pnpm
    bun: 1.2.2 - ~/.proto/shims/bun
  Browsers:
    Chrome: 133.0.6943.142
    Edge: 133.0.3065.92
    Safari: 18.3
  npmPackages:
    rolldown: latest => 1.0.0-beta.3-commit.3337767

Any additional comments?

Maybe I am not setting things up properly, but I tried using the newest packages, so let me know if I misconfigured something.

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 20 (7 by maintainers)

Commits related to this issue

Most upvoted comments

@IWANABETHATGUY that would be great, thank you!

https://github.com/rolldown/rolldown/pull/3780, you may be able to use it in the next rolldown @nightly

My question is why does Rolldown create a different result, compared to Rolldown with unplugin-oxc/rolldown.

They both use OXC transform under the hood, right? So is something not being passed the same way?

This is because https://babeljs.io/docs/babel-plugin-transform-typescript#onlyremovetypeimports, was set to false by default(which rolldown doesn’t modify), I think unplugin may modify some values in oxc-transform . I will try to expose these options to js side, so that you can customize yourself.

These bugs are caused by incorrect OXC transformation. I am going to fix them soon.

I found another bug is should be __decorateMetadata("design:type", Function)), not __decorateParam(0, __decorateMetadata("design:type", Function)),

Ok, I see, let me have a look.

As I replied in Discord, OXC metadata emitter implementation is ported from TypeScript, not SWC. See the TypeScript’s playground, we are almost the same. But I found there is a bug indeed, should be typeof BBBBB !== "undefined" not typeof BBBBB === “undefined”`.