`houdini-svelte` projectDir config option doesn't work as expected.
benterova opened this issue · 3 comments
Describe the bug
I am building a Rails application using SvelteKit to handle the frontend, with all of my Sveltekit files specified in app/frontend
. My node_modules
, package.json
, and configuration files are in the root directory, living alongside houdini.config.js.
When setting up Houdini and pointing my projectDir
to where my SvelteKit application lives, I get the error: houdini init must target an existing node project (with a package.json)
In addition, if I try to alias the src
directory to app/frontend
in either vite.config.ts
or svelte.config.js
as a workaround, it appears to have no effect for Houdini, and a ENOENT: no such file or directory, scandir '/workspaces/job-tailor/src/routes'
is thrown instead. However, I'm not entirely sure I'm using the aliasing functionality correctly.
If I create a symlink for src
to point at app/frontend
, it appears that the application starts, but none of the operations specified in the include path in houdini.config.js
are detected.
Houdini config:
/// <references types="houdini-svelte">
/** @type {import('houdini').ConfigFile} */
const config = {
include: ['app/frontend/**/*.{svelte, ts, graphql}'],
schemaPath: 'app/graphql/schema.graphql',
module: 'esm',
defaultKeys: ['uuid', 'id'],
// projectDir: 'app/frontend',
plugins: {
'houdini-svelte': {
client: 'app/frontend/lib/helpers/graphql.ts',
projectDir: 'app/frontend',
framework: 'kit',
}
}
}
export default config
Svelte config
import adapter from '@sveltejs/adapter-static'
import { vitePreprocess } from '@sveltejs/kit/vite'
import path from 'path'
/** @type {import('@sveltejs/kit').Config} */
const config = {
preprocess: vitePreprocess(),
kit: {
adapter: adapter({
pages: 'public',
fallback: 'index.html'
}),
files: {
assets: 'app/frontend/static',
lib: 'app/frontend/lib',
params: 'app/frontend/params',
routes: 'app/frontend/routes',
serviceWorker: 'app/frontend/service-worker',
appTemplate: 'app/frontend/app.html',
errorTemplate: 'app/frontend/error.html'
},
csp: {
mode: 'hash',
directives: {
'default-src': ['none'],
'script-src': ['self'],
'connect-src': ['self'],
'style-src': ['self'],
'img-src': ['self']
}
},
alias: {
$houdini: path.resolve('.', '$houdini'),
}
}
}
export default config
Vite config
import { defineConfig } from 'vite'
import { sveltekit } from '@sveltejs/kit/vite'
import houdini from 'houdini/vite'
import path from 'path'
export default defineConfig({
clearScreen: false,
plugins: [houdini(), sveltekit()],
server: {
proxy: {
'/graphql': {
target: process.env.RAILS_HOST || 'http://localhost:3000',
changeOrigin: true,
rewrite: path => path.replace(/^\/api/, '')
},
'/cable': {
target: process.env.RAILS_HOST || 'ws://localhost:3000',
changeOrigin: true,
ws: true,
rewrite: path => path.replace(/^\/api/, '')
}
}
},
css: {
devSourcemap: true
}
})
Severity
blocking all usage of Houdini
Steps to Reproduce the Bug
Configuring houdini-svelte (most likely where the bug is occurring, and where it should be fixed)
- Configure Houdini as specified in the documentation
- Point
projectDir
config var ofhoudini-svelte
to another directory - Start application
- Houdini fails with ENOENT error
Base configuration change (this one makes sense, but should still have a configuration option)
- Configure Houdini as specified in the documentation
- Point
projectDir
config var to another directory not containing a package.json - Start application
- Houdini fails because it cannot find a
package.json
Reproduction
No response
Update: after fiddling around I was able to get it to detect operations (this is still the setup with src
symlinked to app/frontend
. I believe this issue is just incomplete projectDir
implementation on houdini-svelte
You have a reason to not have all your frontend
code & config in app/frontend
?
I'm going to close this as its gone a bit stale and it sounds like you have a solution @benterova. If you have the time to put a reproduction together that I can look at I'll gladly reopen this