Skip to content

Commit

Permalink
fix: vaadin/router added with react-router (#20522) (#20542)
Browse files Browse the repository at this point in the history
Exclude vaadin/router when runing
in react mode.
Without exclusion vaadin/router
gets added from the vaadin-core.json
package in platform.

Fixes #20496
  • Loading branch information
caalador authored Nov 25, 2024
1 parent e362efa commit b057f27
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ class VersionsJsonConverter {
* Mode value for dependency for all modes.
*/
public static final String MODE_ALL = "all"; // same as empty string
private static final Object VAADIN_ROUTER = "@vaadin/router";

private final JsonObject convertedObject;

Expand Down Expand Up @@ -151,6 +152,10 @@ private void addDependency(JsonObject obj) {
if (Objects.equals(npmName, VAADIN_CORE_NPM_PACKAGE)) {
return;
}
if (reactEnabled && Objects.equals(npmName, VAADIN_ROUTER)) {
exclusions.add(npmName);
return;
}
if (!isIncludedByMode(mode)) {
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,41 @@ public void reactRouterNotUsed_reactComponentsIgnored() {
convertedJson.getString("@polymer/iron-list"));
}

@Test
public void reactRouterUsed_noVaadinRouterAdded() {
String json = """
{
"core": {
"flow": {
"javaVersion": "3.0.0.alpha17"
},
},
"vaadin-router": {
"npmName": "@vaadin/router",
"jsVersion": "2.0.0"
},
"react": {
"react-components": {
"jsVersion": "24.4.0-alpha7",
"npmName": "@vaadin/react-components",
"mode": "react"
}
},
"platform": "foo"
}
""".formatted(VAADIN_CORE_NPM_PACKAGE);

VersionsJsonConverter convert = new VersionsJsonConverter(
Json.parse(json), true);
JsonObject convertedJson = convert.getConvertedJson();

Assert.assertFalse(
"Found @vaadin/router even though it should not be in use.",
convertedJson.hasKey("@vaadin/router"));
Assert.assertTrue("Missing react-components",
convertedJson.hasKey("@vaadin/react-components"));
}

@Test
public void testModeProperty() {
String json = """
Expand Down

0 comments on commit b057f27

Please sign in to comment.