Vite.js build errors during background java compilation

The Vaadin frontend build via Vite often causes problems when working with AI coding agents:

My usual approach these days is as follows:

  • I have IntelliJ IDEA open to edit the Java code

  • The Spring Boot Vaadin app is also launched within IDEA

  • I use the Claude Code CLI

  • This results in files being modified, and Claude Code compiles them automatically

  • At the same time, the Vaadin devServer goes haywire because it claims files are no longer present:

[vite] Internal server error: Failed to resolve import ‘./index’ from ‘src/main/frontend/generated/vaadin.ts’. Does the file exist?

  • However, these frontend-related files should not be affected at all by the parallel compilation initiated by Claude Code.

  • Even after the Claude Code compilation has finished, the application is no longer usable because the Vite-based front-end build only throws errors and does not terminate

The application must be restarted.

How can this problem be resolved?

Is this due to the configuration of the Vite build? Can it be defined here which file changes it should only react to?

 11:21:25 [vite] (client) page reload generated/vaadin.ts
 11:21:25 [vite] (client) hmr update /generated/vaadin-react.tsx
 11:21:25 [vite] (client) hmr update /generated/index.tsx
 11:21:25 [vite] (client) page reload generated/vite-devmode.ts
 11:21:25 [vite] (client) hmr update /generated/flow/Flow.tsx
 11:21:25 [vite] (client) hmr invalidate /generated/flow/Flow.tsx Could not Fast Refresh ("loadComponentScript" export is incompatible). Learn more at https://github.com/vitejs/vite-plugin-react/tree/main/packages/plugin-react#consistent-components-exports
 11:21:25 [vite] (client) page reload generated/flow/Flow.tsx
 11:21:26 [vite] (client) Pre-transform error: Failed to load url /generated/vite-devmode.ts (resolved id: /XXXX/.worktree/nfc/src/main/frontend/generated/vite-devmode.ts). Does the file exist?
 11:21:26 [vite] (client) Pre-transform error: Failed to resolve import "./index" from "src/main/frontend/generated/vaadin.ts". Does the file exist?

Hi Dominik,

We’re looking into this.

-Petter-

This was a problem in Flow. Fix: fix: write generated frontend files atomically by totally-not-ai[bot] · Pull Request #24667 · vaadin/flow · GitHub

-Petter-

Thanks for this fast response :grinning:
But why those files are re-generated when Java runs is in the background (IDE or agent) without any frontend related changes. I assume , it’s hard to detect that there aren’t such frontend related changes, isn’t it ?

Kind ragrds
Dominik

I take a look at the commit you mentioned @ GitHub:

Maybe it’s a kind of improvement to move the new written file only if it differs from the existing one (via checksum diff) ?:thinking:

Out of curiosity: is it a gradle project?

Nope, Maven 3.9.14 + Vaadin25 + Java25

Who actually compiles the files and how? Does Claude Code really run something - in that case what?

In my case mvn compile

Who actually compiles the files and how?

Claude Code is instructed to compile the files.

Does Claude Code really run something - in that case what?

Therefore, mvn compile is used

It’s printed in the logs, you can see the newly created *.class files, and -in the case the vite process didn’t run amok- one can see the result in the browser immediately

The issue I’m having right now is that compile also runs flow:prepare-frontend, which deletes a number of frontend files that are in use by an app that runs with hot deploy enabled. The problem seems to be that starting an app with hotdeploy generates a different set of frontend files than just running flow:prepare-frontend on its own.

The files that are removed are: vite-devmode.ts, index.tsx, vaadin-react.tsx, layouts.json, ReactAdapter.tsx

There might be more depending on configuration.

Edit: Created a PR, though it looks quite hacky: fix: prevent deletion of dev-server generated files by cleanup task by sissbruecker · Pull Request #24677 · vaadin/flow · GitHub

One potential cause could be setting the frontend hotdeploy configuration only in application.properties and not in the maven plugin configuration as well

In my case I’m passing the hotdeploy option through the command line when starting the app:

mvn package jetty:run -Dvaadin.pnpm.enable -Dvaadin.frontend.hotdeploy=true -am -B -q -DskipTests -pl vaadin-button-flow-parent/vaadin-button-flow-integration-tests