0.1.0-beta.1 • Published 4 months ago

@yamatomo/codegen-client-preset-transform v0.1.0-beta.1

Weekly downloads
-
License
MIT
Repository
github
Last release
4 months ago

codegen-client-preset-transform

Transform the code of a project that uses client-preset into a tree-shakeable code.

Usage

Vanilla JS

import { transform } from '@yamatomo/codegen-client-preset-transform'

const transformedCode = transform({
  code: `... your code ...`,
  // Pass the path to the code generation directory.
  artifact: './path/to/'
}).toString()

Alternatively, a DocumentNode dictionary can be passed.

import { transform } from '@yamatomo/codegen-client-preset-transform'
import documentNodeDict from './path/to/graphql'

const transformedCode = transform({
  code: `... your code ...`,
  artifact: documentNodeDict
}).toString()

vite

import { defineConfig } from 'vite'
import { vitePlugin as codegenClientPresetTransform } from '@yamatomo/codegen-client-preset-transform'

export default defineConfig({
  plugins: [
    codegenClientPresetTransform({ artifactDirectory: './path/to/' })
  ]
})