Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/generators/inertia/install/frameworks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ svelte:
inertia_package: "@inertiajs/svelte"
packages:
- "svelte@5"
- "@sveltejs/vite-plugin-svelte"
- "vite@latest"
- "@sveltejs/vite-plugin-svelte@4"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Last version compatible with Vite 5

Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't think vite ruby cares about version of vite, I personally use Vite 7 in production for quite some time. what's the issue exactly?

Copy link
Contributor Author

@capripot capripot Nov 23, 2025

Choose a reason for hiding this comment

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

By default when installing on last Rails, when starting bin/dev, vite will crash with the following error:

13:18:31 vite.1 | failed to load config from /Users/capripot/Developer/src/github.com/capripot/inertia-ssr2-test-ts/vite.config.ts
13:18:31 vite.1 | error when starting dev server:
13:18:31 vite.1 | Error [ERR_MODULE_NOT_FOUND]: Cannot find package '@sveltejs/vite-plugin-svelte' imported from /Users/capripot/Developer/src/github.com/capripot/inertia-ssr2-test-ts/vite.config.ts.timestamp-1763846311646-4cf5869104465.mjs
13:18:31 vite.1 |     at Object.getPackageJSONURL (node:internal/modules/package_json_reader:267:9)
13:18:31 vite.1 |     at packageResolve (node:internal/modules/esm/resolve:768:81)
13:18:31 vite.1 |     at moduleResolve (node:internal/modules/esm/resolve:854:18)
13:18:31 vite.1 |     at defaultResolve (node:internal/modules/esm/resolve:984:11)
13:18:31 vite.1 |     at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:780:12)
13:18:31 vite.1 |     at #cachedDefaultResolve (node:internal/modules/esm/loader:704:25)
13:18:31 vite.1 |     at ModuleLoader.resolve (node:internal/modules/esm/loader:687:38)
13:18:31 vite.1 |     at ModuleLoader.getModuleJobForImport (node:internal/modules/esm/loader:305:38)
13:18:31 vite.1 |     at ModuleJob._link (node:internal/modules/esm/module_job:137:49)
13:18:31 vite.1 | exited with code 1

Because the packages for Svelte added during the generation are not compatible with vite@latest. It can be reproduced removing --silent flag from the line installing the packages:

$ npm add @inertiajs/svelte@latest svelte@5 @sveltejs/vite-plugin-svelte vite@latest

npm error code ERESOLVE
npm error ERESOLVE unable to resolve dependency tree
npm error
npm error While resolving: undefined@undefined
npm error Found: [email protected]
npm error node_modules/vite
npm error   dev vite@"7.2.4" from the root project
npm error
npm error Could not resolve dependency:
npm error peer vite@"^6.0.0" from @sveltejs/[email protected]
npm error node_modules/@sveltejs/vite-plugin-svelte
npm error   @sveltejs/vite-plugin-svelte@"*" from the root project
npm error
npm error Fix the upstream dependency conflict, or retry
npm error this command with --force or --legacy-peer-deps
npm error to accept an incorrect (and potentially broken) dependency resolution.
npm error
npm error
npm error For a full report see:
npm error /Users/capripot/Developer/src/github.com/capripot/inertia_rails/tmp/npm_cache/_logs/2025-11-23T03_54_09_412Z-eresolve-report.txt
npm error A complete log of this run can be found in: /Users/capripot/Developer/src/github.com/capripot/inertia_rails/tmp/npm_cache/_logs/2025-11-23T03_54_09_412Z-debug-0.log

Also, I think the generator should fail when npm is not able to install the packages. 😅

Copy link
Collaborator

Choose a reason for hiding this comment

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

Just tried to install svelte and it works absolutely fine to me, is there a chance you are using old-ish node version that doesn't support older vite/@sveltejs/vite-plugin-svelte etc?

rails -v
Rails 8.1.1

node -v
v22.20.0

# also steps that I used to try to repro:
rails new -J foo
cd foo
bundle add inertia_rails
bin/rails g inertia:install --vite --tailwind --typescript --framework=svelte
bin/dev

Copy link
Collaborator

Choose a reason for hiding this comment

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

If that's the case, it's still a bug, but a better fix is to batch all deps installation together in one step, I actually have this in the workings.

- "vite@5"
packages_ts:
- "@tsconfig/svelte@5"
- "svelte-check"
Expand Down