Ravenstine / ember-custom-elements

The easiest way to render parts of your Ember app using custom elements.
MIT License
15 stars 4 forks source link

Implement support for use in add-ons #10

Closed Ravenstine closed 4 years ago

Ravenstine commented 4 years ago

The customElement decorator was failing to work when used in add-ons that were using it. This PR makes it possible to use the decorator on entities inside an add-on.

It was failing to work for add-ons because the Babel transform used to support module evaluation was not being applied to add-ons, and the initializer was not written to check dependencies of modules under app/. Both of these issues are intended to be resolved in this PR.

EDIT: It also fixes a failure in the add-on to work properly in production builds. That problem was occurring because of a few factors, the main being that bare strings and such are stripped out in production, and a bug in one of the functions used to detect whether a module is supported by the decorator. Ultimately, I chose to ditch the Babel plugin approach in favor of checking whether this add-on is a dependency of a module and then checking the code to see if the decorator function is called.

Closes: #6 #9