Skip to content
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

Add support for ember-cli addon proxy (bundle caching) #941

Merged
merged 1 commit into from
Aug 26, 2021

Conversation

eoneill
Copy link
Contributor

@eoneill eoneill commented Aug 25, 2021

As of ember-cli@3.28, addon instances may be proxied (see ember-cli/ember-cli#9487). This can become a problem when patching (setting/restoring) methods on the addon instance or comparing with the addon __proto__.

There was an initial workaround for setting/restoring the preprocessJs method (see ember-cli/ember-cli#9562). This has proven to be unsustainable as other similar issues were uncovered.

For example, when an addon is proxied, this comparison will always be true:

(this.addonInstance.__proto__ && this.addonInstance[treeName] !== this.addonInstance.__proto__[treeName])

... as the methods on the __proto__ are the original method, while on the (proxied) addon are proxy methods. This particular scenario manifests in empty addon trees for proxied addons.

The fix here is to get a reference to the real addon whenever patching methods or comparing to the __proto__.
A similar solution was implemented in ember-engines (see ember-engines/ember-engines#769).

@rwjblue rwjblue added the enhancement New feature or request label Aug 26, 2021
@rwjblue rwjblue changed the title add support for ember-cli addon proxy (bundle caching) Add support for ember-cli addon proxy (bundle caching) Aug 26, 2021
@rwjblue rwjblue merged commit 56391d8 into embroider-build:master Aug 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants