angular-intercom icon indicating copy to clipboard operation
angular-intercom copied to clipboard

Not works when used with webpack

Open Alex12321 opened this issue 8 years ago • 3 comments

I create the sample repo https://github.com/Alex12321/test-intercom In this case I need to run intercom after page loads. But nothing happens.

You can see code what I used at this file: https://github.com/Alex12321/test-intercom/blob/master/client/app/app.js

To run:

npm install
gulp serve

Alex12321 avatar Mar 15 '16 09:03 Alex12321

According to my tests, it seems that the Intercom script is not even loaded from the CDN. Will continue to investigate.

(Correction: It is, but the ping endpoint isn't being hit)

yjwong avatar Mar 21 '16 14:03 yjwong

The issue is that webpack allows using AMD, which is the first if case. You need to disable AMD in webpack:

Install imports loader:

npm install imports-loader

On your require statement:

require('imports?define=>false!angular-intercom')

derekstavis avatar Apr 08 '16 20:04 derekstavis

Complementing @derekstavis answer, this did the trick:

import 'imports?this=>window&exports=>false&define=>false!angular-intercom'

This fools angular-intercom's module startup tests ("exports=>false&define=>false") and works around webpack's scoping ("this=>window")

bisol avatar May 12 '16 22:05 bisol