graphql-request
graphql-request copied to clipboard
Publish ES module
Vite does not work well with commonjs module. In this case all named exports are inaccessible in vite build.
I think we would also need to fix cross-fetch to get graphql-request working in Vite.
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 same here. Did you find a solution for this?
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(),
],
});
Same here again. Any working solutions?
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.
Hey everyone, I'm interested in publishing a proper ESM soon, more info here https://github.com/prisma-labs/graphql-request/pull/359.
I'm back on this now.