-
Notifications
You must be signed in to change notification settings - Fork 4
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
Getting TypeError: Reflect.getMetadata is not a function #9
Comments
I have found why webpack works, we take |
could we make |
I think we can make that happen. Yeah, we don't even have it listed as a peer.. Before I make a decision how to do this, let me look at our other builds.. we have a few packages that use reflect-metadata, and I want to take a peek at your setup too :) What are you trying to do with rollup? |
Thanks Derek, our webpack config is specifying
We are trying to improve our build time and overhead with Rollup, because moving to webpack 4 is quite painful |
So I made a fork and embedded the code, I had to change the build process because Gulp was only adding However I have been facing another issue which is not so easily solved. And after spending quite some time on it, I am curious if you might have some guidance to understand what's happening. I see these errors in the console:
This is a stack trace:
This is one of the calling code in the bundle:
right above it are the class definitions:
So I am quite confused by the error message (which I saw is custom). I tried to follow through what's happening, but I didn't really see anything wrong.
What it looks like to me is that we are trying to read an object that's not ready yet, but that's all I can make of it. With a webpack build, the code looks similar (although ES5). And this is not related with this issue, and I don't necessarily think it is a general issue with Thanks |
Hey, sorry I wasn't able to get back to you yesterday. Yeah, your fork is looking good! The rollup build is something i've had on my todo list for a little bit, but haven't been able to sit down and do it. So thank you!!! Go ahead and make a PR, and we can work on the other things that need to happen with the build (like outputting the typescript def). As for that error, yes, it is exactly what you describe. It will usually occur when you have code like this:
class1 will have it's decorators processed first, before class2 is seen. Moving So I would have to see more of your code to see why that is happening, since it looks like it is setup correctly. This is awesome! Thank you!! |
yeah that's how it's defined in the src code:
To be noted that this is the example I gave, but all I will try with a simpler case to see |
So I made a basic repro: https://github.com/lemoustachiste/fw-model-rollup |
alright cool! i'll check it out and see whats up |
I see what's going on! We do rely on some compiler options with typescript: so if you change your rollup config to be:
that will go away |
Thanks Derek, That's great info, and indeed I fixed the issue in the repro. However it still remains in my actual build. So now I'm exploring other things, like conflicts with the rest of the build (we are using Aurelia, so there might be weird things happening with it). Anyway, it put me back on the trail so thanks for that. I'll keep you posted if I (hopefully) get somewhere |
I'm trying to build with Rollup, as I run the build code, it fails on this:
it looks like
getMetadata
is not part of the native definition ofReflect
: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect and could be found here: https://www.npmjs.com/package/reflect-metadataBut it does not seem to be a dependency of this project, however, our build with Webpack does not fail?
cc @raiseandfall
The text was updated successfully, but these errors were encountered: