graphql-tag icon indicating copy to clipboard operation
graphql-tag copied to clipboard

Allow exporting ESM

Open mkg20001 opened this issue 2 years ago • 3 comments

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 avatar Oct 03 '23 15:10 mkg20001

@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/

apollo-cla avatar Oct 03 '23 15:10 apollo-cla

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!

jerelmiller avatar Oct 03 '23 16:10 jerelmiller

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

mkg20001 avatar Oct 03 '23 16:10 mkg20001