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(dev): allow any mode (NODE_ENV) #7113

Merged
merged 2 commits into from
Aug 9, 2023
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
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