zyra / ngx-facebook

Angular TypeScript Wrapper for Facebook SDK
http://zyra.github.io/ngx-facebook/
MIT License
209 stars 70 forks source link

"Unexpected token import" error with Angular Universal #146

Open SoftwareAndOutsourcing opened 5 years ago

SoftwareAndOutsourcing commented 5 years ago

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.

nch3ng commented 5 years ago

any solution for this error?

HighSoftWare96 commented 5 years ago

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

aazo11 commented 5 years ago

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.

tebantebanteban commented 4 years ago

@aazo11 do you found solution?

azkarmoulana commented 4 years ago

@aazo11 @tebantebanteban found any solution?