rbuckton / reflect-metadata

Prototype for a Metadata Reflection API for ECMAScript
https://rbuckton.github.io/reflect-metadata
Apache License 2.0
3.21k stars 184 forks source link

Reflect-Metadata doesn't work with WebPack 3 Scope Hoisting #77

Open CmdrShepardsPie opened 7 years ago

CmdrShepardsPie commented 7 years ago

I tried reporting this to the WebPack team and they said it is a problem with Reflect-Metadata.

I'm using Reflect-Metadata in a TypeScript project that's being built and bundled with WebPack 3. When I add the scope hoisting plugin to my WebPack config, the project no longer runs properly.

I get the following error: Uncaught TypeError: Reflect.hasOwnMetadata is not a function at injectable.js:7 at Object.decorate [as a] (tslib.es6.js:48) at Object../client/app/app.bootstrap.ts (data.service.ts:4) at webpack_require (bootstrap 1856459e76a82a034076:54) at webpackJsonpCallback (bootstrap 1856459e76a82a034076:25) at app.js:1 (anonymous) @ injectable.js:7 decorate @ tslib.es6.js:48 ./client/app/app.bootstrap.ts @ data.service.ts:4 __webpack_require__ @ bootstrap 1856459e76a82a034076:54 webpackJsonpCallback @ bootstrap 1856459e76a82a034076:25 (anonymous) @ app.js:1

Is there a way to make it work, or can this problem be fixed?

danzel commented 6 years ago

Seems totally busted in webpack 4. In my limited debugging it looks like reflect-metadata is not getting included in the resulting bundle at all.

Edit: Or maybe it is? I tried to use webpack shims, but that didn't get it going either, I may have been using it wrong however.

Edit2: I think I was doing something wrong, I re-did the update on our app and things are fine 🤔