You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
@DanailPenev Thanks for reporting this issue. Unfortunately, I'm a bit at a loss for how to address this problem. I am reading into it but do you have any suggestions?
The problem is with how the packages debug and pluralize are imported, since both of these are CommonJS. The CJS export (dist/index.js) works fine, since it uses good old require. But the esm module needs to be corrected. The only thing that would be needed is to be a bit more consistent in how the imports are handled.
ESM should be fixed by this, and CommonJS should still be working.
Give me a few minutes and I'll create a PR.
Until that is merged and released, one can still use this package with Webpack (but not have as good tree shaking capabilities) by using cjs: const { createGraphQLSchema } = require('openapi-to-graphql');.
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-foundTo Reproduce
openapi-to-graphql
to a project using webpack 5createGraphQLSchema
Expected behavior
createGraphQLSchema
should work as expectedError log
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.The text was updated successfully, but these errors were encountered: