Skip to content

Commit

Permalink
fix(dev): allow any mode (NODE_ENV)
Browse files Browse the repository at this point in the history
  • Loading branch information
pcattori committed Aug 9, 2023
1 parent 002ed42 commit 5894f13
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 17 deletions.
5 changes: 5 additions & 0 deletions .changeset/wild-garlics-draw.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@remix-run/dev": patch
---

allow any mode (NODE_ENV)
21 changes: 5 additions & 16 deletions packages/remix-dev/cli/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,14 @@ export async function routes(

export async function build(
remixRoot: string,
modeArg?: string,
mode?: string,
sourcemap: boolean = false
): Promise<void> {
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,",
Expand Down Expand Up @@ -136,9 +136,9 @@ export async function build(

export async function watch(
remixRootOrConfig: string | RemixConfig,
modeArg?: string
mode?: string
): Promise<void> {
let mode = parseMode(modeArg) ?? "development";
mode = mode ?? "development";
console.log(`Watching Remix app in ${mode} mode...`);

let config =
Expand Down Expand Up @@ -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 (
Expand Down
2 changes: 1 addition & 1 deletion packages/remix-dev/compiler/options.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
type Mode = "development" | "production" | "test";

export type Options = {
mode: Mode;
mode: Mode | Omit<string, Mode>;
sourcemap: boolean;

REMIX_DEV_ORIGIN?: URL; // TODO: required in v2
Expand Down

0 comments on commit 5894f13

Please sign in to comment.