Skip to content

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

@ejbp

Description

@ejbp

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions