-
Notifications
You must be signed in to change notification settings - Fork 319
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
lit decorators doesnt work with babel legacy mode decorators #205
Comments
i prepared a pull request to support the babel decorators |
Related #174 Decorators don't work in Babel7, I think they work in Babel6 |
Do you have a link to the PR? |
I started investigating how this could work in Babel 7 with the latest decorators proposal. I'll post back here if I have time to work on it more, but this inspired me to make this comment on the proposal repo which might be of interest: |
I figured out a working implementation of the
|
@mbrowne I had the same problem with my library, I wrote all my decorators according to the stage2 API and for legacy and babel compatibility I created a small helper to use the stage2 decorators also in legacy mode (https://github.com/mzeiher/ce-decorators/blob/master/src/stage2/stage2decorators.ts) the decorators probe if a stage2 or legacy is expected and apply either the native s2, or transform the request to a s2 compatible one (don't know if it works on all edge cases, it works for me at the moment with TS decorators (also patched Reflect.decorate to let TS apply multiple decorators (https://github.com/mzeiher/ce-decorators/blob/master/src/reflect.ts)) Babel legacy and Babel-stage2. maybe you can include this logic into lit-element? Or create maybe I can publish the helper as a separate library... |
Is this also why I'm currently seeing (in latest release) that my use of |
@ernsheong Yep |
Dup of #156 |
Re-opening as we've had a couple more requests. I'm not sure when we can get to this though, so contributions welcome. |
From #921
Sometime ago, i did some tests with possible decorator setups (babel6, babel7/legacy babel7/spec, typescript): https://github.com/blikblum/lit-element-decorator-tests You can look at compiled files like https://github.com/blikblum/lit-element-decorator-tests/blob/master/babel7/dist/main-legacy.js#L2258 At the time i come to the conclusion that is not possible to use property decorator with babel/legacy and that typescript was working by accident (it is/was setting the property instead of defining it) |
How to reproduce with a project on github pwa-webpack-starter-kit. If you run the project using |
Struggling with this in a project that uses NX where I can't override { decoratorsBeforeExport: true } in the babel config built into their build system. I've opened a ticket but if there are other paths to resolution I'd appreciate any help, I was stumped on why the property changes weren't updating the updating the view for a long time. |
Looks like TC39 has come up with yet another decorators proposal, and recommends sticking with legacy decorators for now. The new proposal seems less powerful than either of the other two. Hopefully it will still support everything lit is using decorators for. |
Closing due to age. We're waiting for spec progress before making additional changes to decorators support. |
babel decorators (in legacy mode) expect the property descriptor to be returned rather than be defined within the decorator, TS also supports this feature.
Steps to Reproduce
checkout https://github.com/mzeiher/lit-element-test
npm install
npm run build
open index.html
Expected Results
both elements are updated (one decorated with TS the other with babel decorators in legacy mode)
Actual Results
only the TS version works
Browsers Affected
Versions
The text was updated successfully, but these errors were encountered: