Have problem when npm run build-prod
Closed this issue · 18 comments
Hi, it's okay with it in development mode but have ERROR in prod mode:
ERROR in Unexpected value 'DateTimePickerDirective in .../node_modules/ng2-eonasdan-datetimepicker/dist/datetimepicker.directive.d.ts' declared by the module 'AppModule in .../src/app/app.module.ts'
can you help me with it?
Maybe related to AOT compiling and loading, what is the result if you run the ng build without aot?
ng build --prod --aot=false
With such command its okay, it works and build correctly, but i have command "npm run build-prod" in deployment, how can i use this with deploying?
Also errors still exist wit "ng --prod" command.
this means, that the module is not AOT compatible. This is something the module owner could fix.
You can do a ng build --prod --aot=false and not have AOT in your production build. The normal ng build --prod command has default AOT set to true, that is why you get the errors.
If you want AOT you could remove this module from your application and consider http://valor-software.com/ngx-bootstrap/#/datepicker
What this module lacks for AOT support?
I can't use the ngx-bootstrap datepicker because i need the date and time picker in one window, so thats why i decide to use this picker.
Ok then maybe make the changes in de module and create a PR for the owner
@egnashko If you need this AOT change fast I would be really glad to accept the PR 👍
@iturn do you have any experience if the changes you mentioned (to adapt to AOT) may break the build with JIT?
Sorry, i dont know about that. But from what i read it should not.
Also i read the first answer here, it might be very easy to provide AOT support.
https://stackoverflow.com/questions/38932193/angular-2-ahead-of-time-compilation-how-to
@iturn so as i understand if i want to built my project with AOT it's better to use other date-time-picker?
@atais i am sorry, i am new in code =) and don't know what "PR" means. What it means?
The code i using:
app.module.ts (uses DateTimePickerDirective cose without it have error that "A2Edatetimepicker is not ngModule")
...
import { DateTimePickerDirective } from 'ng2-eonasdan-datetimepicker/dist/datetimepicker.directive';
...
declarations: [
DateTimePickerDirective
]
main.ts
import 'eonasdan-bootstrap-datetimepicker';
angular.cli
styles: [
"../node_modules/eonasdan-bootstrap-datetimepicker/build/css/bootstrap-datetimepicker.min.css"
]
component html
<div class="input-group">
<input class="form-control"
type="text"
placeholder="From"
[(ngModel)]="filter.from"
a2e-datetimepicker
[date]="filter.from"
(onChange)="dateChangeFrom($event)"
/>
<span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span></span>
</div>
component.ts
private a2eOptions = {format: 'MM/DD/YYYY hh:mm A'};
dateChangeFrom(date) {
this.filter.from = date.format(this.a2eOptions.format);
}
dateChangeTo(date) {
this.filter.to = date.format(this.a2eOptions.format);
}
@egnashko If you are not able to fix this library you may either use other library or turn of AOT. At least until I fix it or somebody else does.
Currently, I am busy with other projects so I can't promise this fix in the nearest future.