From 82603a296bed566e54becc6438468f509575d9a6 Mon Sep 17 00:00:00 2001 From: Logan McAnsh Date: Mon, 6 Mar 2023 18:25:06 -0500 Subject: [PATCH] chore: coerce react version, check for v0 releases Signed-off-by: Logan McAnsh --- packages/remix-dev/config.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/packages/remix-dev/config.ts b/packages/remix-dev/config.ts index f32f3e2b1b3..e08ca5aaf94 100644 --- a/packages/remix-dev/config.ts +++ b/packages/remix-dev/config.ts @@ -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"; @@ -461,8 +461,8 @@ 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( @@ -470,6 +470,11 @@ export async function readConfig( ); } + let reactVersion = + maybeReactVersion.major >= 18 || maybeReactVersion.raw === "0.0.0" + ? "18" + : "17"; + let serverRuntime = deps["@remix-run/deno"] ? "deno" : deps["@remix-run/cloudflare"]