Class member has empty decorators array #9025
Replies: 8 comments
-
If I remember correctly, this is currently expected behavior. There are few pre-transform passes before running plugin transform such as typescript strip and decorators for the performance & few other reasons. |
Beta Was this translation helpful? Give feedback.
-
Not going to say expected behavior === will do nothing, but also we had some prior discussions regarding those prepass transforms and found it wasn't super ideal to pass everything into plugin. |
Beta Was this translation helpful? Give feedback.
-
Right. The question is what should I do? Write custom transform? Stripe? Without this transformation we cannot use Rspack and swc |
Beta Was this translation helpful? Give feedback.
-
Unfortunate to say as of today, the only way I can think of is having custom transformation and create a swc binary instead of using prepublished one. As you said, that'll defeat to use any other packages like rspack. Other than those, I do not have an immediate suggestion. Adding additional transform phase in plugin transform might need some proof if it won't hurt any other generic plugin transforms. |
Beta Was this translation helpful? Give feedback.
-
That’s bad information for us :( |
Beta Was this translation helpful? Give feedback.
-
That's more no-go given we skipped some transform for the performance reasons. |
Beta Was this translation helpful? Give feedback.
-
This could be nice feature for SWC. There are tones of plugins for babel typescript that can be rewrites as SWC transformer. Do you have some docs how should we build and use custom binary of SWC? |
Beta Was this translation helpful? Give feedback.
-
You may check how swc builds itself. https://github.com/swc-project/swc/tree/main/bindings/binding_core_node
I do not want derail this thread for those topics, there are huge lengthy discussions around plugin architectures and there's no way 1:1 babel - swc transformer conversion anyway. I'm moving this to discussion, since this is not an actual bug but more of feature request now. |
Beta Was this translation helpful? Give feedback.
-
Describe the bug
We are working on moving into Rspack . To make that happen we have to rewrite our custom TypeScript transformer (AST) into SWC plugin. The plugin for reproductions is available here
What is the problem?
The problem is that class member has as empty array of decorators even if they exists (see example)
In the SWC Playground decorators also exists in as an filled array.
But inside of our code the decorators array is empty:
The problem is that all tests are working properly and transforms class property decorator into new value but the example code does not.
How to reproduce?
We've been created an reproduction repository.
The example code is available in
example
directory. To run the test you have to install all required packages then runbuild
command:What is the expected output?
We are trying to make plugin that will add into
Prop
decorator the annotation type e.g.Before:
After:
Input code
Config
Playground link (or link to the minimal reproduction)
https://play.swc.rs/?version=1.5.24&code=H4sIAAAAAAAAAx2MMQqEQAxF%2B5wiWGmz9toIXsBiL5DVCAPjZMhklwWZuxv91Yf%2F%2FgtHFjU8F5VccVc5sHn1G6%2BiZKKlv4dmBOD%2FA2680zcarpFKwTcXm8UViZNLANAz3Ze2e3rW8CNjNAcH%2FIhEpuS2ChePRyj4eQAAAA%3D%3D&config=H4sIAAAAAAAAA2WPSw7CMAxE9z1F5TULYIEEd%2BAQUepWQc1HtisRVb17kzYNIHbxvHjGMzdtCy%2FW8Gjn9ExDUMRIdU4KRyfqnRSQGJA1mSBwOqhwRr0aGavWofakxBMnJDThBpadgygaULIf8vV8uRcvGL1n%2FPUCa5zp4%2Fc12ttAyPwXapUbxrq%2FJzYlFazvpg2WlrnJfsENPp%2BOsGoMhp%2FH5tZjWQEa0ouIMQEAAA%3D%3D
SWC Info output
Expected behavior
The
decorators
arrays are filled.Actual behavior
No response
Version
latest
Additional context
No response
Beta Was this translation helpful? Give feedback.
All reactions