Skip to content

Commit

Permalink
Fix error preventing fresh builds of framework (#1177)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlecAivazis authored Sep 28, 2023
1 parent 210c166 commit 8831c14
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 10 deletions.
5 changes: 5 additions & 0 deletions .changeset/silly-carpets-smash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'houdini-react': patch
---

Fix error preventing succesfull build
2 changes: 1 addition & 1 deletion e2e/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"build:generate": "pnpm build: && pnpm houdini generate",
"build:build": "pnpm build: && pnpm build",
"dev": "vite",
"build": "tsc && vite build",
"build": "vite build",
"preview": "vite preview"
},
"dependencies": {
Expand Down
26 changes: 17 additions & 9 deletions packages/houdini-react/src/plugin/codegen/render.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@ export async function generate_renders({
// make sure the necessary directories exist
await fs.mkdirp(path.dirname(routerConventions.server_adapter_path(config)))

const app_index = `
import React from 'react'
import Shell from '../../../../../src/+index'
import { Router } from '$houdini'
export default (props) => <Shell><Router {...props} /></Shell>
`

// and a file that adapters can import to get the local configuration
let adapter_config = `
import createAdapter from './server'
Expand Down Expand Up @@ -50,6 +58,7 @@ import { serverAdapterFactory } from '$houdini/runtime/router/server'
import { Router, router_cache } from '../../runtime'
import manifest from '../../runtime/manifest'
import App from './App'
import Shell from '../../../../../src/+index'
Expand All @@ -66,15 +75,13 @@ export default (options) => {
}
const { readable, injectToStream, pipe: pipeTo } = await renderToStream(
React.createElement(Shell, {
children: React.createElement(Router, {
initialURL: url,
cache: cache,
session: session,
assetPrefix: options.assetPrefix,
manifest: manifest,
...router_cache()
})
React.createElement(App, {
initialURL: url,
cache: cache,
session: session,
assetPrefix: options.assetPrefix,
manifest: manifest,
...router_cache()
}),
{
userAgent: 'Vite',
Expand Down Expand Up @@ -110,5 +117,6 @@ export default (options) => {
await Promise.all([
fs.writeFile(routerConventions.server_adapter_path(config), server_adapter),
fs.writeFile(routerConventions.adapter_config_path(config), adapter_config),
fs.writeFile(routerConventions.app_component_path(config), app_index),
])
}
4 changes: 4 additions & 0 deletions packages/houdini/src/lib/router/conventions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ export function adapter_config_path(config: Config, base?: string) {
return path.join(units_dir(config, base), 'render', 'config.js')
}

export function app_component_path(config: Config, base?: string) {
return path.join(units_dir(config, base), 'render', 'App.jsx')
}

export function page_unit_path(config: Config, id: string, base?: string) {
return path.join(page_units_dir(config, base), `${id}.jsx`)
}
Expand Down

0 comments on commit 8831c14

Please sign in to comment.