tvcutsem / harmony-reflect

ES5 shim for ES6 Reflect and Proxy objects
http://www.ecma-international.org/ecma-262/6.0/#sec-reflection
Other
478 stars 48 forks source link

Conflict with `reflect-metadata` #79

Closed sanex3339 closed 6 years ago

sanex3339 commented 6 years ago

Hi. This package is using in different packages and plugins, for example here: https://github.com/evilebottnawi/favicons (plugin https://github.com/jantimon/favicons-webpack-plugin)

When favicons-webpack-plugin plugin was loaded alongside with my plugin which using reflect-metadata - my plugin stopped working because of different API between harmony-reflect and reflect-metadata.

So, can you fix this from your side?

tvcutsem commented 6 years ago

Hi,

Did you find any workaround for your issue?

Currently the harmony-reflect module will always override the Reflect global. I could test if the Reflect global exists and if so, override or add methods on the existing Reflect global rather than replacing it. Do you think that would solve your issue?

sanex3339 commented 6 years ago

I think that add methods (without overriding if possible) - best option.

tvcutsem commented 6 years ago

If I don't override the pre-existing methods then this library will not work anymore. This library implements a shim for Proxy objects. The patched Reflect methods need to recognize the shimmed Proxy objects generated by this library.

I'm unfamiliar with reflect-metadata, but at first glance, it seems it defines a different set of methods on its Reflect object. If that is the case, there won't be a conflict.

tvcutsem commented 6 years ago

Can you try upgrading to v1.6.0 (just released) and see if this solves your problem?

Relevant commit: https://github.com/tvcutsem/harmony-reflect/commit/a79500fcd9af84948974d71e9dc04fbc48251fb6

sanex3339 commented 6 years ago

It working now, thank you!

tvcutsem commented 6 years ago

glad to hear it works!