From 5894f13b71ccd8c1967d35269b6aaabcf602a10f Mon Sep 17 00:00:00 2001 From: Pedro Cattori Date: Wed, 9 Aug 2023 10:59:53 -0400 Subject: [PATCH] fix(dev): allow any mode (NODE_ENV) --- .changeset/wild-garlics-draw.md | 5 +++++ packages/remix-dev/cli/commands.ts | 21 +++++---------------- packages/remix-dev/compiler/options.ts | 2 +- 3 files changed, 11 insertions(+), 17 deletions(-) create mode 100644 .changeset/wild-garlics-draw.md diff --git a/.changeset/wild-garlics-draw.md b/.changeset/wild-garlics-draw.md new file mode 100644 index 00000000000..8df9966ad7e --- /dev/null +++ b/.changeset/wild-garlics-draw.md @@ -0,0 +1,5 @@ +--- +"@remix-run/dev": patch +--- + +allow any mode (NODE_ENV) diff --git a/packages/remix-dev/cli/commands.ts b/packages/remix-dev/cli/commands.ts index b7f801aaa39..bfea77aca67 100644 --- a/packages/remix-dev/cli/commands.ts +++ b/packages/remix-dev/cli/commands.ts @@ -91,14 +91,14 @@ export async function routes( export async function build( remixRoot: string, - modeArg?: string, + mode?: string, sourcemap: boolean = false ): Promise { - let mode = parseMode(modeArg) ?? "production"; + mode = mode ?? "production"; logger.info(`building...` + pc.gray(` (NODE_ENV=${mode})`)); - if (modeArg === "production" && sourcemap) { + if (mode === "production" && sourcemap) { logger.warn("🚨 source maps enabled in production", { details: [ "You are using `--sourcemap` to enable source maps in production,", @@ -136,9 +136,9 @@ export async function build( export async function watch( remixRootOrConfig: string | RemixConfig, - modeArg?: string + mode?: string ): Promise { - let mode = parseMode(modeArg) ?? "development"; + mode = mode ?? "development"; console.log(`Watching Remix app in ${mode} mode...`); let config = @@ -352,17 +352,6 @@ async function createClientEntry( return contents; } -let parseMode = ( - mode?: string -): compiler.CompileOptions["mode"] | undefined => { - if (mode === undefined) return undefined; - if (mode === "development") return mode; - if (mode === "production") return mode; - if (mode === "test") return mode; - console.error(`Unrecognized mode: ${mode}`); - process.exit(1); -}; - let findPort = async () => getPort({ port: makeRange(3001, 3100) }); let resolveDev = async ( diff --git a/packages/remix-dev/compiler/options.ts b/packages/remix-dev/compiler/options.ts index 2f85f6160e9..fe31834edd0 100644 --- a/packages/remix-dev/compiler/options.ts +++ b/packages/remix-dev/compiler/options.ts @@ -1,7 +1,7 @@ type Mode = "development" | "production" | "test"; export type Options = { - mode: Mode; + mode: Mode | Omit; sourcemap: boolean; REMIX_DEV_ORIGIN?: URL; // TODO: required in v2