Skip to content
This repository has been archived by the owner on Aug 4, 2021. It is now read-only.

Inheriting class via a external extended export #231

Closed
sgwilym opened this issue Sep 25, 2017 · 0 comments
Closed

Inheriting class via a external extended export #231

sgwilym opened this issue Sep 25, 2017 · 0 comments

Comments

@sgwilym
Copy link

sgwilym commented Sep 25, 2017

I think I've found an issue somewhat similar to #150, where classes don't have their superclasses defined.

The problem is happening with classes extending Mutation from react-relay/classic:

import { Mutation } from "react-relay/classic";

export default class MyCoolMutation extends Mutation {
  ...
}

This is bundled by Rollup into something like the following:

var MyCoolMutation = function (_Mutation) {
  _inherits(MyCoolMutation, _Mutation);

 ...
}

_Mutation being an argument of this function, you end up with this error when you try to use this export:

TypeError: Super expression must either be null or a function, not undefined

I looked into react-relay/classic to see how the exports were structured:

module.exports = require('./lib/ReactRelayClassicExports.js');

Which leads to where I suspect the source of the trouble is coming from:

'use strict';

var _extends3 = _interopRequireDefault(require('babel-runtime/helpers/extends'));

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }

// As early as possible, check for the existence of the JavaScript globals which
// React Relay relies upon, and produce a clear message if they do not exist.
if (process.env.NODE_ENV !== 'production') {
  if (typeof Map !== 'function' || typeof Set !== 'function' || typeof Promise !== 'function' || typeof Object.assign !== 'function' || typeof Array.prototype.find !== 'function') {
    throw new Error('react-relay requires Map, Set, Promise, Object.assign, and Array#find ' + 'to exist. Use a polyfill to provide these for older browsers.');
  }
}

// By default, assume that GraphQL is served at `/graphql` on the same domain.
// To override, use `Relay.injectNetworkLayer`.
require('./RelayStore').injectDefaultNetworkLayer(new (require('./RelayDefaultNetworkLayer'))('/graphql'));

module.exports = (0, _extends3['default'])({}, require('./RelayPublic'), {
  // Expose the default network layer to allow convenient re-configuration.
  DefaultNetworkLayer: require('./RelayDefaultNetworkLayer')
});

I'd be grateful to know if there's some option or plugin that I'm not using properly or at all, or whether this is indeed something weird going on here. Sorry if this is in the wrong repo, I wasn't sure where the problem, if any, could be.

@sgwilym sgwilym closed this as completed Oct 17, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant