github / catalyst

Catalyst is a set of patterns and techniques for developing components within a complex application.
https://github.github.io/catalyst/
MIT License
1.34k stars 50 forks source link

Decorators `@target` and `@targets` not work with babel #271

Closed onEXHovia closed 2 years ago

onEXHovia commented 2 years ago

At work with @babel/plugin-proposal-decorators, decorators @target and @targets returns undefined. Made small repository where reproduce error https://github.com/onEXHovia/catalyst-decorators

At a quick inspection, if you add return for methods https://github.com/github/catalyst/blob/main/src/target.ts the problem is solved, but not sure if it's correct solution

export function target<K extends string>(proto: Record<K, unknown>, key: K): void {
  meta(proto, 'target').add(key)
  return Object.defineProperty(proto, key, {
    configurable: true,
    get() {
      return findTarget(this, key)
    }
  })
}
.....
.....
keithamus commented 2 years ago

@onEXHovia have you tried the 2.0 alpha? I believe this is resolved in 2.0

onEXHovia commented 2 years ago

@onEXHovia have you tried the 2.0 alpha? I believe this is resolved in 2.0

Now I tried it, everything works on version 2.0 alpha. How relevant is it now to start a project on version 2.0?

keithamus commented 2 years ago

2.0 alpha should be quite stable despite the name. We’re using it on some internal tools and it works fine, but we’ve not shipped it to github.com yet, as we have a lot of controllers that we’re slowly migrating to 2.0 attr syntax.

2.0-alpha1 is based off 1.4x. I’ll release 2.0-alpha2 to be based off of 1.6 in a few hours then maybe 1 or 2 more prerelease versions over the coming weeks as we get it into .com before it is released as 2.0 stable.

If you do use it and find any bugs, quirks, or behaviours which seem weird please file issues and we’ll be sure to resolve them!

athopen commented 1 year ago

Hey @keithamus 👋🏻

What is the status of the v2-version - is there a planned release-date? We would like to use catalyst in our project but have our own logic of defining our components so we cannot use the @controller syntax from v1. We would prefer to use the other decorators (actionable, targetable ...) from v2.

keithamus commented 1 year ago

Development has slowed for v2, mostly due to complexities of getting interoperable decorators across different compiler tool-chains. If you have your own logic for defining components, I'd encourage you to work greenfield on decorators that can support Stage 3 Decorators proper; this code is all MIT licensed so feel free to take parts you need!