Skip to content

Commit

Permalink
Fix build errors
Browse files Browse the repository at this point in the history
  • Loading branch information
ewen-lbh committed Nov 9, 2024
1 parent 7d8e0b8 commit b85c365
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion packages/houdini/src/lib/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ export type GenerateHookInput = {
export type PluginConfig = {
configPath?: string
adapter?: Adapter
autoCodeGen: 'smart' | 'off' | 'startup' | 'watch'
autoCodeGen?: 'smart' | 'off' | 'startup' | 'watch'
} & Partial<ConfigFile>

export * from '../runtime/lib/types'
Expand Down
12 changes: 6 additions & 6 deletions packages/houdini/src/vite/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import minimatch from 'minimatch'
import { readFile } from 'node:fs/promises'
import type { Plugin, ViteDevServer } from 'vite'
import watch_and_run from 'vite-plugin-watch-and-run'
import { watchAndRun } from 'vite-plugin-watch-and-run'

import generate from '../codegen'
import type { PluginConfig } from '../lib'
Expand Down Expand Up @@ -36,7 +36,7 @@ export default function (opts?: PluginConfig): Plugin[] {
watch_local_schema(watchSchemaListref),
]

const codegen = async (_server?: ViteDevServer, absolutePath?: string) => {
const codegen = async (_server: ViteDevServer | undefined, absolutePath: string | null) => {
// load the config file
const config = await getConfig(opts)
if (config.localSchema) {
Expand All @@ -47,7 +47,7 @@ export default function (opts?: PluginConfig): Plugin[] {
// make sure we behave as if we're generating from inside the plugin (changes logging behavior)
config.pluginMode = true

if (opts.autoCodeGen === 'smart' && absolutePath) {
if (opts?.autoCodeGen === 'smart' && absolutePath) {
const fileContents = await readFile(absolutePath).then((buf) => buf.toString('utf8'))
if (fileContents) {
const [documentsChanged, documents] = graphQLDocumentsChanged(
Expand All @@ -72,16 +72,16 @@ export default function (opts?: PluginConfig): Plugin[] {

switch (opts.autoCodeGen) {
case 'startup':
void codegen()
void codegen(undefined, null)
break

case 'watch':
case 'smart':
plugins.push(
watch_and_run([
// @ts-ignore TODO
watchAndRun([
{
name: 'Houdini',
quiet: true,
async watchFile(filepath: string) {
// load the config file
const config = await getConfig(opts)
Expand Down

0 comments on commit b85c365

Please sign in to comment.