I am trying to setup a rails application with inertia and svelte
I've got the following files set-up as per the documentation however it will not render the svelte component it errors in the console with this message:
Uncaught (in promise) SyntaxError: "undefined" is not valid JSON
at JSON.parse (<anonymous>)
at createInertiaApp (@inertiajs_svelte.js?v=5b546d2f:5036:37)
at application.js:3:1
I saw this error referenced in #1358 as well although I'm not sure they're directly related if anyone has insight on how to resolve this I'd appreciate it
app/frontend/entrypoints/application.js
import { createInertiaApp } from '@inertiajs/svelte'
createInertiaApp({
resolve: name => {
const pages = import.meta.glob('./Pages/**/*.svelte', { eager: true })
return pages[`./Pages/${name}.svelte`]
},
setup({ el, app, props }) {
new app({ target: el, props })
},
})
config/routes.rb
Rails.application.routes.draw do
root "static#home"
end
app/controllers/static_controller.rb
class StaticController < ApplicationController
def home
render inertia: 'app'
end
end
Version:
@inertiajs/svelte
version: 1.0.15Describe the problem:
I am trying to setup a rails application with inertia and svelte
I've got the following files set-up as per the documentation however it will not render the svelte component it errors in the console with this message:
I saw this error referenced in #1358 as well although I'm not sure they're directly related if anyone has insight on how to resolve this I'd appreciate it
app/frontend/entrypoints/application.js
config/routes.rb
app/controllers/static_controller.rb
app/views/layouts/application.html.erb
app/frontend/pages/app.svelte
Steps to reproduce:
setup a rails/inertia/svelte app with the preceding set up