Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: vaadin/router added with react-router (#20522) (CP: 24.5) #20542

Merged
merged 1 commit into from
Nov 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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