ng2-pdf-viewer breaks the AOT build with Angular CLI 1.5.0

Created on 6 Nov 2017  路  1Comment  路  Source: VadimDez/ng2-pdf-viewer

Updated the Angular version to 5.0 in my existing project and it stopped working.
Just importing and adding PdfViewerComponent to declarations of an Angular 5 module leads to an error when compiling with Angular CLI 1.5 with --aot:

ERROR in TypeError: Cannot read property 'annotation' of null
    at CompileMetadataResolver.loadDirectiveMetadata (C:\Projects\Cat\turbo\turbo-ui\node_modules\@angular\compiler\bundles\compiler.umd.js:14787:109)
    at C:\Projects\Cat\turbo\turbo-ui\node_modules\@angular\compiler\bundles\compiler.umd.js:15073:54
    at Array.forEach (native)
    at CompileMetadataResolver.loadNgModuleDirectiveAndPipeMetadata (C:\Projects\Cat\turbo\turbo-ui\node_modules\@angular\compiler\bundles\compiler.umd.js:15072:41)
    at C:\Projects\Cat\turbo\turbo-ui\node_modules\@angular\compiler\bundles\compiler.umd.js:29416:69
    at Array.forEach (native)
    at C:\Projects\Cat\turbo\turbo-ui\node_modules\@angular\compiler\bundles\compiler.umd.js:29415:35
    at Array.forEach (native)
    at AotCompiler.loadFilesAsync (C:\Projects\Cat\turbo\turbo-ui\node_modules\@angular\compiler\bundles\compiler.umd.js:29414:15)
    at C:\Projects\Cat\turbo\turbo-ui\node_modules\@angular\compiler-cli\src\transformers\program.js:145:35
    at process._tickCallback (internal/process/next_tick.js:109:7)

Tested with 1.1.1 and 2.0.3.
Also there's an issue in Angular CLI repo.

And when you just import the PdfViewerComponent and don't add it to declarations, you get this error.

When I remove the import completely, the project gets compiled and works just fine.

bug

Most helpful comment

That was fast! Thanks @VadimDez, it works now in 3.0.0!
BTW if anyone else stumbles upon this and has a problem like mine, you now need to import PdfViewerModule (not the PdfViewerComponent) and add it to the imports array of your Angular module.

>All comments

That was fast! Thanks @VadimDez, it works now in 3.0.0!
BTW if anyone else stumbles upon this and has a problem like mine, you now need to import PdfViewerModule (not the PdfViewerComponent) and add it to the imports array of your Angular module.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

xmran picture xmran  路  4Comments

RahmatAliMalik5 picture RahmatAliMalik5  路  5Comments

roginneil picture roginneil  路  3Comments

fncamm picture fncamm  路  4Comments

UlricW picture UlricW  路  3Comments