rorygarand / react-amplitude

React Amplitude Analytics
11 stars 13 forks source link

__webpack_require__(...) is not a function #17

Open ejbp opened 6 years ago

ejbp commented 6 years ago

I've made a few upgrades to pass from babel-x to @babel/x modules and suddenly I encountered the following error:

Uncaught TypeError: __webpack_require__(...) is not a function
    at Object.init (index.js:158)
    at Module.orQv (index.js:44)
    at __webpack_require__ (bootstrap:63)
    at Object.0 (index.bb54bbdf5c8ea754aa69.bundle.js:3826)
    at __webpack_require__ (bootstrap:63)
    at bootstrap:196
    at bootstrap:196

Line 158 on react-amplitude/dist/index.js is: __webpack_require__(11)((window, document));

var Amplitude = {
  /**
   * Initialize amplitude
   * @param apiKey {String} required
   * @param userId {String} optional
   * @param config {Object} optional
   * @param cb {Function} optional
   */
  init: function init(apiKey, userId, config, cb) {
    if (!(0, _lodash12.default)(apiKey)) {
      (0, _console.warn)('[init] apiKey is required');
      return;
    }
    if (!(0, _lodash4.default)(userId) && !(0, _lodash12.default)(userId)) {
      (0, _console.warn)('[init] userId should be a string');
    }
    if (!(0, _lodash4.default)(config) && !(0, _lodash10.default)(config)) {
      (0, _console.warn)('[init] config should be an object');
    }
    if (!(0, _lodash4.default)(cb) && !(0, _lodash2.default)(cb)) {
      (0, _console.warn)('[init] callback should be a function');
    }

    if ((0, _lodash4.default)(window.amplitude)) {
      __webpack_require__(11)((window, document));
    }

    config = config || {};
    cb = cb || function () {};
    amplitude.getInstance().init(apiKey, userId, config, cb);
  },

Any ideas?

Thanks in advance.

---- UPDATE -----

I changed line of code 46 on src/index.js from require('./utils/amplitude')((window, document)) to require('./utils/amplitude').default(window, document), build it and started to work.

ejbp commented 6 years ago

The issue still maintains.

RyanWarner commented 6 years ago

I am currently unable to use this library due to this issue.

rorygarand commented 5 years ago

hey guys, so sorry about the delay. i will push an update tomorrow to address.

thanks for your patience.

egemon commented 5 years ago

@rorygarand any updated regarding this?

luistiburcio commented 5 years ago

Hi, any updated regarding this?

project-atlas-world commented 5 years ago

Yea, still seeing this issue.

tychovbh commented 5 years ago

Please update

Benyaminrmb commented 5 years ago

i got this problem too ... we all waiting for update

ksaitor commented 5 years ago

updates? 🤔

andrey-s-zakharov commented 4 years ago

I got this issue too, please update