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

Publish ES module

Open znck opened this issue 3 years ago • 7 comments

Vite does not work well with commonjs module. In this case all named exports are inaccessible in vite build.

znck avatar Aug 19 '20 05:08 znck

I think we would also need to fix cross-fetch to get graphql-request working in Vite.

Zippersk avatar Sep 08 '20 19:09 Zippersk

I just tried to use graphql-request with a @web/dev-server and it doesn't work because it's not published as modules.

justinfagnani avatar Dec 18 '20 19:12 justinfagnani

@justinfagnani same here. Did you find a solution for this?

alber70g avatar Jan 20 '21 07:01 alber70g

As for @web/dev-server I'm using the rollup plugin commonjs. This fixes the exports for now, but it doesn't work yet.

web-dev-server now tries to resolve "util". I think it's because it's trying to resolve cross-fetch with node-fetch instead the browser variant?

+ import { fromRollup } from '@web/dev-server-rollup';
+ import commonjs from '@rollup/plugin-commonjs';
+ const rollupCommonjs = fromRollup(commonjs);

export default /** @type {import('@web/dev-server').DevServerConfig} */ ({
  nodeResolve: true,
  open: '/',

  plugins: [
+     rollupCommonjs(),
  ],
});

alber70g avatar Jan 20 '21 07:01 alber70g

Same here again. Any working solutions?

canonic-epicure avatar Jun 14 '22 14:06 canonic-epicure

The workaround for me was to use esinstall to install graphql-request for me. It creates a separate folder web_modules and pulls in all dependencies. This is of course sub-optimal in regards of bundle size.

package.json

    "devDependencies": {
         "esinstall": "^1.1.7"
    }
}

web-install.js (any script name will work):

import { install } from 'esinstall'

await install([ 'graphql-request', 'graphql' ], { polyfillNode : true })

I'm also using @web/dev-server with the rollup's commonjs plugin. But it does not work for some reason.

canonic-epicure avatar Jun 15 '22 06:06 canonic-epicure

Hey everyone, I'm interested in publishing a proper ESM soon, more info here https://github.com/prisma-labs/graphql-request/pull/359.

jasonkuhrt avatar Jun 15 '22 12:06 jasonkuhrt

I'm back on this now.

jasonkuhrt avatar Feb 18 '23 00:02 jasonkuhrt