From 0c81de6ca4a266a646948a09bdc83428379504f3 Mon Sep 17 00:00:00 2001 From: Alec Aivazis Date: Sun, 1 Oct 2023 15:33:24 -0700 Subject: [PATCH] Improve fragmework integration with vite dev server --- .changeset/nice-socks-push.md | 5 +++ .../package.json | 2 +- packages/houdini-react/src/plugin/vite.tsx | 35 ++----------------- packages/houdini-svelte/package.json | 2 +- packages/houdini/package.json | 2 +- 5 files changed, 10 insertions(+), 36 deletions(-) create mode 100644 .changeset/nice-socks-push.md diff --git a/.changeset/nice-socks-push.md b/.changeset/nice-socks-push.md new file mode 100644 index 000000000..49e5a76d3 --- /dev/null +++ b/.changeset/nice-socks-push.md @@ -0,0 +1,5 @@ +--- +'houdini-react': patch +--- + +Improve integration with vite dev server diff --git a/packages/houdini-plugin-svelte-global-stores/package.json b/packages/houdini-plugin-svelte-global-stores/package.json index 6c9d20edf..8a1d9a40a 100644 --- a/packages/houdini-plugin-svelte-global-stores/package.json +++ b/packages/houdini-plugin-svelte-global-stores/package.json @@ -58,4 +58,4 @@ }, "main": "./build/plugin-cjs/index.js", "types": "./build/plugin/index.d.ts" -} +} \ No newline at end of file diff --git a/packages/houdini-react/src/plugin/vite.tsx b/packages/houdini-react/src/plugin/vite.tsx index 2c2322c1a..89c22fb37 100644 --- a/packages/houdini-react/src/plugin/vite.tsx +++ b/packages/houdini-react/src/plugin/vite.tsx @@ -261,37 +261,9 @@ if (window.__houdini__nav_caches__ && window.__houdini__nav_caches__.artifact_ca ) )) as { default: RouterManifest } - const [match] = find_match(router_manifest, req.url) - - if ( - !match && - !internalRoutes(server.houdiniConfig.configFile).find((route) => - req.url?.startsWith(route) - ) - ) { - next() - return - } - - // its worth loading the project manifest - const project_manifest = await load_manifest({ config: server.houdiniConfig }) - - // import the schema - let schema: GraphQLSchema | null = null - if (project_manifest.local_schema) { - schema = await loadLocalSchema(server.houdiniConfig) - } - - // import the yoga server - let yoga: YogaServer | null = null - if (project_manifest.local_yoga) { - const yogaPath = path.join(server.houdiniConfig.localApiDir, '+yoga') - yoga = (await server.ssrLoadModule(yogaPath)) as YogaServer - } - // load the render factory const { createServerAdapter } = (await server.ssrLoadModule( - routerConventions.server_adapter_path(server.houdiniConfig) + routerConventions.adapter_config_path(server.houdiniConfig) )) as { createServerAdapter: any } const requestHeaders = new Headers() @@ -317,17 +289,14 @@ if (window.__houdini__nav_caches__ && window.__houdini__nav_caches__.artifact_ca // instantiate the handler and invoke it with a mocked response const result: Response = await createServerAdapter({ - schema, - yoga, production: false, manifest: router_manifest, - graphqlEndpoint: localApiEndpoint(server.houdiniConfig.configFile), assetPrefix: '/virtual:houdini', pipe: res, documentPremable: ``, })(request) if (result && result.status === 404) { - next() + return next() } // if we got here but we didn't pipe a response then we have to send the result to the end if (result && typeof result !== 'boolean') { diff --git a/packages/houdini-svelte/package.json b/packages/houdini-svelte/package.json index 6d160f320..ffbc0f510 100644 --- a/packages/houdini-svelte/package.json +++ b/packages/houdini-svelte/package.json @@ -72,4 +72,4 @@ }, "main": "./build/plugin-cjs/index.js", "types": "./build/plugin/index.d.ts" -} +} \ No newline at end of file diff --git a/packages/houdini/package.json b/packages/houdini/package.json index aae923df8..9debc246b 100644 --- a/packages/houdini/package.json +++ b/packages/houdini/package.json @@ -109,4 +109,4 @@ "bin": "./build/cmd-esm/index.js", "main": "./build/lib-cjs/index.js", "types": "./build/lib/index.d.ts" -} +} \ No newline at end of file