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.
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
- fix(transformer/legacy-decorator): metadata incorrectly wrapped by decorateParam (#9490) close: https://github.com/rolldown/rolldown/issues/3728#issuecomment-2693097569 Before, we need to make sure ... — committed to oxc-project/oxc by Dunqing 2 years ago
- fix(transformer/legacy-decorator): incorrect check for potentially non-existent ident (#9491) close: https://github.com/rolldown/rolldown/issues/3728 — committed to oxc-project/oxc by Dunqing 2 years ago
https://github.com/rolldown/rolldown/pull/3780, you may be able to use it in the next rolldown @nightly
This is because https://babeljs.io/docs/babel-plugin-transform-typescript#onlyremovetypeimports, was set to
falseby default(which rolldown doesn’t modify), I thinkunpluginmay modify some values inoxc-transform. I will try to expose these options to js side, so that you can customize yourself.Fixed in https://github.com/oxc-project/oxc/pull/9491 and https://github.com/oxc-project/oxc/pull/9490
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" nottypeof BBBBB === “undefined”`.