Skip to content

Commit d7bb739

Browse files
ZheSun88claude
andcommitted
fix: install pnpm deps in hoisted mode + declare @babel/types (#24288) (CP: 25.1)
Cherry-pick of d9290f8 from main. Adjusted for 25.1's dep-graph: @babel/types is pinned to 7.28.5 to match @babel/preset-react's version on this branch (main pins to 7.29.0 to match @babel/core which is not declared on 25.1). @babel/core and @babel/plugin-transform-react-jsx-development from the main commit are not added — they are not declared as direct deps on 25.1 and the React function location plugin only imports @babel/types. The .npmrc and FrontendTools changes that switch pnpm to hoisted mode apply unchanged. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 0648006 commit d7bb739

6 files changed

Lines changed: 19 additions & 3 deletions

File tree

‎flow-build-tools/src/main/java/com/vaadin/flow/server/frontend/FrontendTools.java‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,13 @@ public List<String> getPnpmExecutable() {
364364
List<String> pnpmCommand = getSuitablePnpm();
365365
assert !pnpmCommand.isEmpty();
366366
pnpmCommand = new ArrayList<>(pnpmCommand);
367-
pnpmCommand.add("--shamefully-hoist=true");
367+
// Force hoisted (flat npm-style) layout. CLI takes precedence over
368+
// .npmrc, so this is unambiguous even if the project lacks the
369+
// generated .npmrc. Replaces the previous --shamefully-hoist=true,
370+
// which only controls the partial-hoist heuristic on top of the
371+
// default isolated layout and did not consistently expose every
372+
// transitive at the project root.
373+
pnpmCommand.add("--config.node-linker=hoisted");
368374
return pnpmCommand;
369375
}
370376

‎flow-build-tools/src/test/java/com/vaadin/flow/server/frontend/FrontendToolsTest.java‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -379,8 +379,9 @@ void knownFaultyNpmVersionThrowsException() {
379379
@Test
380380
void getPnpmExecutable_executableIsAvailable() {
381381
List<String> executable = tools.getPnpmExecutable();
382-
// command line should contain --shamefully-hoist=true option
383-
assertTrue(executable.contains("--shamefully-hoist=true"));
382+
// command line should force hoisted node-linker so transitive
383+
// deps are always installed at the project root
384+
assertTrue(executable.contains("--config.node-linker=hoisted"));
384385
assertTrue(executable.stream().anyMatch(cmd -> cmd.contains("pnpm")));
385386
}
386387

‎flow-build-tools/src/test/java/com/vaadin/flow/server/frontend/NodeUpdaterTest.java‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ void getDefaultDevDependencies_includesAllDependencies_whenUsingVite() {
169169
expectedDependencies.add("transform-ast");
170170
expectedDependencies.add("strip-css-comments");
171171
expectedDependencies.add("@babel/preset-react");
172+
expectedDependencies.add("@babel/types");
172173
expectedDependencies.add("@types/react");
173174
expectedDependencies.add("@types/react-dom");
174175
expectedDependencies.add("@preact/signals-react-transform");

‎flow-build-tools/src/test/java/com/vaadin/flow/server/frontend/TaskRunPnpmInstallTest.java‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,7 @@ void runPnpmInstall_npmRcFileNotFound_newNpmRcFileIsGenerated()
227227
String content = FileUtils.readFileToString(npmRcFile,
228228
StandardCharsets.UTF_8);
229229
assertTrue(content.contains("shamefully-hoist"));
230+
assertTrue(content.contains("node-linker=hoisted"));
230231
}
231232

232233
@Test

‎flow-server/src/main/resources/com/vaadin/flow/server/frontend/dependencies/vite/package.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"@rollup/plugin-replace": "6.0.3",
1616
"@rollup/pluginutils": "5.3.0",
1717
"@babel/preset-react": "7.28.5",
18+
"@babel/types": "7.28.5",
1819
"rollup-plugin-visualizer": "7.0.1",
1920
"rollup-plugin-brotli": "3.1.0",
2021
"vite-plugin-checker": "0.12.0",

‎flow-server/src/main/resources/npmrc‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,11 @@
33
#
44
# This file sets the default parameters for manual `pnpm install`.
55
#
6+
# node-linker=hoisted produces a flat node_modules layout (like npm),
7+
# so every transitive dependency lives at the project root. Flow's
8+
# frontend tooling and bundled Vite plugins (e.g. the React function
9+
# location plugin) import transitive deps that pnpm's symlink-based
10+
# layout did not consistently hoist, even with shamefully-hoist=true.
11+
node-linker=hoisted
612
shamefully-hoist=true
713
strict-peer-dependencies=false

0 commit comments

Comments
 (0)