Vue + Vite + Parse JS: error “Super expression must either be null or a function”

Hello community,

first post here! I’m experiencing the exact same error from this post .

I have created a minimale repro on Codesandbox .

You will notice that the OP from the other post and I are both using Vite, which I believe is what is ultimately causing the issue.

The error happens here in LiveQuerySubscription.js:

var Subscription = /*#__PURE__*/function (_EventEmitter) {
  (0, _inherits2.default)(Subscription, _EventEmitter); // error happens here

  var _super = _createSuper(Subscription);

and it’s apparently because the following check fails in babel/runtime-corejs3/helpers/inherits.js:

function _inherits(subClass, superClass) {
// superClass is === undefined and the error is thrown
  if (typeof superClass !== "function" && superClass !== null) {
    throw new TypeError("Super expression must either be null or a function");
  }

  subClass.prototype = _Object$create(superClass && superClass.prototype, {
    constructor: {
      value: subClass,
      writable: true,
      configurable: true
    }
  });
  if (superClass) setPrototypeOf(subClass, superClass);
}

…since superClass is undefined and the strict check !== null fails

image

All this is probably because Vite uses no preprocessor and instead leans on modern browsers being able to use ES6 modules? I don’t know, may be something completely different. All I know is that I don’t have this issue using the vue-cli in place of Vite… but then again, I was just migrating to Vite!! :cry:

Hope this can be solved, thanks in advance,

Stefano

1 Like