fix: declare @babel/types so Vite config loads reliably#24289
Closed
vaadin-bot wants to merge 1 commit into24.10from
Closed
fix: declare @babel/types so Vite config loads reliably#24289vaadin-bot wants to merge 1 commit into24.10from
vaadin-bot wants to merge 1 commit into24.10from
Conversation
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>
vaadin-review-bot
approved these changes
May 7, 2026
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-review-bot
approved these changes
May 7, 2026
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] |
|
3 tasks
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Summary
flow-server's Vite pluginreact-function-location-plugin.jsdoesimport * as t from '@babel/types';, but the bundledvite/package.jsononly includes@babel/typestransitively via@babel/preset-react. Withpnpm install --shamefully-hoist=truethepackage is usually hoisted to the project's root
node_modules—but hoisting is best-effort. When dep-graph drift leaves
@babel/typesreachable only inside
.pnpm/..., Node's ESM resolver doesn't see itwhen loading
vite.config.ts: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 Sand then ~20 minutes of silence (e.g.it-tests (2)on this run).
Fix
"@babel/types": "7.28.5"as an explicitdevDependencyinflow-server/.../dependencies/vite/package.json(pinned to match@babel/preset-react's version on 24.10). This puts@babel/typesat the project root
node_modulesregardless of pnpm's hoistingdecisions, so the plugin's ESM import always resolves.
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=NodeUpdaterTestpasses.mvn -pl flow-tests/test-frontend/vite-basics verifycompletes;the dev-server log no longer contains
[UNRESOLVED_IMPORT]for@babel/typesorfailed to load config from .../vite.config.ts.package.jsonlists@babel/typesunder
devDependencies.🤖 Generated with Claude Code