Skip to content

Webpack5 doesn't work due to 'debug' named export #452

@DanailPenev

Description

@DanailPenev

Describe the bug
Using the openapi-to-graphql library in projects using webpack 5 throws a runtime error due to issues with CommonJS/ESM. This is similar to the issue observed in other libraries, e.g. graphql/graphql-js#2721 or https://stackoverflow.com/questions/70615613/apollo-client-named-export-remove-not-found

To Reproduce

  • Add openapi-to-graphql to a project using webpack 5
  • Call createGraphQLSchema
  • Try opening the page triggering this behaviour
  • You should see an error in the console

Expected behavior

  • createGraphQLSchema should work as expected

Error log

CommonJS modules can always be imported via the default export, for example using:
import pkg from 'debug';
const { debug: debug$1 } = pkg;
error - unhandledRejection: SyntaxError: Named export 'debug' not found. The requested module 'debug' is a CommonJS module, which may not support all module.exports as named exports.
CommonJS modules can always be imported via the default export, for example using:
import pkg from 'debug';
const { debug: debug$1 } = pkg;

Additional context
This seems to have been introduced in openapi-to-graphql 2.5.0. More specifically I suspect that it was this commit 74d7163

Removing the exports object from the package.json has worked as a temporary solution for me.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions