zyra/ngx-facebook

"Unexpected token import" error with Angular Universal

SoftwareAndOutsourcing opened this issue · 5 comments

Hi,

I'm getting an error with the ngx-facebook with Angular Universal. Steps to reproduce:

  1. git clone https://github.com/angular/universal-starter.git.
  2. npm i.
  3. Add ngx-facebook as described in the docs.
  4. npm run build:ssr && npm run serve:ssr.

Result: I get an SyntaxError: Unexpected token import error.

I created a demo repository in https://github.com/SoftwareAndOutsourcing/universal-starter-ngx-facebook-demo following the above steps.

Thanks.

any solution for this error?

Try importing the library directly from ngx-facebook/dist/umd

I was facing the same problem so I tried the suggested solution of importing from /dist/umd. Then when I import the library directly I get a number of warnings similar to the following when I do ng build --prod:

WARNING in ./node_modules/ngx-facebook/dist/umd/components/fb-quote/fb-quote.js 6:24-31
Critical dependency: require function is used in a way in which dependencies cannot be statically extracted

Then when I deploy nothing works with error:

Uncaught Error: Cannot find module './components/fb-comment-embed/fb-comment-embed'

Any help would be greatly appreciated.

@aazo11 do you found solution?

@aazo11 @tebantebanteban found any solution?