Skip to content

fix: declare @babel/types so Vite config loads reliably#24289

Closed
vaadin-bot wants to merge 1 commit into24.10from
fix-babel-types-direct-dep-24.10
Closed

fix: declare @babel/types so Vite config loads reliably#24289
vaadin-bot wants to merge 1 commit into24.10from
fix-babel-types-direct-dep-24.10

Conversation

@vaadin-bot
Copy link
Copy Markdown
Collaborator

Summary

flow-server's Vite plugin react-function-location-plugin.js does
import * as t from '@babel/types';, but the bundled
vite/package.json only includes @babel/types transitively via
@babel/preset-react. With pnpm install --shamefully-hoist=true the
package is usually hoisted to the project's root node_modules
but hoisting is best-effort. When dep-graph drift leaves @babel/types
reachable only inside .pnpm/..., Node's ESM resolver doesn't see it
when loading vite.config.ts:

Error [ERR_MODULE_NOT_FOUND]: Cannot find package '@babel/types'
imported from .../vite-basics/node_modules/.vite-temp/vite.config.ts.timestamp-...mjs
failed to load config from .../vite.config.ts
[qtp...] ERROR com.vaadin.flow.server.DefaultErrorHandler -
   Unexpected error: Startup of Vite failed.

Vite fails to start → the Vaadin servlet can't fetch index.html → every
Selenium-driven test hangs waiting for a page that never loads, until
the surefire fork is killed by the step timeout. Symptom in CI: failsafe
prints T E S T S and then ~20 minutes of silence (e.g. it-tests (2)
on this run
).

Fix

  • Declare "@babel/types": "7.28.5" as an explicit devDependency in
    flow-server/.../dependencies/vite/package.json (pinned to match
    @babel/preset-react's version on 24.10). This puts @babel/types
    at the project root node_modules regardless of pnpm's hoisting
    decisions, so the plugin's ESM import always resolves.
  • Update NodeUpdaterTest's expected-set to include @babel/types,
    since the test asserts an exact match against
    getDefaultDevDependencies() which reads the same template.

Test plan

  • mvn -pl flow-server test -Dtest=NodeUpdaterTest passes.
  • mvn -pl flow-tests/test-frontend/vite-basics verify completes;
    the dev-server log no longer contains [UNRESOLVED_IMPORT] for
    @babel/types or failed to load config from .../vite.config.ts.
  • In a fresh project, generated package.json lists @babel/types
    under devDependencies.

🤖 Generated with Claude Code

The Vite plugin react-function-location-plugin.js imports @babel/types,
but the bundled vite/package.json only includes it transitively via
@babel/preset-react. With pnpm install --shamefully-hoist=true, the
package usually ends up at the project's root node_modules, but
hoisting is best-effort. When pnpm leaves @babel/types only inside
.pnpm/..., Node ESM cannot resolve it when loading vite.config.ts:
Vite fails to start, the Vaadin servlet cannot fetch index.html, and
Selenium tests hang waiting for pages that never load.

Declare @babel/types as an explicit devDependency at the same version
as @babel/preset-react so the package is always installed at the root.
Update NodeUpdaterTest's expected-set accordingly.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@github-actions github-actions Bot added the +0.0.1 label May 7, 2026
@vaadin-bot
Copy link
Copy Markdown
Collaborator Author

This PR is eligible for auto-merging policy, so it has been approved automatically. If there are pending conditions, auto merge (with 'squash' method) has been enabled for this PR [Message is sent from bot]

@vaadin-bot
Copy link
Copy Markdown
Collaborator Author

This PR is eligible for auto-merging policy, so it has been approved automatically. If there are pending conditions, auto merge (with 'squash' method) has been enabled for this PR[Message is sent from bot]

@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented May 7, 2026

@ZheSun88 ZheSun88 marked this pull request as ready for review May 7, 2026 14:34
@ZheSun88 ZheSun88 marked this pull request as draft May 7, 2026 14:35
@Artur- Artur- closed this May 8, 2026
ZheSun88 added a commit that referenced this pull request May 8, 2026
… (CP: 24.10) (#24297)

Cherry-pick of #24288 (commit d9290f8) from main to 24.10.

## Summary

Same fix as #24288: switches pnpm install to hoisted (flat npm-style)
layout so transitive npm deps (`@babel/types`, `@lit/reactive-element`,
`cookie`, `set-cookie-parser`, `@preact/signals-react/runtime`) are
always reachable from project root, eliminating the `vite-basics` IT
hang and similar symptoms.

## Adjustments for 24.10

24.10 is pre-`flow-build-tools` refactor (#23161), so all the Java
files the original commit touches (`FrontendTools.java`,
`FrontendToolsTest.java`, `NodeUpdaterTest.java`,
`TaskRunPnpmInstallTest.java`) live under `flow-server/` here. The
edits are otherwise identical.

Two version adjustments to match this branch's dep graph:

1. **`@babel/types` pinned to `7.28.5`** (matching
`@babel/preset-react`)
   instead of main's `7.29.0`. 24.10 does not declare `@babel/core`,
   so version coherence is anchored to `preset-react`.

2. **Skipped `@babel/core` and
`@babel/plugin-transform-react-jsx-development`**
   declarations from the main commit — not declared as direct deps on
   24.10, and the React function location plugin only imports
   `@babel/types`.

## Supersedes #24289

This PR replaces #24289 (the narrower @babel/types-only fix). Once
this lands, #24289 should be closed.

## Test plan

- [ ] CI on this PR passes (specifically `it-tests (1)` and `it-tests
(2)`).
- [ ] `mvn -pl flow-server test
-Dtest=NodeUpdaterTest,TaskRunPnpmInstallTest,FrontendToolsTest` passes.
- [ ] After install in any vite-using IT module, `node_modules/.pnpm/`
does not exist (or is empty); `node_modules/@babel/types/` and
`node_modules/@lit/reactive-element/` exist as real directories at the
project root.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Zhe Sun <zhe@vaadin.com>
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants