Skip to content

Commit

Permalink
fix: vaadin/router added with react-router (#20522)
Browse files Browse the repository at this point in the history
* fix: vaadin/router added with react-router

Exclude vaadin/router when runing
in react mode.
Without exclusion vaadin/router
gets added from the vaadin-core.json
package in platform.

Fixes #20496

* Test filtering of vaadin/router

---------

Co-authored-by: Mikhail Shabarov <[email protected]>
  • Loading branch information
caalador and mshabarov authored Nov 21, 2024
1 parent 69e47a5 commit 5415b3b
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 @@ -70,6 +70,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 @@ -161,6 +162,10 @@ private void addDependency(JsonObject obj) {
exclusions.add(npmName);
return;
}
if (reactEnabled && Objects.equals(npmName, VAADIN_ROUTER)) {
exclusions.add(npmName);
return;
}
if (!isIncludedByMode(mode)) {
if (excludeWebComponents) {
// collecting exclusions also from non-included dependencies
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, false);
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 5415b3b

Please sign in to comment.