Add flag to dev server to disable HMR

This commit is contained in:
Jarred Sumner
2021-09-16 20:34:22 -07:00
parent 9e2910365a
commit d5186ee663
5 changed files with 2489 additions and 2330 deletions

1
src/api/schema.d.ts vendored
View File

@@ -468,6 +468,7 @@ type uint32 = number;
framework?: FrameworkConfig;
router?: RouteConfig;
no_summary?: boolean;
disable_hmr?: boolean;
}
export interface FileHandle {

View File

@@ -1707,6 +1707,10 @@ function decodeTransformOptions(bb) {
result["no_summary"] = !!bb.readByte();
break;
case 24:
result["disable_hmr"] = !!bb.readByte();
break;
default:
throw new Error("Attempted to parse invalid message");
}
@@ -1881,6 +1885,12 @@ bb.writeByte(encoded);
bb.writeByte(23);
bb.writeByte(value);
}
var value = message["disable_hmr"];
if (value != null) {
bb.writeByte(24);
bb.writeByte(value);
}
bb.writeByte(0);
}

View File

@@ -337,6 +337,8 @@ message TransformOptions {
FrameworkConfig framework = 21;
RouteConfig router = 22;
bool no_summary = 23;
bool disable_hmr = 24;
}
struct FileHandle {

File diff suppressed because it is too large Load Diff

View File

@@ -150,7 +150,7 @@ pub const Arguments = struct {
pub const ParamType = clap.Param(clap.Help);
const params: [24]ParamType = brk: {
const params: [25]ParamType = brk: {
@setEvalBranchQuota(9999);
break :brk [_]ParamType{
clap.parseParam("--use <STR> Choose a framework, e.g. \"--use next\". It checks first for a package named \"bun-framework-packagename\" and then \"packagename\".") catch unreachable,
@@ -158,6 +158,7 @@ pub const Arguments = struct {
clap.parseParam("--server-bunfile <STR> Use a .server.bun file (default: node_modules.server.bun)") catch unreachable,
clap.parseParam("--cwd <STR> Absolute path to resolve files & entry points from. This just changes the process' cwd.") catch unreachable,
clap.parseParam("--disable-react-fast-refresh Disable React Fast Refresh") catch unreachable,
clap.parseParam("--disable-hmr Disable Hot Module Reloading (disables fast refresh too)") catch unreachable,
clap.parseParam("--extension-order <STR>... defaults to: .tsx,.ts,.jsx,.js,.json ") catch unreachable,
clap.parseParam("--jsx-factory <STR> Changes the function called when compiling JSX elements using the classic JSX runtime") catch unreachable,
clap.parseParam("--jsx-fragment <STR> Changes the function called when compiling JSX fragments using the classic JSX runtime") catch unreachable,
@@ -239,6 +240,7 @@ pub const Arguments = struct {
.extension_order = args.options("--extension-order"),
.entry_points = undefined,
.no_summary = args.flag("--no-summary"),
.disable_hmr = args.flag("--disable-hmr"),
};
const print_help = args.flag("--help");