-
Notifications
You must be signed in to change notification settings - Fork 42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
v1.0.0 incompatible with Node.js at runtime #93
Comments
I see you're publishing both CJS and ESM modules in https://unpkg.com/browse/graphql-query-complexity@1.0.0/dist/ Something you could consider, is having a build step when creating those artifacts that inserts https://github.com/jaydenseric/babel-plugin-transform-require-extensions Nowadays in my own packages I militantly publish pure ESM and haven't used it for some time. The catch with the above approach is that people (like me) like to consume your package as ESM, but expect it to pull in the CJS version of graphql-query-complexity/package.json Lines 46 to 51 in 455978d
For optimal JavaScript module design you should have package exports allowing deep imports of only the things people need anyway, and ideally remove the ability for consumers to import any other way. Force them to fall into the pit of success. |
+1 for this |
Has anyone found a workaround for using this plugin in an ESM project? I'm assuming this is the PR that introduced the bug: #91 |
CC @ivome |
The recent v1.0.0 release has made this package incompatible with the Node.js runtime, because of this change from a valid fully specified import path to an invalid non fully specified import path missing the file extension:
https://github.com/slicknode/graphql-query-complexity/pull/91/files#diff-720574529a576948113b0f865801527a139a756ce25203d58f98f714bfd59b76R11
With Node.js v22.3.0, here is the runtime error:
We do not have a bundler in our Node.js GraphQL API project, and even if we did, we would be enforcing modern ESM module resolution rules which require fully specified import paths.
We will have to keep our dependency on
graphql-query-complexity
at^0.12.0
until this issue is resolved.Because the ecosystem can't be importing both ESM and CJS versions of
graphql
modules, so far it has settled on only importing the CJS because that's what came first and took root. The people best positioned to effect a transition to the ESM is thegraphql
maintainers, who could stop publishing CJS in a new major version and only publish pure ESM and force an ecosystem migration to align to ESM instead. That was actually planned for a majorgraphql
release, but they chickened out on it in the end.As a package author, you have to pick either importing ESM or CJS from
graphql
; you can't avoid making a decision.The text was updated successfully, but these errors were encountered: