@graphql-codegen/client-preset-swc-plugin

中文文档
0.2.0发布于 2023/04/27MITCommonJS零依赖近 30 天下载 3.5万
此软件包已被标记为弃用

This package is deprecated. Please use @swc-contrib/plugin-graphql-codegen-client-preset instead.

原始使用文档
文档目录3 节
  1. Installation
  2. Usage
  3. Release

@graphql-codegen/client-preset-swc-plugin

When using the @graphql-codegen/client-preset on large scale projects might want to enable code splitting or tree shaking on the client-preset generated files. This is because instead of using the map which contains all GraphQL operations in the project, we can use the specific generated document types.

This plugin works for SWC only.

Installation

yarn add -D @graphql-codegen/client-preset-swc-plugin

Usage

You will need to provide the artifactDirectory path that should be the same as the one configured in your codegen.ts

Vite

import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react-swc'

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    react({
      plugins: [
        ['@graphql-codegen/client-preset-swc-plugin', { artifactDirectory: './src/gql', gqlTagName: 'graphql' }]
      ]
    })
  ]
})

Next.js

const nextConfig = {
  // ...
  experimental: {
    swcPlugins: [
      ['@graphql-codegen/client-preset-swc-plugin', { artifactDirectory: './src/gql', gqlTagName: 'graphql' }]
    ]
  }
}

.swcrc

{
  // ...
  jsc: {
    // ...
    experimental: {
      plugins: [
        ['@graphql-codegen/client-preset-swc-plugin', { artifactDirectory: './src/gql', gqlTagName: 'graphql' }]
      ]
    }
  }
}

Release

To publish a new version ensure you have done the following:

  • Update the version in package.json
  • Update the CHANGELOG.md with the new version and changes
  • Commit the changes
  • From GitHub Actions, run the Rust plugin workflow

版本与发布记录

@graphql-codegen/client-preset-swc-plugin 共发布 5 个版本,首次发布于 2023/02/21;过去 12 个月发布了 0 个版本。

版本发布日期距今
0.2.0latest2023/04/273 年前
0.1.32023/03/123 年前
0.1.22023/03/093 年前
0.1.12023/02/233 年前
0.1.02023/02/213 年前

关于 @graphql-codegen/client-preset-swc-plugin 的常见问题

@graphql-codegen/client-preset-swc-plugin 是什么?

A SWC plugin for https://the-guild.dev/graphql/codegen/plugins/presets/preset-client注意:该包已被作者标记为弃用——This package is deprecated. Please use @swc-contrib/plugin-graphql-codegen-client-preset instead.

如何安装 @graphql-codegen/client-preset-swc-plugin?

在项目目录运行 npm install @graphql-codegen/client-preset-swc-plugin,或使用 pnpm add / yarn add / bun add。

@graphql-codegen/client-preset-swc-plugin 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/graphql-codegen__client-preset-swc-plugin 是否存在。

@graphql-codegen/client-preset-swc-plugin 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@graphql-codegen/client-preset-swc-plugin 可以商用吗?

@graphql-codegen/client-preset-swc-plugin 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@graphql-codegen/client-preset-swc-plugin 的下载量有多少?

根据 npm 官方下载统计,@graphql-codegen/client-preset-swc-plugin 在 2026/10/17 – 2026/11/15 这 30 天内被下载 35,108 次,日均约 1,170 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@graphql-codegen/client-preset-swc-plugin 还在维护吗?

最新版本 0.2.0 发布于 2023/04/27(3 年前);至今共发布 5 个版本,其中过去 12 个月发布了 0 个;首次发布于 2023/02/21。作者已将其标记为弃用,新项目建议寻找替代方案。