Open
Description
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
Labels
No labels