SamirHodzic / ngx-embed-video

Get embed code for embedding youtube/vimeo/dailymotion/* video in websites from URL or ID in Angular 6+.
MIT License
56 stars 41 forks source link

getting error only with AOT #21

Closed sam0hack closed 5 years ago

sam0hack commented 5 years ago

it's working fine with JIT but gives this error when compile with AOT.

i'm using-> ng serve --aot

angularJS version 6.0.8

Error when compiling with AOT

sam0hack commented 5 years ago

Okay, I fixed the error. it is a workaround but I hope this plugin author will fix this problem. So for fixing it, I added this "include": ["./**/*.ts", "../node_modules/ngx-embed-video/**/*.ts"] into /src/tsconfig.app.json but then I got the errors in the node_modules/ngx-embed-video/tests/embed-video-service.spec.ts Errors in embed-video-service.spec.ts I just commented out the embed-video-service.spec.ts and it fixed all the problems, now the application is working fine with AOT

AaronLavers commented 5 years ago

It would be really nice if this module were packaged correctly and didn't include these .ts files

SamirHodzic commented 5 years ago

@AaronLavers I agree, it should be packaged differently and It will be soon. It was primarily made for Angular 2 before and just patched for newer versions because lack of time.

vdias38 commented 5 years ago

Hi,

I've tried above solution suggested by @sam0hack but it not fix the issue for me. I use Ionic v3 w/ Angular 5. Below the error raised if I include ../node_modules/ngx-embed-video/**/*.ts on tsconfig.json and comment spec.ts.

[15:47:53]  ionic-app-scripts 3.1.9 
[15:47:53]  build prod started ... 
[15:47:53]  clean started ... 
[15:47:54]  clean finished in 90 ms 
[15:47:54]  copy started ... 
[15:47:56]  deeplinks started ... 
[15:47:57]  deeplinks finished in 538 ms 
[15:47:57]  ngc started ... 
[15:48:51]  ngc finished in 54.36 s 
[15:48:51]  preprocess started ... 
[15:48:51]  preprocess finished in 1 ms 
[15:48:51]  webpack started ... 

Using DEFAULT environment variables for PROD build.

Loading ./src/environments/environment.ts

[15:48:53]  copy finished in 59.79 s 
[15:51:31]  ionic-app-script task: "build" 
[15:51:31]  Error: ./node_modules/ngx-embed-video/index.ts Module build failed: Error: ENOENT: no such file or 
            directory, open '/Users/victor/Dvpt/PROJECTS/ion-employee/node_modules/ngx-embed-video/index.js' @ 
            ./src/pages/video-details/video-details.module.ngfactory.js 39:0-45 @ ./src lazy @ 
            ./node_modules/ionic-angular/util/ng-module-loader.js @ ./src/app/app.module.ngfactory.js @ 
            ./src/app/main.ts,./node_modules/ngx-embed-video/src/embed-video.service.ts Module build failed: Error: 
            ENOENT: no such file or directory, open 
            '/Users/victor/Dvpt/PROJECTS/ion-employee/node_modules/ngx-embed-video/src/embed-video.service.js' @ 
            ./src/pages/video-details/video-details.module.ngfactory.js 31:0-63 @ ./src lazy @ 
            ./node_modules/ionic-angular/util/ng-module-loader.js @ ./src/app/app.module.ngfactory.js @ 
            ./src/app/main.ts 
Error: ./node_modules/ngx-embed-video/index.ts
Module build failed: Error: ENOENT: no such file or directory, open '/Users/victor/Dvpt/PROJECTS/ion-employee/node_modules/ngx-embed-video/index.js'
 @ ./src/
SamirHodzic commented 5 years ago

Hi @elbidone, latest version works with Angular 6+. You can try 0.3.0, should work fine with Angular 5.

vdias38 commented 5 years ago

Hi @SamirHodzic , I've downgraded to 0.3.0 but raised same error reported above for prod build AOT (works fine for dev)

SamirHodzic commented 5 years ago

Did you updated tsconfig.app.json also to include it?

Something like this should work I think,

"include": [
    "./node_modules/ngx-embed-video/**/*.ts"
],
"exclude": [
    "./node_modules/ngx-embed-video/tests/embed-video-service.spec.ts"
]
vdias38 commented 5 years ago

an extract of tsconfig.json of my project

  "include": [
    "src/**/*.ts",
    "node_modules/ngx-embed-video/**/*.ts"
  ],
  "exclude": [
    "node_modules",
    "src/**/*.spec.ts",
    "src/**/__tests__/*.ts"
  ],

It doesn't work, but I'm not sure if it's due to the config. I'm doing some investigation to check if ngx-embed-video/**/*.ts are correctly transpiled even if I exclude "node_modules".