Skip to content

Commit

Permalink
Fix error when prerendering application (#786)
Browse files Browse the repository at this point in the history
* don't add session infrastructure when static is set to true

* use existing static config value

* changeset

* unused import
  • Loading branch information
AlecAivazis authored Dec 23, 2022
1 parent 44f8acc commit 0437769
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/dull-starfishes-matter.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'houdini-svelte': patch
---

Static configuration value can now be used to remove session infrastructure from application
8 changes: 7 additions & 1 deletion packages/houdini-svelte/src/plugin/fsPatch.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import filesystem, { Dirent, PathLike } from 'fs'
import { fs, Plugin, path } from 'houdini'

import { _config } from '.'
import {
Framework,
is_root_layout,
is_root_layout_server,
is_route_script,
plugin_config,
resolve_relative,
} from './kit'

Expand Down Expand Up @@ -193,7 +195,11 @@ filesystem.readdirSync = function (
}
// if we are in looking inside of src/routes and there's no +layout.server.js file
// we need to create one
if (is_root_route(posix_filepath) && !contains('+layout.server.js', '+layout.server.ts')) {
if (
is_root_route(posix_filepath) &&
!contains('+layout.server.js', '+layout.server.ts') &&
!plugin_config(_config).static
) {
result.push(virtual_file('+layout.server.js', options))
}

Expand Down
5 changes: 4 additions & 1 deletion packages/houdini-svelte/src/plugin/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { HoudiniError, PluginFactory, path, fs } from 'houdini'
import { HoudiniError, PluginFactory, path, fs, type Config } from 'houdini'
import * as url from 'url'
import { loadEnv } from 'vite'

Expand All @@ -18,6 +18,8 @@ import validate from './validate'

let framework: Framework = 'svelte'

export let _config: Config

const HoudiniSveltePlugin: PluginFactory = async () => ({
order: 'core',

Expand Down Expand Up @@ -131,6 +133,7 @@ export const error = svelteKitError
*/

async after_load(cfg) {
_config = cfg
const cfgPlugin = plugin_config(cfg)

let client_file_exists = false
Expand Down
2 changes: 1 addition & 1 deletion site/src/routes/api/config/+page.svx
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ Here is a summary of the possible configuration values:
- `pageQueryFilename` (optional, default: `+page.gql`): The name of the file used to define page queries.
- `layoutQueryFilename` (optional, default: `+layout.gql`): The name of the file used to define layout queries.
- `quietQueryErrors` (optional, default: `false`): With this enabled, errors in your query will not be thrown as exceptions. You will have to handle error state in your route components or by hand in your load (or the onError hook)
- `static` (optional, default: `false`): A flag to treat every component as a non-route.
- `static` (optional, default: `false`): A flag to remove the session infrastructure from your application

## Custom Scalars

Expand Down

2 comments on commit 0437769

@vercel
Copy link

@vercel vercel bot commented on 0437769 Dec 23, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

docs-next – ./site

docs-next-git-main-houdinigraphql.vercel.app
docs-next-houdinigraphql.vercel.app
docs-next-kohl.vercel.app

@vercel
Copy link

@vercel vercel bot commented on 0437769 Dec 23, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.