ember-polyfills / ember-cached-decorator-polyfill

Polyfill for RFC 566: @cached
MIT License
20 stars 6 forks source link

fix: Allow the babel plugin to be registered for addons #85

Closed dcyriller closed 3 years ago

dcyriller commented 3 years ago

Description

This PR would fix the case when @cached is used in an addon.

When ember-cached-decorator-polyfill is used in an addon... Currently the babel polyfill is registered for the host app. So, adding the polyfill to the addon's package.json file doesn't allow the @cached transpilation to happen.

This PR would allow the babel plugin to be registered for the addon instead.

Links

If merged, this PR would make https://github.com/emberjs/data/pull/7599 possible. It would fix https://github.com/concordnow/ember-aria-tabs/pull/218. It might fix (I'm not sure) https://github.com/ember-polyfills/ember-cached-decorator-polyfill/pull/75#issuecomment-844912062.

void-mAlex commented 2 years ago

following this change I've started encountering https://github.com/ember-polyfills/ember-cached-decorator-polyfill/issues/97 can someone clarify if that is intended?

NullVoxPopuli commented 2 years ago

@void-mAlex I'm experiencing #97 as well.

void-mAlex commented 2 years ago

@NullVoxPopuli from the minimal digging I've done I think it might be a case where the app importing the addon has other dependencies that pull in older versions of 'ember-cli-babel' (and maybe related to https://github.com/ember-polyfills/ember-cached-decorator-polyfill/issues/81#issuecomment-850570452). sorry if this is ends up being red herring

NullVoxPopuli commented 2 years ago

hmm, that might be much harder to track down. we have a lot of deps

RobbieTheWagner commented 2 years ago

0.1.4 should have been a 0.2.0 or 1.0.0 as this was a breaking change for addon authors.

RobbieTheWagner commented 2 years ago

Does anyone have a fix for the TypeError: decorator is not a function error?

simonihmig commented 2 years ago

I read #97 as an issue, where the app is using @cached while it didn't have the polyfill as a direct dependency. If that is the case, then I think @dcyriller comment is correct.

0.1.4 should have been a 0.2.0 or 1.0.0 as this was a breaking change for addon authors.

Again, if the above is true, then I would disagree. If things break, then because people were accidentally relying on the buggy behavior before the latest release. But that's strictly speaking not a SemVer breaking change. (yes, I see that it can feel as such)

RobbieTheWagner commented 2 years ago

Even after removing ember-cached-decorator-polyfill from the addon and installing in our app, I get TypeError: decorator is not a function. I had to downgrade to 0.1.1.

knownasilya commented 2 years ago

I was able to get this working in ember-flow by moving it to dependencies (addon with 3.28 ember-cli-update)