graphql-tag
graphql-tag copied to clipboard
Allow exporting ESM
This adds an option esm which if set to true changes the exports to use ESM format
export default doc;
export const MyQuery = oneQuery(...);
etc.
This allows usage with node-esm-loader
export default {
loaders: [
{
test: /\.(graphql|gql)$/,
use: [
{
loader: "graphql-tag/loader.js",
options: {
esm: true
}
}
]
},
],
};
@mkg20001: Thank you for submitting a pull request! Before we can merge it, you'll need to sign the Apollo Contributor License Agreement here: https://contribute.apollographql.com/
Hey @mkg20001 👋
Thanks so much for the PR! For now I can't guarantee a timeline on when we will review/merge this PR as we are still figuring out our ESM strategy right now. Thanks for the thought put into this!
Fyi ESM is now stable and esm loaders are "Release Candidate" as of node 20, so relying on this in production is no longer such a trouble as it used to be.
https://nodejs.org/dist/latest-v20.x/docs/api/esm.html#modules-ecmascript-modules
https://nodejs.org/dist/latest-v20.x/docs/api/module.html#customization-hooks