Skip to content

Cannot create an instance of GraphiQL when using requirejs #2598

Closed as not planned
@shabab477

Description

@shabab477

I am trying to get an instance of GraphiQL but keep getting this error:

index.js:5 Uncaught ReferenceError: exports is not defined

My requrejs code looks like this:

requirejs(['../../config'], function (c) {
    requirejs(['react'], function(react) {
      requirejs(['ReactDOM'], function(reactDOM) {
        requirejs([ 'graphiql'], function strict(GraphiQL) {
            ............

And config:

requirejs.config({
  baseUrl: '/asset',
  paths: {
    app: '../app',
    // Add path to WebJars here, without extension...
    react: '../lib/react/umd/react.production.min',
    ReactDOM: '../lib/react-dom/umd/react-dom.production.min',
    graphiql: '../lib/graphiql/dist/index'
  }
});

I understand that this is because GraphiQL dist/index.js is not using AMD. Could you point me towards how I would go about this issue when using GraphiQL with requirejs?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions