jelgblad / angular2-masonry

https://github.com/desandro/masonry module for Angular2
101 stars 48 forks source link

Failing to build for production #56

Open fpinela8 opened 7 years ago

fpinela8 commented 7 years ago

I am using this in my Angular 4 application and everything seems to be working ok so far. It works perfectly fine with a dev build, but as soon as I try to build it for production (with AOT) i get the error below:

> tcd@1.0.0 build:prod /home/fabio/workspace/tcd
> del-cli public/js/app && ngc -p tsconfig.aot.json && ngc -p tsconfig.aot.json && webpack --config webpack.config.prod.js --progress --profile --bail && del-cli 'public/js/app/**/*.js' 'public/js/app/**/*.js.map' '!public/js/app/bundle.js' '!public/js/app/*.chunk.js' 'assets/app/**/*.ngfactory.ts' 'assets/app/**/*.shim.ts' 'assets/app/**/*.ngsummary.json' 'assets/app/**/*.ngstyle.ts'
Unexpected value 'MasonryModule in /home/fabio/workspace/tcd/node_modules/angular2-masonry/index.d.ts' imported by the module 'AppModule in /home/fabio/workspace/tcd/assets/app/app.module.ts'. Please add a @NgModule annotation.

Any ideas why is it failing only when i build it for production?

EDIT: What is causing the error is AOT compilation, i.e., ngc -p tsconfig.aot.json && ngc -p tsconfig.aot.json

Below my successful dev build:

npm run build

> tcd@1.0.0 build /home/fabio/workspace/tcd
> del-cli public/js/app && webpack --config webpack.config.dev.js --progress --profile --watch

  0% compiling
Webpack is watching the files…

 10% building modules 0/1 modules 1 active ...ce/tcd/assets/app/main.ts
[at-loader] Using typescript@2.4.2 from typescript and "tsconfig.json" from /home/fabio/workspace/tcd/tsconfig.json.

10598ms building modules                                                                 
48ms sealing
5ms optimizing 
0ms basic module optimization 
10ms module optimization
1ms advanced module optimization 
0ms basic chunk optimization 
0ms chunk optimization 
1ms advanced chunk optimization 
5ms module and chunk tree optimization 
17ms module reviving
3ms module order optimization 
6ms module id optimization 
5ms chunk reviving 
0ms chunk order optimization 
22ms chunk id optimization
57ms hashing
1ms module assets processing 
663ms chunk assets processing
4ms additional chunk assets processing 
0ms recording 
0ms additional asset processing 
0ms chunk asset optimization 
807ms asset optimization
174ms emitting
Hash: 362e24432280d758943f
Version: webpack 2.7.0
Time: 12490ms
    Asset   Size  Chunks                    Chunk Names
bundle.js  11 MB       0  [emitted]  [big]  app
fpinela8 commented 7 years ago

I can't explain why, but after migrating my project to use angular-cli everything works fine with angular 4 and AOT.