graphql-query-compress
graphql-query-compress copied to clipboard
make entry point consistently CJS instead of ESM and CJS combined
Sorry for all the GitHub notifications. Your entry point was a mix of ESM for import, and CJS for export. This causes errors if people alias webpack to just consume the entry point directly. Making the entry point consistently CJS fixes this problem, without introducing any breaking behavior.
I'm using ESM on imports in nearly all libraries and intentionally the good old CJS export for compatibility reasons and I've not seen any trouble with Webpack until now. Can you be more specific when and why Webpack breaks when using graphql-query-compress?
Sure, basically adding this
"graphql-query-compress": "graphql-query-compress/src/graphql-query-compress"
causes a TypeError at runtime
on module.exports = compactGraphQLQuery since of course module doesn't exist.
webpack sees the ESM import at the top of the file, and processes it, and assumes the file is ESM. It then ignores the call to module.exports.
Of course the secondary workaround would be to point it at the Node build, but I really think you should consider making these modules consistent. I'd love all ESM, but that would be a breaking change, and so all CJS would in this case be as good, with no breakage anywhere.