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

When installed redundantly, Metadata could be erased #45

Closed
crierr opened this issue Sep 27, 2016 · 2 comments
Closed

When installed redundantly, Metadata could be erased #45

crierr opened this issue Sep 27, 2016 · 2 comments

Comments

@crierr
Copy link

crierr commented Sep 27, 2016

If multiple node modules have dependencies on 'reflect-metadata' and modules are installed redundantly, metadata is erased after later require('reflect-metadata') is invoked.

Assume that using module Foo and Bar, they're using reflect-metadata
npm package tree looks like below
|─ Foo
| └ reflect-metadata@0.1.8
|─ Bar
└ reflect-metadata@0.1.8

One of my own decorators save something by invoking Reflect.defineMetadata() and another module imports Bar module, so another reflect-metadata module is initialized.
On initialization, reflect-metadata patches its own functions to global Reflect object.
On second initialization, it may overwrite functions, but internal Metadata object will be lost.

I've avoided this problem by specifying same semver version in package.json. latest npm (ver>=3) does not install redundantly.
|─ Foo
| └ reflect-metadata@0.1.8
|─ Bar

But for the case modules should use different versions or one of them is maintained by others,
it would be great to copy internal Metadata values

@rbuckton
Copy link
Owner

rbuckton commented Feb 21, 2017

Unfortunately, even if I address this in a later release it is possible an earlier release would still overwrite the members if it is loaded after the earlier later release.

@rbuckton
Copy link
Owner

Fixed in 69f4359

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants