dotansimha / dotansimha/graphql-code-generator
client-preset babelOptimizerPlugin configuration issue
- Dominant language
- TypeScript
- Stars
- 11.3k
- Forks
- 1.4k
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 23
Description
### Which packages are impacted by your issue?
@graphql-codegen/client-preset
### Describe the bug
When I configure the babelOptimizerPlugin according to the documentation (https://the-guild.dev/graphql/codegen/plugins/presets/preset-client#babel-plugin) the build output becomes unusable.
### Your Example Website or App
https://github.com/amorey/graphql-codegen-babel-example
### Steps to Reproduce the Bug or Issue
```bash
pnpm install
pnpm build
```
### Expected behavior
The output I expect is something like this:
```
$ pnpm build
...
vite v5.0.9 building for production...
✓ 298 modules transformed.
dist/index.html 0.54 kB │ gzip: 0.33 kB
dist/assets/index-T74ItOsL.css 0.92 kB │ gzip: 0.50 kB
dist/assets/index-87qPBcCT.js 2.03 kB │ gzip: 0.88 kB
dist/assets/vendor-UWntF4n2.js 157.87 kB │ gzip: 50.74 kB
✓ built in 1.14s
```
But the output I'm seeing is:
```
$ pnpm build
...
vite v5.0.9 building for production...
✓ 3 modules transformed.
dist/index.html 0.39 kB │ gzip: 0.27 kB
dist/assets/index-KKvdShDj.js 1.14 kB │ gzip: 0.61 kB
✓ built in 396ms
```
### Screenshots or Videos
_No response_
### Platform
- OS: macOS
- NodeJS: 20.9.0
- `graphql` version: 16.8.1
- `@graphql-codegen/*` version(s): 5.0.0
### Codegen Config File
```typescript
import type { CodegenConfig } from '@graphql-codegen/cli';
const config: CodegenConfig = {
overwrite: true,
schema: "./schema.graphql",
documents: "src/**/*.tsx",
generates: {
"src/gql/": {
preset: "client",
plugins: []
},
"./graphql.schema.json": {
plugins: ["introspection"]
}
}
};
export default config;
```
### Additional context
```typescript
// vite.config.ts
import { defineConfig, splitVendorChunkPlugin } from 'vite'
import { babelOptimizerPlugin } from '@graphql-codegen/client-preset';
import react from '@vitejs/plugin-react'
// https://vitejs.dev/config/
export default defineConfig({
plugins: [
react({
babel: {
presets: [
'react-app',
],
plugins: [
[babelOptimizerPlugin, { artifactDirectory: './src/gql', gqlTagName: 'graphql' }],
],
}
}),
splitVendorChunkPlugin(),
],
})
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.