angular2-masonry icon indicating copy to clipboard operation
angular2-masonry copied to clipboard

angular2-masonry won't compile under Angular 5

Open web-snake opened this issue 7 years ago • 9 comments

Angular 5 has stricter Typescript compilation configurations and will not compile: node_modules/angular2-masonry/index.ts The error is: ERROR in ./node_modules/angular2-masonry/index.ts Module build failed: Error: myapp/node_modules/angular2-masonry/index.ts is not part of the compilation output. Please check the other error messages for details.

This type script file is incorrectly packed in angular2-masonry according to the Angular team. You should not package uncompiled .ts files in packages because it can compile diffferently under different configs. Angular plans to make it even harder for you to use this bad practice in the future. YOur package is already broken for Angular 5. Here's an Angular team member saying this: https://github.com/angular/angular-cli/issues/8284 ( see filipesilva 's comment )

web-snake avatar Nov 20 '17 03:11 web-snake

Any work around for the time being?

khalid-halo avatar Nov 22 '17 23:11 khalid-halo

Temporary workaround is to bring the angular2-masonry into a sub-folder of your app. You can that include it as usual using:

import { MasonryModule } from './angular2-masonry';

JaronrH avatar Nov 24 '17 02:11 JaronrH

hello JaronrH if you import
like import { MasonryModule } from './angular2-masonry'; then ssr will not work

error come=>>>>>>>>>>>>>>> }( window, function factory( Outlayer, getSize ) { ^

ReferenceError: window is not defined


if you running project via ng serve it will work fine

rahulmodu avatar Nov 26 '17 18:11 rahulmodu

take a look https://github.com/Angular-RU/angular-universal-starter/blob/master/server.ts

Gorniv avatar Nov 30 '17 20:11 Gorniv

Another workaround is to temporarily add the package in the include array of your tsconfig.json. My full tsconfig.json is this:

{
  "compileOnSave": false,
  "compilerOptions": {
    "outDir": "./dist/out-tsc",
    "sourceMap": true,
    "declaration": false,
    "moduleResolution": "node",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "target": "es5",
    "typeRoots": [
      "node_modules/@types"
    ],
    "lib": [
      "es2017",
      "dom"
    ]
  },
  "include":[
    "node_modules/angular2-masonry",
    "src/**/*"
  ]
}

Note that by default there was no include present and I also had to add src/**/* into it to have full compilation of my project.

ElkeCodes avatar Dec 02 '17 16:12 ElkeCodes

I've forked this repository and updated it for Angular 5+ https://github.com/gethinoakes/ngx-masonry

Works fine for me. I'll try to work on it more when I have time.

gethinoakes avatar Dec 06 '17 12:12 gethinoakes

@gethinoakes ty. 👍

juhguu avatar Jan 16 '18 17:01 juhguu

Angular 5 Masonry Module with animations: https://github.com/Shailu4u/ng-masonry-grid

Shailu4u avatar Jan 24 '18 09:01 Shailu4u

Thanks Shailu4u this works for me.

renzo031109 avatar Mar 09 '18 03:03 renzo031109