-
Notifications
You must be signed in to change notification settings - Fork 12k
build --prod does not include metadata defined by decorator #5359
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
Comments
I don't think your example can ever work with AOT. You can still have production builds with it turned off via If you think AOT should support your case please open an issue on https://github.com/angular/angular instead. |
@filipesilva I agree, the example above is definitely not AOT-friendly. However, I would like to note that the title as is, "build --prod does not include metadata defined by decorator", very much is true, which is why I stumbled upon this issue, regardless of the above example. I've had a project with my own build process (non Angular CLI, using A couple weeks ago I wanted to prototype a new component in "isolation", i.e., only with the bare parts I would need from my main project's architecture, so I scaffolded a new project with Angular CLI (post v1.0.0) and simply copied the needed parts from my other application. As expected, I'm able to AOT build just fine using the CLI—no errors, but when I load the app in a browser environment, I tried a couple configurations by setting values to Wrapping up, none of these are issues in my main project which has been working with AOT just fine. It may be that these use cases are simply unsupported by Angular CLI, but just wanted to note it because it most definitely isn't an issue with Angular itself. |
@filipesilva FYI I got the same error |
@filipesilva when I try your example using CLI 6.2.7 I get the following error:
Is there an alternative? Thanks |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
OS?
MacOS Sierra
Versions.
@angular/cli: 1.0.0-rc.1
node: 7.6.0
os: darwin x64
@angular/cli: 1.0.0-rc.1
@angular/common: 2.4.9
@angular/compiler: 2.4.9
@angular/compiler-cli: 2.4.9
@angular/core: 2.4.9
@angular/forms: 2.4.9
@angular/http: 2.4.9
@angular/platform-browser: 2.4.9
@angular/platform-browser-dynamic: 2.4.9
@angular/router: 3.4.9
Repro steps.
I have a root component which will load a template from HTML and compile it dynamically.
The
DynamicHtmlModule
is not using decorator.Both
UtilityModule
andMemberModule
declares tones of components.Here is the problem, when I build it by
ng build
everything is fine. The app is running without error.The
UtilityModule
is built to beBut if I build it by
ng build --prod
, there will be an errorBy my understanding, it means my
UtilityModule
is not a valid module since it does not contain any metadata.Here is how it is built to be
It seems normal to me since
UtilityModule
is just an empty class with decorator. However, I cannot find any compiled code for its decorator. In fact, it seems that all decorators are missing including all components (there is not selector and template).Okay, let's get back to the root component
App
. My first error is not mentioned above. My first error is come from theDynamicHtmlModule
which originally I was using decorator to define metadata. But it rises similar error so I switch to the current way.This is how it is built to be now
The metadata is clear.
I found a guy on SO with similar problem http://stackoverflow.com/questions/42537138/angular2-cli-tree-shaking-removing-dynamically-created-ngmodule/42693400?noredirect=1#comment72521082_42693400
The text was updated successfully, but these errors were encountered: