Skip to content

Commit

Permalink
chore: coerce react version, check for v0 releases
Browse files Browse the repository at this point in the history
Signed-off-by: Logan McAnsh <logan@mcan.sh>
  • Loading branch information
mcansh committed Mar 6, 2023
1 parent b635550 commit 82603a2
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions packages/remix-dev/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { pathToFileURL } from "node:url";
import fse from "fs-extra";
import getPort from "get-port";
import NPMCliPackageJson from "@npmcli/package-json";
import { lte } from "semver";
import { coerce } from "semver";

import type { RouteManifest, DefineRoutesFunction } from "./config/routes";
import { defineRoutes } from "./config/routes";
Expand Down Expand Up @@ -461,15 +461,20 @@ export async function readConfig(
let pkgJson = await NPMCliPackageJson.load(remixRoot);
let deps = pkgJson.content.dependencies ?? {};

let reactVersion = lte(deps.react, "18.0.0") ? "17" : "18";
if (!reactVersion) {
let maybeReactVersion = coerce(deps.react);
if (!maybeReactVersion) {
let react = ["react", "react-dom"];
let list = conjunctionListFormat(react);
throw new Error(
`Could not determine React version. Please install the following packages: ${list}`
);
}

let reactVersion =
maybeReactVersion.major >= 18 || maybeReactVersion.raw === "0.0.0"
? "18"
: "17";

let serverRuntime = deps["@remix-run/deno"]
? "deno"
: deps["@remix-run/cloudflare"]
Expand Down

0 comments on commit 82603a2

Please sign in to comment.