aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--examples/hello-next/pages/posts/[id].tsx2
-rw-r--r--src/api/schema.d.ts2
-rw-r--r--src/api/schema.js18
-rw-r--r--src/api/schema.peechy2
-rw-r--r--src/api/schema.zig3835
-rw-r--r--src/bundler.zig54
-rw-r--r--src/fallback.ts13
-rw-r--r--src/fallback.version2
-rw-r--r--src/feature_flags.zig2
-rw-r--r--src/global.zig11
-rw-r--r--src/http.zig122
-rw-r--r--src/javascript/jsc/bindings/ZigGlobalObject.cpp2
-rw-r--r--src/javascript/jsc/bindings/exports.zig17
-rw-r--r--src/javascript/jsc/javascript.zig46
-rw-r--r--src/javascript/jsc/webcore/response.zig16
-rw-r--r--src/js_parser/js_parser.zig6
-rw-r--r--src/js_printer.zig6
-rw-r--r--src/linker.zig3
-rw-r--r--src/main.zig4
-rw-r--r--src/options.zig4
-rw-r--r--src/renamer.zig3
-rw-r--r--src/resolver/package_json.zig8
-rw-r--r--src/router.zig26
-rw-r--r--src/test/fixtures/default_export_hmr_identifier_ref.tsx5
-rw-r--r--src/test/fixtures/keyword-in-property-binding.tsx8
25 files changed, 2162 insertions, 2055 deletions
diff --git a/examples/hello-next/pages/posts/[id].tsx b/examples/hello-next/pages/posts/[id].tsx
index 48413669c..bf795ae83 100644
--- a/examples/hello-next/pages/posts/[id].tsx
+++ b/examples/hello-next/pages/posts/[id].tsx
@@ -3,7 +3,7 @@ import Link from "next/link";
export default function Post({}) {
const router = useRouter();
-
+
return (
<div style={{ padding: 16 }}>
<h1>Post: {router.query.id}</h1>
diff --git a/src/api/schema.d.ts b/src/api/schema.d.ts
index d7e66820e..224b2be8f 100644
--- a/src/api/schema.d.ts
+++ b/src/api/schema.d.ts
@@ -399,6 +399,7 @@ type uint32 = number;
fallback?: FrameworkEntryPointMessage;
development?: boolean;
client_css_in_js?: CSSInJSBehavior;
+ display_name?: string;
}
export interface FrameworkEntryPoint {
@@ -420,6 +421,7 @@ type uint32 = number;
export interface LoadedFramework {
package: string;
+ display_name: string;
development: boolean;
entry_points: FrameworkEntryPointMap;
client_css_in_js: CSSInJSBehavior;
diff --git a/src/api/schema.js b/src/api/schema.js
index 73e7e20c7..2600ee1d4 100644
--- a/src/api/schema.js
+++ b/src/api/schema.js
@@ -1212,6 +1212,10 @@ function decodeFrameworkConfig(bb) {
result["client_css_in_js"] = CSSInJSBehavior[bb.readByte()];
break;
+ case 7:
+ result["display_name"] = bb.readString();
+ break;
+
default:
throw new Error("Attempted to parse invalid message");
}
@@ -1257,6 +1261,12 @@ function encodeFrameworkConfig(message, bb) {
if (encoded === void 0) throw new Error("Invalid value " + JSON.stringify(value) + " for enum \"CSSInJSBehavior\"");
bb.writeByte(encoded);
}
+
+ var value = message["display_name"];
+ if (value != null) {
+ bb.writeByte(7);
+ bb.writeString(value);
+ }
bb.writeByte(0);
}
@@ -1389,6 +1399,7 @@ function decodeLoadedFramework(bb) {
var result = {};
result["package"] = bb.readString();
+ result["display_name"] = bb.readString();
result["development"] = !!bb.readByte();
result["entry_points"] = decodeFrameworkEntryPointMap(bb);
result["client_css_in_js"] = CSSInJSBehavior[bb.readByte()];
@@ -1404,6 +1415,13 @@ function encodeLoadedFramework(message, bb) {
throw new Error("Missing required field \"package\"");
}
+ var value = message["display_name"];
+ if (value != null) {
+ bb.writeString(value);
+ } else {
+ throw new Error("Missing required field \"display_name\"");
+ }
+
var value = message["development"];
if (value != null) {
bb.writeByte(value);
diff --git a/src/api/schema.peechy b/src/api/schema.peechy
index 3b7b2669e..7aa7ba6c4 100644
--- a/src/api/schema.peechy
+++ b/src/api/schema.peechy
@@ -254,6 +254,7 @@ message FrameworkConfig {
bool development = 5;
CSSInJSBehavior client_css_in_js = 6;
+ string display_name = 7;
}
struct FrameworkEntryPoint {
@@ -275,6 +276,7 @@ message FrameworkEntryPointMessage {
struct LoadedFramework {
string package;
+ string display_name;
bool development;
FrameworkEntryPointMap entry_points;
CSSInJSBehavior client_css_in_js;
diff --git a/src/api/schema.zig b/src/api/schema.zig
index bd0873540..b8e0dc6d0 100644
--- a/src/api/schema.zig
+++ b/src/api/schema.zig
@@ -1,4 +1,3 @@
-
const std = @import("std");
pub const Reader = struct {
@@ -282,2440 +281,2322 @@ pub fn Writer(comptime WritableStream: type) type {
pub const ByteWriter = Writer(*std.io.FixedBufferStream([]u8));
pub const FileWriter = Writer(std.fs.File);
+pub const Api = struct {
+ pub const Loader = enum(u8) {
+ _none,
+ /// jsx
+ jsx,
+ /// js
+ js,
+ /// ts
+ ts,
-pub const Api = struct {
-
-pub const Loader = enum(u8) {
-
-_none,
- /// jsx
- jsx,
-
- /// js
- js,
-
- /// ts
- ts,
-
- /// tsx
- tsx,
-
- /// css
- css,
-
- /// file
- file,
-
- /// json
- json,
-
-_,
-
- pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void {
- return try std.json.stringify(@tagName(self), opts, o);
- }
-
-
-};
-
-pub const FrameworkEntryPointType = enum(u8) {
-
-_none,
- /// client
- client,
-
- /// server
- server,
-
- /// fallback
- fallback,
-
-_,
-
- pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void {
- return try std.json.stringify(@tagName(self), opts, o);
- }
-
-
-};
-
-pub const StackFrameScope = enum(u8) {
-
-_none,
- /// Eval
- eval,
+ /// tsx
+ tsx,
- /// Module
- module,
+ /// css
+ css,
- /// Function
- function,
+ /// file
+ file,
- /// Global
- global,
-
- /// Wasm
- wasm,
-
- /// Constructor
- constructor,
-
-_,
-
- pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void {
- return try std.json.stringify(@tagName(self), opts, o);
- }
+ /// json
+ json,
-
-};
+ _,
-pub const StackFrame = struct {
-/// function_name
-function_name: []const u8,
+ pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void {
+ return try std.json.stringify(@tagName(self), opts, o);
+ }
+ };
-/// file
-file: []const u8,
+ pub const FrameworkEntryPointType = enum(u8) {
+ _none,
+ /// client
+ client,
-/// position
-position: StackFramePosition,
+ /// server
+ server,
-/// scope
-scope: StackFrameScope,
+ /// fallback
+ fallback,
+ _,
-pub fn decode(reader: anytype) anyerror!StackFrame {
- var this = std.mem.zeroes(StackFrame);
+ pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void {
+ return try std.json.stringify(@tagName(self), opts, o);
+ }
+ };
- this.function_name = try reader.readValue([]const u8);
- this.file = try reader.readValue([]const u8);
- this.position = try reader.readValue(StackFramePosition);
- this.scope = try reader.readValue(StackFrameScope);
- return this;
-}
+ pub const StackFrameScope = enum(u8) {
+ _none,
+ /// Eval
+ eval,
-pub fn encode(this: *const @This(), writer: anytype) anyerror!void {
- try writer.writeValue(this.function_name);
- try writer.writeValue(this.file);
- try writer.writeValue(this.position);
- try writer.writeEnum(this.scope);
-}
+ /// Module
+ module,
-};
+ /// Function
+ function,
-pub const StackFramePosition = packed struct {
-/// source_offset
-source_offset: i32 = 0,
+ /// Global
+ global,
-/// line
-line: i32 = 0,
+ /// Wasm
+ wasm,
-/// line_start
-line_start: i32 = 0,
+ /// Constructor
+ constructor,
-/// line_stop
-line_stop: i32 = 0,
+ _,
-/// column_start
-column_start: i32 = 0,
+ pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void {
+ return try std.json.stringify(@tagName(self), opts, o);
+ }
+ };
-/// column_stop
-column_stop: i32 = 0,
+ pub const StackFrame = struct {
+ /// function_name
+ function_name: []const u8,
-/// expression_start
-expression_start: i32 = 0,
+ /// file
+ file: []const u8,
-/// expression_stop
-expression_stop: i32 = 0,
+ /// position
+ position: StackFramePosition,
+ /// scope
+ scope: StackFrameScope,
-pub fn decode(reader: anytype) anyerror!StackFramePosition {
- var this = std.mem.zeroes(StackFramePosition);
+ pub fn decode(reader: anytype) anyerror!StackFrame {
+ var this = std.mem.zeroes(StackFrame);
- this.source_offset = try reader.readValue(i32);
- this.line = try reader.readValue(i32);
- this.line_start = try reader.readValue(i32);
- this.line_stop = try reader.readValue(i32);
- this.column_start = try reader.readValue(i32);
- this.column_stop = try reader.readValue(i32);
- this.expression_start = try reader.readValue(i32);
- this.expression_stop = try reader.readValue(i32);
- return this;
-}
+ this.function_name = try reader.readValue([]const u8);
+ this.file = try reader.readValue([]const u8);
+ this.position = try reader.readValue(StackFramePosition);
+ this.scope = try reader.readValue(StackFrameScope);
+ return this;
+ }
-pub fn encode(this: *const @This(), writer: anytype) anyerror!void {
- try writer.writeInt(this.source_offset);
- try writer.writeInt(this.line);
- try writer.writeInt(this.line_start);
- try writer.writeInt(this.line_stop);
- try writer.writeInt(this.column_start);
- try writer.writeInt(this.column_stop);
- try writer.writeInt(this.expression_start);
- try writer.writeInt(this.expression_stop);
-}
+ pub fn encode(this: *const @This(), writer: anytype) anyerror!void {
+ try writer.writeValue(this.function_name);
+ try writer.writeValue(this.file);
+ try writer.writeValue(this.position);
+ try writer.writeEnum(this.scope);
+ }
+ };
-};
+ pub const StackFramePosition = packed struct {
+ /// source_offset
+ source_offset: i32 = 0,
-pub const SourceLine = struct {
-/// line
-line: i32 = 0,
+ /// line
+ line: i32 = 0,
-/// text
-text: []const u8,
+ /// line_start
+ line_start: i32 = 0,
+ /// line_stop
+ line_stop: i32 = 0,
-pub fn decode(reader: anytype) anyerror!SourceLine {
- var this = std.mem.zeroes(SourceLine);
+ /// column_start
+ column_start: i32 = 0,
- this.line = try reader.readValue(i32);
- this.text = try reader.readValue([]const u8);
- return this;
-}
+ /// column_stop
+ column_stop: i32 = 0,
-pub fn encode(this: *const @This(), writer: anytype) anyerror!void {
- try writer.writeInt(this.line);
- try writer.writeValue(this.text);
-}
+ /// expression_start
+ expression_start: i32 = 0,
-};
+ /// expression_stop
+ expression_stop: i32 = 0,
-pub const StackTrace = struct {
-/// source_lines
-source_lines: []const SourceLine,
+ pub fn decode(reader: anytype) anyerror!StackFramePosition {
+ var this = std.mem.zeroes(StackFramePosition);
-/// frames
-frames: []const StackFrame,
+ this.source_offset = try reader.readValue(i32);
+ this.line = try reader.readValue(i32);
+ this.line_start = try reader.readValue(i32);
+ this.line_stop = try reader.readValue(i32);
+ this.column_start = try reader.readValue(i32);
+ this.column_stop = try reader.readValue(i32);
+ this.expression_start = try reader.readValue(i32);
+ this.expression_stop = try reader.readValue(i32);
+ return this;
+ }
+ pub fn encode(this: *const @This(), writer: anytype) anyerror!void {
+ try writer.writeInt(this.source_offset);
+ try writer.writeInt(this.line);
+ try writer.writeInt(this.line_start);
+ try writer.writeInt(this.line_stop);
+ try writer.writeInt(this.column_start);
+ try writer.writeInt(this.column_stop);
+ try writer.writeInt(this.expression_start);
+ try writer.writeInt(this.expression_stop);
+ }
+ };
-pub fn decode(reader: anytype) anyerror!StackTrace {
- var this = std.mem.zeroes(StackTrace);
+ pub const SourceLine = struct {
+ /// line
+ line: i32 = 0,
- this.source_lines = try reader.readArray(SourceLine);
- this.frames = try reader.readArray(StackFrame);
- return this;
-}
+ /// text
+ text: []const u8,
-pub fn encode(this: *const @This(), writer: anytype) anyerror!void {
- try writer.writeArray(SourceLine, this.source_lines);
- try writer.writeArray(StackFrame, this.frames);
-}
+ pub fn decode(reader: anytype) anyerror!SourceLine {
+ var this = std.mem.zeroes(SourceLine);
-};
+ this.line = try reader.readValue(i32);
+ this.text = try reader.readValue([]const u8);
+ return this;
+ }
-pub const JsException = struct {
-/// name
-name: ?[]const u8 = null,
-
-/// message
-message: ?[]const u8 = null,
-
-/// runtime_type
-runtime_type: ?u16 = null,
-
-/// code
-code: ?u8 = null,
-
-/// stack
-stack: ?StackTrace = null,
-
-
-pub fn decode(reader: anytype) anyerror!JsException {
- var this = std.mem.zeroes(JsException);
-
- while(true) {
- switch (try reader.readByte()) {
- 0 => { return this; },
-
- 1 => {
- this.name = try reader.readValue([]const u8);
-},
- 2 => {
- this.message = try reader.readValue([]const u8);
-},
- 3 => {
- this.runtime_type = try reader.readValue(u16);
-},
- 4 => {
- this.code = try reader.readValue(u8);
-},
- 5 => {
- this.stack = try reader.readValue(StackTrace);
-},
- else => {
- return error.InvalidMessage;
- },
- }
- }
-unreachable;
-}
+ pub fn encode(this: *const @This(), writer: anytype) anyerror!void {
+ try writer.writeInt(this.line);
+ try writer.writeValue(this.text);
+ }
+ };
-pub fn encode(this: *const @This(), writer: anytype) anyerror!void {
-if (this.name) |name| {
- try writer.writeFieldID(1);
- try writer.writeValue(name);
-}
-if (this.message) |message| {
- try writer.writeFieldID(2);
- try writer.writeValue(message);
-}
-if (this.runtime_type) |runtime_type| {
- try writer.writeFieldID(3);
- try writer.writeInt(runtime_type);
-}
-if (this.code) |code| {
- try writer.writeFieldID(4);
- try writer.writeInt(code);
-}
-if (this.stack) |stack| {
- try writer.writeFieldID(5);
- try writer.writeValue(stack);
-}
-try writer.endMessage();
-}
+ pub const StackTrace = struct {
+ /// source_lines
+ source_lines: []const SourceLine,
-};
+ /// frames
+ frames: []const StackFrame,
-pub const FallbackStep = enum(u8) {
+ pub fn decode(reader: anytype) anyerror!StackTrace {
+ var this = std.mem.zeroes(StackTrace);
-_none,
- /// ssr_disabled
- ssr_disabled,
+ this.source_lines = try reader.readArray(SourceLine);
+ this.frames = try reader.readArray(StackFrame);
+ return this;
+ }
- /// create_vm
- create_vm,
+ pub fn encode(this: *const @This(), writer: anytype) anyerror!void {
+ try writer.writeArray(SourceLine, this.source_lines);
+ try writer.writeArray(StackFrame, this.frames);
+ }
+ };
- /// configure_router
- configure_router,
+ pub const JsException = struct {
+ /// name
+ name: ?[]const u8 = null,
- /// configure_defines
- configure_defines,
+ /// message
+ message: ?[]const u8 = null,
- /// resolve_entry_point
- resolve_entry_point,
+ /// runtime_type
+ runtime_type: ?u16 = null,
- /// load_entry_point
- load_entry_point,
+ /// code
+ code: ?u8 = null,
- /// eval_entry_point
- eval_entry_point,
+ /// stack
+ stack: ?StackTrace = null,
- /// fetch_event_handler
- fetch_event_handler,
+ pub fn decode(reader: anytype) anyerror!JsException {
+ var this = std.mem.zeroes(JsException);
-_,
+ while (true) {
+ switch (try reader.readByte()) {
+ 0 => {
+ return this;
+ },
- pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void {
- return try std.json.stringify(@tagName(self), opts, o);
+ 1 => {
+ this.name = try reader.readValue([]const u8);
+ },
+ 2 => {
+ this.message = try reader.readValue([]const u8);
+ },
+ 3 => {
+ this.runtime_type = try reader.readValue(u16);
+ },
+ 4 => {
+ this.code = try reader.readValue(u8);
+ },
+ 5 => {
+ this.stack = try reader.readValue(StackTrace);
+ },
+ else => {
+ return error.InvalidMessage;
+ },
}
+ }
+ unreachable;
+ }
-
-};
-
-pub const Problems = struct {
-/// code
-code: u16 = 0,
-
-/// name
-name: []const u8,
-
-/// exceptions
-exceptions: []const JsException,
-
-/// build
-build: Log,
+ pub fn encode(this: *const @This(), writer: anytype) anyerror!void {
+ if (this.name) |name| {
+ try writer.writeFieldID(1);
+ try writer.writeValue(name);
+ }
+ if (this.message) |message| {
+ try writer.writeFieldID(2);
+ try writer.writeValue(message);
+ }
+ if (this.runtime_type) |runtime_type| {
+ try writer.writeFieldID(3);
+ try writer.writeInt(runtime_type);
+ }
+ if (this.code) |code| {
+ try writer.writeFieldID(4);
+ try writer.writeInt(code);
+ }
+ if (this.stack) |stack| {
+ try writer.writeFieldID(5);
+ try writer.writeValue(stack);
+ }
+ try writer.endMessage();
+ }
+ };
+ pub const FallbackStep = enum(u8) {
+ _none,
+ /// ssr_disabled
+ ssr_disabled,
-pub fn decode(reader: anytype) anyerror!Problems {
- var this = std.mem.zeroes(Problems);
+ /// create_vm
+ create_vm,
- this.code = try reader.readValue(u16);
- this.name = try reader.readValue([]const u8);
- this.exceptions = try reader.readArray(JsException);
- this.build = try reader.readValue(Log);
- return this;
-}
+ /// configure_router
+ configure_router,
-pub fn encode(this: *const @This(), writer: anytype) anyerror!void {
- try writer.writeInt(this.code);
- try writer.writeValue(this.name);
- try writer.writeArray(JsException, this.exceptions);
- try writer.writeValue(this.build);
-}
+ /// configure_defines
+ configure_defines,
-};
+ /// resolve_entry_point
+ resolve_entry_point,
-pub const Router = struct {
-/// routes
-routes: []const []const u8,
+ /// load_entry_point
+ load_entry_point,
-/// route
-route: i32 = 0,
+ /// eval_entry_point
+ eval_entry_point,
-/// params
-params: StringMap,
+ /// fetch_event_handler
+ fetch_event_handler,
+ _,
-pub fn decode(reader: anytype) anyerror!Router {
- var this = std.mem.zeroes(Router);
+ pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void {
+ return try std.json.stringify(@tagName(self), opts, o);
+ }
+ };
- this.routes = try reader.readArray([]const u8);
- this.route = try reader.readValue(i32);
- this.params = try reader.readValue(StringMap);
- return this;
-}
+ pub const Problems = struct {
+ /// code
+ code: u16 = 0,
-pub fn encode(this: *const @This(), writer: anytype) anyerror!void {
- try writer.writeArray([]const u8, this.routes);
- try writer.writeInt(this.route);
- try writer.writeValue(this.params);
-}
+ /// name
+ name: []const u8,
-};
+ /// exceptions
+ exceptions: []const JsException,
-pub const FallbackMessageContainer = struct {
-/// message
-message: ?[]const u8 = null,
-
-/// router
-router: ?Router = null,
-
-/// reason
-reason: ?FallbackStep = null,
-
-/// problems
-problems: ?Problems = null,
-
-
-pub fn decode(reader: anytype) anyerror!FallbackMessageContainer {
- var this = std.mem.zeroes(FallbackMessageContainer);
-
- while(true) {
- switch (try reader.readByte()) {
- 0 => { return this; },
-
- 1 => {
- this.message = try reader.readValue([]const u8);
-},
- 2 => {
- this.router = try reader.readValue(Router);
-},
- 3 => {
- this.reason = try reader.readValue(FallbackStep);
-},
- 4 => {
- this.problems = try reader.readValue(Problems);
-},
- else => {
- return error.InvalidMessage;
- },
- }
- }
-unreachable;
-}
+ /// build
+ build: Log,
-pub fn encode(this: *const @This(), writer: anytype) anyerror!void {
-if (this.message) |message| {
- try writer.writeFieldID(1);
- try writer.writeValue(message);
-}
-if (this.router) |router| {
- try writer.writeFieldID(2);
- try writer.writeValue(router);
-}
-if (this.reason) |reason| {
- try writer.writeFieldID(3);
- try writer.writeEnum(reason);
-}
-if (this.problems) |problems| {
- try writer.writeFieldID(4);
- try writer.writeValue(problems);
-}
-try writer.endMessage();
-}
+ pub fn decode(reader: anytype) anyerror!Problems {
+ var this = std.mem.zeroes(Problems);
-};
+ this.code = try reader.readValue(u16);
+ this.name = try reader.readValue([]const u8);
+ this.exceptions = try reader.readArray(JsException);
+ this.build = try reader.readValue(Log);
+ return this;
+ }
-pub const ResolveMode = enum(u8) {
+ pub fn encode(this: *const @This(), writer: anytype) anyerror!void {
+ try writer.writeInt(this.code);
+ try writer.writeValue(this.name);
+ try writer.writeArray(JsException, this.exceptions);
+ try writer.writeValue(this.build);
+ }
+ };
-_none,
- /// disable
- disable,
+ pub const Router = struct {
+ /// routes
+ routes: []const []const u8,
- /// lazy
- lazy,
+ /// route
+ route: i32 = 0,
- /// dev
- dev,
+ /// params
+ params: StringMap,
- /// bundle
- bundle,
+ pub fn decode(reader: anytype) anyerror!Router {
+ var this = std.mem.zeroes(Router);
-_,
+ this.routes = try reader.readArray([]const u8);
+ this.route = try reader.readValue(i32);
+ this.params = try reader.readValue(StringMap);
+ return this;
+ }
- pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void {
- return try std.json.stringify(@tagName(self), opts, o);
- }
+ pub fn encode(this: *const @This(), writer: anytype) anyerror!void {
+ try writer.writeArray([]const u8, this.routes);
+ try writer.writeInt(this.route);
+ try writer.writeValue(this.params);
+ }
+ };
-
-};
+ pub const FallbackMessageContainer = struct {
+ /// message
+ message: ?[]const u8 = null,
-pub const Platform = enum(u8) {
+ /// router
+ router: ?Router = null,
-_none,
- /// browser
- browser,
+ /// reason
+ reason: ?FallbackStep = null,
- /// node
- node,
+ /// problems
+ problems: ?Problems = null,
- /// bun
- bun,
+ pub fn decode(reader: anytype) anyerror!FallbackMessageContainer {
+ var this = std.mem.zeroes(FallbackMessageContainer);
-_,
+ while (true) {
+ switch (try reader.readByte()) {
+ 0 => {
+ return this;
+ },
- pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void {
- return try std.json.stringify(@tagName(self), opts, o);
+ 1 => {
+ this.message = try reader.readValue([]const u8);
+ },
+ 2 => {
+ this.router = try reader.readValue(Router);
+ },
+ 3 => {
+ this.reason = try reader.readValue(FallbackStep);
+ },
+ 4 => {
+ this.problems = try reader.readValue(Problems);
+ },
+ else => {
+ return error.InvalidMessage;
+ },
}
+ }
+ unreachable;
+ }
-
-};
-
-pub const CssInJsBehavior = enum(u8) {
-
-_none,
- /// facade
- facade,
-
- /// facade_onimportcss
- facade_onimportcss,
+ pub fn encode(this: *const @This(), writer: anytype) anyerror!void {
+ if (this.message) |message| {
+ try writer.writeFieldID(1);
+ try writer.writeValue(message);
+ }
+ if (this.router) |router| {
+ try writer.writeFieldID(2);
+ try writer.writeValue(router);
+ }
+ if (this.reason) |reason| {
+ try writer.writeFieldID(3);
+ try writer.writeEnum(reason);
+ }
+ if (this.problems) |problems| {
+ try writer.writeFieldID(4);
+ try writer.writeValue(problems);
+ }
+ try writer.endMessage();
+ }
+ };
- /// auto_onimportcss
- auto_onimportcss,
+ pub const ResolveMode = enum(u8) {
+ _none,
+ /// disable
+ disable,
-_,
+ /// lazy
+ lazy,
- pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void {
- return try std.json.stringify(@tagName(self), opts, o);
- }
+ /// dev
+ dev,
-
-};
+ /// bundle
+ bundle,
-pub const JsxRuntime = enum(u8) {
+ _,
-_none,
- /// automatic
- automatic,
+ pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void {
+ return try std.json.stringify(@tagName(self), opts, o);
+ }
+ };
- /// classic
- classic,
+ pub const Platform = enum(u8) {
+ _none,
+ /// browser
+ browser,
-_,
+ /// node
+ node,
- pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void {
- return try std.json.stringify(@tagName(self), opts, o);
- }
+ /// bun
+ bun,
-
-};
+ _,
-pub const Jsx = struct {
-/// factory
-factory: []const u8,
+ pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void {
+ return try std.json.stringify(@tagName(self), opts, o);
+ }
+ };
-/// runtime
-runtime: JsxRuntime,
+ pub const CssInJsBehavior = enum(u8) {
+ _none,
+ /// facade
+ facade,
-/// fragment
-fragment: []const u8,
+ /// facade_onimportcss
+ facade_onimportcss,
-/// development
-development: bool = false,
+ /// auto_onimportcss
+ auto_onimportcss,
-/// import_source
-import_source: []const u8,
+ _,
-/// react_fast_refresh
-react_fast_refresh: bool = false,
+ pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void {
+ return try std.json.stringify(@tagName(self), opts, o);
+ }
+ };
+ pub const JsxRuntime = enum(u8) {
+ _none,
+ /// automatic
+ automatic,
-pub fn decode(reader: anytype) anyerror!Jsx {
- var this = std.mem.zeroes(Jsx);
+ /// classic
+ classic,
- this.factory = try reader.readValue([]const u8);
- this.runtime = try reader.readValue(JsxRuntime);
- this.fragment = try reader.readValue([]const u8);
- this.development = try reader.readValue(bool);
- this.import_source = try reader.readValue([]const u8);
- this.react_fast_refresh = try reader.readValue(bool);
- return this;
-}
+ _,
-pub fn encode(this: *const @This(), writer: anytype) anyerror!void {
- try writer.writeValue(this.factory);
- try writer.writeEnum(this.runtime);
- try writer.writeValue(this.fragment);
- try writer.writeInt(@intCast(u8, @boolToInt(this.development)));
- try writer.writeValue(this.import_source);
- try writer.writeInt(@intCast(u8, @boolToInt(this.react_fast_refresh)));
-}
+ pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void {
+ return try std.json.stringify(@tagName(self), opts, o);
+ }
+ };
-};
+ pub const Jsx = struct {
+ /// factory
+ factory: []const u8,
-pub const StringPointer = packed struct {
-/// offset
-offset: u32 = 0,
+ /// runtime
+ runtime: JsxRuntime,
-/// length
-length: u32 = 0,
+ /// fragment
+ fragment: []const u8,
+ /// development
+ development: bool = false,
-pub fn decode(reader: anytype) anyerror!StringPointer {
- var this = std.mem.zeroes(StringPointer);
+ /// import_source
+ import_source: []const u8,
- this.offset = try reader.readValue(u32);
- this.length = try reader.readValue(u32);
- return this;
-}
+ /// react_fast_refresh
+ react_fast_refresh: bool = false,
-pub fn encode(this: *const @This(), writer: anytype) anyerror!void {
- try writer.writeInt(this.offset);
- try writer.writeInt(this.length);
-}
+ pub fn decode(reader: anytype) anyerror!Jsx {
+ var this = std.mem.zeroes(Jsx);
-};
+ this.factory = try reader.readValue([]const u8);
+ this.runtime = try reader.readValue(JsxRuntime);
+ this.fragment = try reader.readValue([]const u8);
+ this.development = try reader.readValue(bool);
+ this.import_source = try reader.readValue([]const u8);
+ this.react_fast_refresh = try reader.readValue(bool);
+ return this;
+ }
-pub const JavascriptBundledModule = struct {
-/// path
-path: StringPointer,
+ pub fn encode(this: *const @This(), writer: anytype) anyerror!void {
+ try writer.writeValue(this.factory);
+ try writer.writeEnum(this.runtime);
+ try writer.writeValue(this.fragment);
+ try writer.writeInt(@intCast(u8, @boolToInt(this.development)));
+ try writer.writeValue(this.import_source);
+ try writer.writeInt(@intCast(u8, @boolToInt(this.react_fast_refresh)));
+ }
+ };
-/// code
-code: StringPointer,
+ pub const StringPointer = packed struct {
+ /// offset
+ offset: u32 = 0,
-/// package_id
-package_id: u32 = 0,
+ /// length
+ length: u32 = 0,
-/// id
-id: u32 = 0,
+ pub fn decode(reader: anytype) anyerror!StringPointer {
+ var this = std.mem.zeroes(StringPointer);
-/// path_extname_length
-path_extname_length: u8 = 0,
+ this.offset = try reader.readValue(u32);
+ this.length = try reader.readValue(u32);
+ return this;
+ }
+ pub fn encode(this: *const @This(), writer: anytype) anyerror!void {
+ try writer.writeInt(this.offset);
+ try writer.writeInt(this.length);
+ }
+ };
-pub fn decode(reader: anytype) anyerror!JavascriptBundledModule {
- var this = std.mem.zeroes(JavascriptBundledModule);
+ pub const JavascriptBundledModule = struct {
+ /// path
+ path: StringPointer,
- this.path = try reader.readValue(StringPointer);
- this.code = try reader.readValue(StringPointer);
- this.package_id = try reader.readValue(u32);
- this.id = try reader.readValue(u32);
- this.path_extname_length = try reader.readValue(u8);
- return this;
-}
+ /// code
+ code: StringPointer,
-pub fn encode(this: *const @This(), writer: anytype) anyerror!void {
- try writer.writeValue(this.path);
- try writer.writeValue(this.code);
- try writer.writeInt(this.package_id);
- try writer.writeInt(this.id);
- try writer.writeInt(this.path_extname_length);
-}
+ /// package_id
+ package_id: u32 = 0,
-};
+ /// id
+ id: u32 = 0,
-pub const JavascriptBundledPackage = struct {
-/// name
-name: StringPointer,
+ /// path_extname_length
+ path_extname_length: u8 = 0,
-/// version
-version: StringPointer,
+ pub fn decode(reader: anytype) anyerror!JavascriptBundledModule {
+ var this = std.mem.zeroes(JavascriptBundledModule);
-/// hash
-hash: u32 = 0,
+ this.path = try reader.readValue(StringPointer);
+ this.code = try reader.readValue(StringPointer);
+ this.package_id = try reader.readValue(u32);
+ this.id = try reader.readValue(u32);
+ this.path_extname_length = try reader.readValue(u8);
+ return this;
+ }
-/// modules_offset
-modules_offset: u32 = 0,
+ pub fn encode(this: *const @This(), writer: anytype) anyerror!void {
+ try writer.writeValue(this.path);
+ try writer.writeValue(this.code);
+ try writer.writeInt(this.package_id);
+ try writer.writeInt(this.id);
+ try writer.writeInt(this.path_extname_length);
+ }
+ };
-/// modules_length
-modules_length: u32 = 0,
+ pub const JavascriptBundledPackage = struct {
+ /// name
+ name: StringPointer,
+ /// version
+ version: StringPointer,
-pub fn decode(reader: anytype) anyerror!JavascriptBundledPackage {
- var this = std.mem.zeroes(JavascriptBundledPackage);
+ /// hash
+ hash: u32 = 0,
- this.name = try reader.readValue(StringPointer);
- this.version = try reader.readValue(StringPointer);
- this.hash = try reader.readValue(u32);
- this.modules_offset = try reader.readValue(u32);
- this.modules_length = try reader.readValue(u32);
- return this;
-}
+ /// modules_offset
+ modules_offset: u32 = 0,
-pub fn encode(this: *const @This(), writer: anytype) anyerror!void {
- try writer.writeValue(this.name);
- try writer.writeValue(this.version);
- try writer.writeInt(this.hash);
- try writer.writeInt(this.modules_offset);
- try writer.writeInt(this.modules_length);
-}
+ /// modules_length
+ modules_length: u32 = 0,
-};
+ pub fn decode(reader: anytype) anyerror!JavascriptBundledPackage {
+ var this = std.mem.zeroes(JavascriptBundledPackage);
-pub const JavascriptBundle = struct {
-/// modules
-modules: []const JavascriptBundledModule,
+ this.name = try reader.readValue(StringPointer);
+ this.version = try reader.readValue(StringPointer);
+ this.hash = try reader.readValue(u32);
+ this.modules_offset = try reader.readValue(u32);
+ this.modules_length = try reader.readValue(u32);
+ return this;
+ }
-/// packages
-packages: []const JavascriptBundledPackage,
+ pub fn encode(this: *const @This(), writer: anytype) anyerror!void {
+ try writer.writeValue(this.name);
+ try writer.writeValue(this.version);
+ try writer.writeInt(this.hash);
+ try writer.writeInt(this.modules_offset);
+ try writer.writeInt(this.modules_length);
+ }
+ };
-/// etag
-etag: []const u8,
+ pub const JavascriptBundle = struct {
+ /// modules
+ modules: []const JavascriptBundledModule,
-/// generated_at
-generated_at: u32 = 0,
+ /// packages
+ packages: []const JavascriptBundledPackage,
-/// app_package_json_dependencies_hash
-app_package_json_dependencies_hash: []const u8,
+ /// etag
+ etag: []const u8,
-/// import_from_name
-import_from_name: []const u8,
+ /// generated_at
+ generated_at: u32 = 0,
-/// manifest_string
-manifest_string: []const u8,
+ /// app_package_json_dependencies_hash
+ app_package_json_dependencies_hash: []const u8,
+ /// import_from_name
+ import_from_name: []const u8,
-pub fn decode(reader: anytype) anyerror!JavascriptBundle {
- var this = std.mem.zeroes(JavascriptBundle);
+ /// manifest_string
+ manifest_string: []const u8,
- this.modules = try reader.readArray(JavascriptBundledModule);
- this.packages = try reader.readArray(JavascriptBundledPackage);
- this.etag = try reader.readArray(u8);
- this.generated_at = try reader.readValue(u32);
- this.app_package_json_dependencies_hash = try reader.readArray(u8);
- this.import_from_name = try reader.readArray(u8);
- this.manifest_string = try reader.readArray(u8);
- return this;
-}
+ pub fn decode(reader: anytype) anyerror!JavascriptBundle {
+ var this = std.mem.zeroes(JavascriptBundle);
-pub fn encode(this: *const @This(), writer: anytype) anyerror!void {
- try writer.writeArray(JavascriptBundledModule, this.modules);
- try writer.writeArray(JavascriptBundledPackage, this.packages);
- try writer.writeArray(u8, this.etag);
- try writer.writeInt(this.generated_at);
- try writer.writeArray(u8, this.app_package_json_dependencies_hash);
- try writer.writeArray(u8, this.import_from_name);
- try writer.writeArray(u8, this.manifest_string);
-}
+ this.modules = try reader.readArray(JavascriptBundledModule);
+ this.packages = try reader.readArray(JavascriptBundledPackage);
+ this.etag = try reader.readArray(u8);
+ this.generated_at = try reader.readValue(u32);
+ this.app_package_json_dependencies_hash = try reader.readArray(u8);
+ this.import_from_name = try reader.readArray(u8);
+ this.manifest_string = try reader.readArray(u8);
+ return this;
+ }
-};
+ pub fn encode(this: *const @This(), writer: anytype) anyerror!void {
+ try writer.writeArray(JavascriptBundledModule, this.modules);
+ try writer.writeArray(JavascriptBundledPackage, this.packages);
+ try writer.writeArray(u8, this.etag);
+ try writer.writeInt(this.generated_at);
+ try writer.writeArray(u8, this.app_package_json_dependencies_hash);
+ try writer.writeArray(u8, this.import_from_name);
+ try writer.writeArray(u8, this.manifest_string);
+ }
+ };
-pub const JavascriptBundleContainer = struct {
-/// bundle_format_version
-bundle_format_version: ?u32 = null,
-
-/// routes
-routes: ?LoadedRouteConfig = null,
-
-/// framework
-framework: ?LoadedFramework = null,
-
-/// bundle
-bundle: ?JavascriptBundle = null,
-
-/// code_length
-code_length: ?u32 = null,
-
-
-pub fn decode(reader: anytype) anyerror!JavascriptBundleContainer {
- var this = std.mem.zeroes(JavascriptBundleContainer);
-
- while(true) {
- switch (try reader.readByte()) {
- 0 => { return this; },
-
- 1 => {
- this.bundle_format_version = try reader.readValue(u32);
-},
- 2 => {
- this.routes = try reader.readValue(LoadedRouteConfig);
-},
- 3 => {
- this.framework = try reader.readValue(LoadedFramework);
-},
- 4 => {
- this.bundle = try reader.readValue(JavascriptBundle);
-},
- 5 => {
- this.code_length = try reader.readValue(u32);
-},
- else => {
- return error.InvalidMessage;
- },
- }
- }
-unreachable;
-}
+ pub const JavascriptBundleContainer = struct {
+ /// bundle_format_version
+ bundle_format_version: ?u32 = null,
-pub fn encode(this: *const @This(), writer: anytype) anyerror!void {
-if (this.bundle_format_version) |bundle_format_version| {
- try writer.writeFieldID(1);
- try writer.writeInt(bundle_format_version);
-}
-if (this.routes) |routes| {
- try writer.writeFieldID(2);
- try writer.writeValue(routes);
-}
-if (this.framework) |framework| {
- try writer.writeFieldID(3);
- try writer.writeValue(framework);
-}
-if (this.bundle) |bundle| {
- try writer.writeFieldID(4);
- try writer.writeValue(bundle);
-}
-if (this.code_length) |code_length| {
- try writer.writeFieldID(5);
- try writer.writeInt(code_length);
-}
-try writer.endMessage();
-}
+ /// routes
+ routes: ?LoadedRouteConfig = null,
-};
+ /// framework
+ framework: ?LoadedFramework = null,
-pub const ScanDependencyMode = enum(u8) {
+ /// bundle
+ bundle: ?JavascriptBundle = null,
-_none,
- /// app
- app,
+ /// code_length
+ code_length: ?u32 = null,
- /// all
- all,
+ pub fn decode(reader: anytype) anyerror!JavascriptBundleContainer {
+ var this = std.mem.zeroes(JavascriptBundleContainer);
-_,
+ while (true) {
+ switch (try reader.readByte()) {
+ 0 => {
+ return this;
+ },
- pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void {
- return try std.json.stringify(@tagName(self), opts, o);
+ 1 => {
+ this.bundle_format_version = try reader.readValue(u32);
+ },
+ 2 => {
+ this.routes = try reader.readValue(LoadedRouteConfig);
+ },
+ 3 => {
+ this.framework = try reader.readValue(LoadedFramework);
+ },
+ 4 => {
+ this.bundle = try reader.readValue(JavascriptBundle);
+ },
+ 5 => {
+ this.code_length = try reader.readValue(u32);
+ },
+ else => {
+ return error.InvalidMessage;
+ },
}
+ }
+ unreachable;
+ }
-
-};
-
-pub const ModuleImportType = enum(u8) {
-
-_none,
- /// import
- import,
+ pub fn encode(this: *const @This(), writer: anytype) anyerror!void {
+ if (this.bundle_format_version) |bundle_format_version| {
+ try writer.writeFieldID(1);
+ try writer.writeInt(bundle_format_version);
+ }
+ if (this.routes) |routes| {
+ try writer.writeFieldID(2);
+ try writer.writeValue(routes);
+ }
+ if (this.framework) |framework| {
+ try writer.writeFieldID(3);
+ try writer.writeValue(framework);
+ }
+ if (this.bundle) |bundle| {
+ try writer.writeFieldID(4);
+ try writer.writeValue(bundle);
+ }
+ if (this.code_length) |code_length| {
+ try writer.writeFieldID(5);
+ try writer.writeInt(code_length);
+ }
+ try writer.endMessage();
+ }
+ };
- /// require
- require,
+ pub const ScanDependencyMode = enum(u8) {
+ _none,
+ /// app
+ app,
-_,
+ /// all
+ all,
- pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void {
- return try std.json.stringify(@tagName(self), opts, o);
- }
+ _,
-
-};
+ pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void {
+ return try std.json.stringify(@tagName(self), opts, o);
+ }
+ };
-pub const ModuleImportRecord = struct {
-/// kind
-kind: ModuleImportType,
+ pub const ModuleImportType = enum(u8) {
+ _none,
+ /// import
+ import,
-/// path
-path: []const u8,
+ /// require
+ require,
-/// dynamic
-dynamic: bool = false,
+ _,
+ pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void {
+ return try std.json.stringify(@tagName(self), opts, o);
+ }
+ };
-pub fn decode(reader: anytype) anyerror!ModuleImportRecord {
- var this = std.mem.zeroes(ModuleImportRecord);
+ pub const ModuleImportRecord = struct {
+ /// kind
+ kind: ModuleImportType,
- this.kind = try reader.readValue(ModuleImportType);
- this.path = try reader.readValue([]const u8);
- this.dynamic = try reader.readValue(bool);
- return this;
-}
+ /// path
+ path: []const u8,
-pub fn encode(this: *const @This(), writer: anytype) anyerror!void {
- try writer.writeEnum(this.kind);
- try writer.writeValue(this.path);
- try writer.writeInt(@intCast(u8, @boolToInt(this.dynamic)));
-}
+ /// dynamic
+ dynamic: bool = false,
-};
+ pub fn decode(reader: anytype) anyerror!ModuleImportRecord {
+ var this = std.mem.zeroes(ModuleImportRecord);
-pub const Module = struct {
-/// path
-path: []const u8,
+ this.kind = try reader.readValue(ModuleImportType);
+ this.path = try reader.readValue([]const u8);
+ this.dynamic = try reader.readValue(bool);
+ return this;
+ }
-/// imports
-imports: []const ModuleImportRecord,
+ pub fn encode(this: *const @This(), writer: anytype) anyerror!void {
+ try writer.writeEnum(this.kind);
+ try writer.writeValue(this.path);
+ try writer.writeInt(@intCast(u8, @boolToInt(this.dynamic)));
+ }
+ };
+ pub const Module = struct {
+ /// path
+ path: []const u8,
-pub fn decode(reader: anytype) anyerror!Module {
- var this = std.mem.zeroes(Module);
+ /// imports
+ imports: []const ModuleImportRecord,
- this.path = try reader.readValue([]const u8);
- this.imports = try reader.readArray(ModuleImportRecord);
- return this;
-}
+ pub fn decode(reader: anytype) anyerror!Module {
+ var this = std.mem.zeroes(Module);
-pub fn encode(this: *const @This(), writer: anytype) anyerror!void {
- try writer.writeValue(this.path);
- try writer.writeArray(ModuleImportRecord, this.imports);
-}
+ this.path = try reader.readValue([]const u8);
+ this.imports = try reader.readArray(ModuleImportRecord);
+ return this;
+ }
-};
+ pub fn encode(this: *const @This(), writer: anytype) anyerror!void {
+ try writer.writeValue(this.path);
+ try writer.writeArray(ModuleImportRecord, this.imports);
+ }
+ };
-pub const StringMap = struct {
-/// keys
-keys: []const []const u8,
+ pub const StringMap = struct {
+ /// keys
+ keys: []const []const u8,
-/// values
-values: []const []const u8,
+ /// values
+ values: []const []const u8,
+ pub fn decode(reader: anytype) anyerror!StringMap {
+ var this = std.mem.zeroes(StringMap);
-pub fn decode(reader: anytype) anyerror!StringMap {
- var this = std.mem.zeroes(StringMap);
+ this.keys = try reader.readArray([]const u8);
+ this.values = try reader.readArray([]const u8);
+ return this;
+ }
- this.keys = try reader.readArray([]const u8);
- this.values = try reader.readArray([]const u8);
- return this;
-}
+ pub fn encode(this: *const @This(), writer: anytype) anyerror!void {
+ try writer.writeArray([]const u8, this.keys);
+ try writer.writeArray([]const u8, this.values);
+ }
+ };
-pub fn encode(this: *const @This(), writer: anytype) anyerror!void {
- try writer.writeArray([]const u8, this.keys);
- try writer.writeArray([]const u8, this.values);
-}
+ pub const LoaderMap = struct {
+ /// extensions
+ extensions: []const []const u8,
-};
+ /// loaders
+ loaders: []const Loader,
-pub const LoaderMap = struct {
-/// extensions
-extensions: []const []const u8,
+ pub fn decode(reader: anytype) anyerror!LoaderMap {
+ var this = std.mem.zeroes(LoaderMap);
-/// loaders
-loaders: []const Loader,
+ this.extensions = try reader.readArray([]const u8);
+ this.loaders = try reader.readArray(Loader);
+ return this;
+ }
+ pub fn encode(this: *const @This(), writer: anytype) anyerror!void {
+ try writer.writeArray([]const u8, this.extensions);
+ try writer.writeArray(Loader, this.loaders);
+ }
+ };
-pub fn decode(reader: anytype) anyerror!LoaderMap {
- var this = std.mem.zeroes(LoaderMap);
+ pub const DotEnvBehavior = enum(u32) {
+ _none,
+ /// disable
+ disable,
- this.extensions = try reader.readArray([]const u8);
- this.loaders = try reader.readArray(Loader);
- return this;
-}
+ /// prefix
+ prefix,
-pub fn encode(this: *const @This(), writer: anytype) anyerror!void {
- try writer.writeArray([]const u8, this.extensions);
- try writer.writeArray(Loader, this.loaders);
-}
+ /// load_all
+ load_all,
-};
+ _,
-pub const DotEnvBehavior = enum(u32) {
+ pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void {
+ return try std.json.stringify(@tagName(self), opts, o);
+ }
+ };
-_none,
- /// disable
- disable,
+ pub const EnvConfig = struct {
+ /// prefix
+ prefix: ?[]const u8 = null,
- /// prefix
- prefix,
+ /// defaults
+ defaults: ?StringMap = null,
- /// load_all
- load_all,
+ pub fn decode(reader: anytype) anyerror!EnvConfig {
+ var this = std.mem.zeroes(EnvConfig);
-_,
+ while (true) {
+ switch (try reader.readByte()) {
+ 0 => {
+ return this;
+ },
- pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void {
- return try std.json.stringify(@tagName(self), opts, o);
+ 1 => {
+ this.prefix = try reader.readValue([]const u8);
+ },
+ 2 => {
+ this.defaults = try reader.readValue(StringMap);
+ },
+ else => {
+ return error.InvalidMessage;
+ },
}
+ }
+ unreachable;
+ }
-
-};
-
-pub const EnvConfig = struct {
-/// prefix
-prefix: ?[]const u8 = null,
-
-/// defaults
-defaults: ?StringMap = null,
-
-
-pub fn decode(reader: anytype) anyerror!EnvConfig {
- var this = std.mem.zeroes(EnvConfig);
-
- while(true) {
- switch (try reader.readByte()) {
- 0 => { return this; },
-
- 1 => {
- this.prefix = try reader.readValue([]const u8);
-},
- 2 => {
- this.defaults = try reader.readValue(StringMap);
-},
- else => {
- return error.InvalidMessage;
- },
- }
- }
-unreachable;
-}
-
-pub fn encode(this: *const @This(), writer: anytype) anyerror!void {
-if (this.prefix) |prefix| {
- try writer.writeFieldID(1);
- try writer.writeValue(prefix);
-}
-if (this.defaults) |defaults| {
- try writer.writeFieldID(2);
- try writer.writeValue(defaults);
-}
-try writer.endMessage();
-}
-
-};
-
-pub const LoadedEnvConfig = struct {
-/// dotenv
-dotenv: DotEnvBehavior,
-
-/// defaults
-defaults: StringMap,
-
-/// prefix
-prefix: []const u8,
-
-
-pub fn decode(reader: anytype) anyerror!LoadedEnvConfig {
- var this = std.mem.zeroes(LoadedEnvConfig);
-
- this.dotenv = try reader.readValue(DotEnvBehavior);
- this.defaults = try reader.readValue(StringMap);
- this.prefix = try reader.readValue([]const u8);
- return this;
-}
+ pub fn encode(this: *const @This(), writer: anytype) anyerror!void {
+ if (this.prefix) |prefix| {
+ try writer.writeFieldID(1);
+ try writer.writeValue(prefix);
+ }
+ if (this.defaults) |defaults| {
+ try writer.writeFieldID(2);
+ try writer.writeValue(defaults);
+ }
+ try writer.endMessage();
+ }
+ };
-pub fn encode(this: *const @This(), writer: anytype) anyerror!void {
- try writer.writeEnum(this.dotenv);
- try writer.writeValue(this.defaults);
- try writer.writeValue(this.prefix);
-}
+ pub const LoadedEnvConfig = struct {
+ /// dotenv
+ dotenv: DotEnvBehavior,
-};
+ /// defaults
+ defaults: StringMap,
-pub const FrameworkConfig = struct {
-/// package
-package: ?[]const u8 = null,
-
-/// client
-client: ?FrameworkEntryPointMessage = null,
-
-/// server
-server: ?FrameworkEntryPointMessage = null,
-
-/// fallback
-fallback: ?FrameworkEntryPointMessage = null,
-
-/// development
-development: ?bool = null,
-
-/// client_css_in_js
-client_css_in_js: ?CssInJsBehavior = null,
-
-
-pub fn decode(reader: anytype) anyerror!FrameworkConfig {
- var this = std.mem.zeroes(FrameworkConfig);
-
- while(true) {
- switch (try reader.readByte()) {
- 0 => { return this; },
-
- 1 => {
- this.package = try reader.readValue([]const u8);
-},
- 2 => {
- this.client = try reader.readValue(FrameworkEntryPointMessage);
-},
- 3 => {
- this.server = try reader.readValue(FrameworkEntryPointMessage);
-},
- 4 => {
- this.fallback = try reader.readValue(FrameworkEntryPointMessage);
-},
- 5 => {
- this.development = try reader.readValue(bool);
-},
- 6 => {
- this.client_css_in_js = try reader.readValue(CssInJsBehavior);
-},
- else => {
- return error.InvalidMessage;
- },
- }
- }
-unreachable;
-}
+ /// prefix
+ prefix: []const u8,
-pub fn encode(this: *const @This(), writer: anytype) anyerror!void {
-if (this.package) |package| {
- try writer.writeFieldID(1);
- try writer.writeValue(package);
-}
-if (this.client) |client| {
- try writer.writeFieldID(2);
- try writer.writeValue(client);
-}
-if (this.server) |server| {
- try writer.writeFieldID(3);
- try writer.writeValue(server);
-}
-if (this.fallback) |fallback| {
- try writer.writeFieldID(4);
- try writer.writeValue(fallback);
-}
-if (this.development) |development| {
- try writer.writeFieldID(5);
- try writer.writeInt(@intCast(u8, @boolToInt(development)));
-}
-if (this.client_css_in_js) |client_css_in_js| {
- try writer.writeFieldID(6);
- try writer.writeEnum(client_css_in_js);
-}
-try writer.endMessage();
-}
+ pub fn decode(reader: anytype) anyerror!LoadedEnvConfig {
+ var this = std.mem.zeroes(LoadedEnvConfig);
-};
+ this.dotenv = try reader.readValue(DotEnvBehavior);
+ this.defaults = try reader.readValue(StringMap);
+ this.prefix = try reader.readValue([]const u8);
+ return this;
+ }
-pub const FrameworkEntryPoint = struct {
-/// kind
-kind: FrameworkEntryPointType,
+ pub fn encode(this: *const @This(), writer: anytype) anyerror!void {
+ try writer.writeEnum(this.dotenv);
+ try writer.writeValue(this.defaults);
+ try writer.writeValue(this.prefix);
+ }
+ };
-/// path
-path: []const u8,
+ pub const FrameworkConfig = struct {
+ /// package
+ package: ?[]const u8 = null,
-/// env
-env: LoadedEnvConfig,
+ /// client
+ client: ?FrameworkEntryPointMessage = null,
+ /// server
+ server: ?FrameworkEntryPointMessage = null,
-pub fn decode(reader: anytype) anyerror!FrameworkEntryPoint {
- var this = std.mem.zeroes(FrameworkEntryPoint);
+ /// fallback
+ fallback: ?FrameworkEntryPointMessage = null,
- this.kind = try reader.readValue(FrameworkEntryPointType);
- this.path = try reader.readValue([]const u8);
- this.env = try reader.readValue(LoadedEnvConfig);
- return this;
-}
+ /// development
+ development: ?bool = null,
-pub fn encode(this: *const @This(), writer: anytype) anyerror!void {
- try writer.writeEnum(this.kind);
- try writer.writeValue(this.path);
- try writer.writeValue(this.env);
-}
+ /// client_css_in_js
+ client_css_in_js: ?CssInJsBehavior = null,
-};
+ /// display_name
+ display_name: ?[]const u8 = null,
-pub const FrameworkEntryPointMap = struct {
-/// client
-client: ?FrameworkEntryPoint = null,
-
-/// server
-server: ?FrameworkEntryPoint = null,
-
-/// fallback
-fallback: ?FrameworkEntryPoint = null,
-
-
-pub fn decode(reader: anytype) anyerror!FrameworkEntryPointMap {
- var this = std.mem.zeroes(FrameworkEntryPointMap);
-
- while(true) {
- switch (try reader.readByte()) {
- 0 => { return this; },
-
- 1 => {
- this.client = try reader.readValue(FrameworkEntryPoint);
-},
- 2 => {
- this.server = try reader.readValue(FrameworkEntryPoint);
-},
- 3 => {
- this.fallback = try reader.readValue(FrameworkEntryPoint);
-},
- else => {
- return error.InvalidMessage;
- },
- }
- }
-unreachable;
-}
+ pub fn decode(reader: anytype) anyerror!FrameworkConfig {
+ var this = std.mem.zeroes(FrameworkConfig);
-pub fn encode(this: *const @This(), writer: anytype) anyerror!void {
-if (this.client) |client| {
- try writer.writeFieldID(1);
- try writer.writeValue(client);
-}
-if (this.server) |server| {
- try writer.writeFieldID(2);
- try writer.writeValue(server);
-}
-if (this.fallback) |fallback| {
- try writer.writeFieldID(3);
- try writer.writeValue(fallback);
-}
-try writer.endMessage();
-}
+ while (true) {
+ switch (try reader.readByte()) {
+ 0 => {
+ return this;
+ },
-};
+ 1 => {
+ this.package = try reader.readValue([]const u8);
+ },
+ 2 => {
+ this.client = try reader.readValue(FrameworkEntryPointMessage);
+ },
+ 3 => {
+ this.server = try reader.readValue(FrameworkEntryPointMessage);
+ },
+ 4 => {
+ this.fallback = try reader.readValue(FrameworkEntryPointMessage);
+ },
+ 5 => {
+ this.development = try reader.readValue(bool);
+ },
+ 6 => {
+ this.client_css_in_js = try reader.readValue(CssInJsBehavior);
+ },
+ 7 => {
+ this.display_name = try reader.readValue([]const u8);
+ },
+ else => {
+ return error.InvalidMessage;
+ },
+ }
+ }
+ unreachable;
+ }
-pub const FrameworkEntryPointMessage = struct {
-/// path
-path: ?[]const u8 = null,
-
-/// env
-env: ?EnvConfig = null,
-
-
-pub fn decode(reader: anytype) anyerror!FrameworkEntryPointMessage {
- var this = std.mem.zeroes(FrameworkEntryPointMessage);
-
- while(true) {
- switch (try reader.readByte()) {
- 0 => { return this; },
-
- 1 => {
- this.path = try reader.readValue([]const u8);
-},
- 2 => {
- this.env = try reader.readValue(EnvConfig);
-},
- else => {
- return error.InvalidMessage;
- },
- }
- }
-unreachable;
-}
+ pub fn encode(this: *const @This(), writer: anytype) anyerror!void {
+ if (this.package) |package| {
+ try writer.writeFieldID(1);
+ try writer.writeValue(package);
+ }
+ if (this.client) |client| {
+ try writer.writeFieldID(2);
+ try writer.writeValue(client);
+ }
+ if (this.server) |server| {
+ try writer.writeFieldID(3);
+ try writer.writeValue(server);
+ }
+ if (this.fallback) |fallback| {
+ try writer.writeFieldID(4);
+ try writer.writeValue(fallback);
+ }
+ if (this.development) |development| {
+ try writer.writeFieldID(5);
+ try writer.writeInt(@intCast(u8, @boolToInt(development)));
+ }
+ if (this.client_css_in_js) |client_css_in_js| {
+ try writer.writeFieldID(6);
+ try writer.writeEnum(client_css_in_js);
+ }
+ if (this.display_name) |display_name| {
+ try writer.writeFieldID(7);
+ try writer.writeValue(display_name);
+ }
+ try writer.endMessage();
+ }
+ };
-pub fn encode(this: *const @This(), writer: anytype) anyerror!void {
-if (this.path) |path| {
- try writer.writeFieldID(1);
- try writer.writeValue(path);
-}
-if (this.env) |env| {
- try writer.writeFieldID(2);
- try writer.writeValue(env);
-}
-try writer.endMessage();
-}
+ pub const FrameworkEntryPoint = struct {
+ /// kind
+ kind: FrameworkEntryPointType,
-};
+ /// path
+ path: []const u8,
-pub const LoadedFramework = struct {
-/// package
-package: []const u8,
+ /// env
+ env: LoadedEnvConfig,
-/// development
-development: bool = false,
+ pub fn decode(reader: anytype) anyerror!FrameworkEntryPoint {
+ var this = std.mem.zeroes(FrameworkEntryPoint);
-/// entry_points
-entry_points: FrameworkEntryPointMap,
+ this.kind = try reader.readValue(FrameworkEntryPointType);
+ this.path = try reader.readValue([]const u8);
+ this.env = try reader.readValue(LoadedEnvConfig);
+ return this;
+ }
-/// client_css_in_js
-client_css_in_js: CssInJsBehavior,
+ pub fn encode(this: *const @This(), writer: anytype) anyerror!void {
+ try writer.writeEnum(this.kind);
+ try writer.writeValue(this.path);
+ try writer.writeValue(this.env);
+ }
+ };
+ pub const FrameworkEntryPointMap = struct {
+ /// client
+ client: ?FrameworkEntryPoint = null,
-pub fn decode(reader: anytype) anyerror!LoadedFramework {
- var this = std.mem.zeroes(LoadedFramework);
+ /// server
+ server: ?FrameworkEntryPoint = null,
- this.package = try reader.readValue([]const u8);
- this.development = try reader.readValue(bool);
- this.entry_points = try reader.readValue(FrameworkEntryPointMap);
- this.client_css_in_js = try reader.readValue(CssInJsBehavior);
- return this;
-}
+ /// fallback
+ fallback: ?FrameworkEntryPoint = null,
-pub fn encode(this: *const @This(), writer: anytype) anyerror!void {
- try writer.writeValue(this.package);
- try writer.writeInt(@intCast(u8, @boolToInt(this.development)));
- try writer.writeValue(this.entry_points);
- try writer.writeEnum(this.client_css_in_js);
-}
+ pub fn decode(reader: anytype) anyerror!FrameworkEntryPointMap {
+ var this = std.mem.zeroes(FrameworkEntryPointMap);
-};
+ while (true) {
+ switch (try reader.readByte()) {
+ 0 => {
+ return this;
+ },
-pub const LoadedRouteConfig = struct {
-/// dir
-dir: []const u8,
+ 1 => {
+ this.client = try reader.readValue(FrameworkEntryPoint);
+ },
+ 2 => {
+ this.server = try reader.readValue(FrameworkEntryPoint);
+ },
+ 3 => {
+ this.fallback = try reader.readValue(FrameworkEntryPoint);
+ },
+ else => {
+ return error.InvalidMessage;
+ },
+ }
+ }
+ unreachable;
+ }
-/// extensions
-extensions: []const []const u8,
+ pub fn encode(this: *const @This(), writer: anytype) anyerror!void {
+ if (this.client) |client| {
+ try writer.writeFieldID(1);
+ try writer.writeValue(client);
+ }
+ if (this.server) |server| {
+ try writer.writeFieldID(2);
+ try writer.writeValue(server);
+ }
+ if (this.fallback) |fallback| {
+ try writer.writeFieldID(3);
+ try writer.writeValue(fallback);
+ }
+ try writer.endMessage();
+ }
+ };
-/// static_dir
-static_dir: []const u8,
+ pub const FrameworkEntryPointMessage = struct {
+ /// path
+ path: ?[]const u8 = null,
-/// asset_prefix
-asset_prefix: []const u8,
+ /// env
+ env: ?EnvConfig = null,
+ pub fn decode(reader: anytype) anyerror!FrameworkEntryPointMessage {
+ var this = std.mem.zeroes(FrameworkEntryPointMessage);
-pub fn decode(reader: anytype) anyerror!LoadedRouteConfig {
- var this = std.mem.zeroes(LoadedRouteConfig);
+ while (true) {
+ switch (try reader.readByte()) {
+ 0 => {
+ return this;
+ },
- this.dir = try reader.readValue([]const u8);
- this.extensions = try reader.readArray([]const u8);
- this.static_dir = try reader.readValue([]const u8);
- this.asset_prefix = try reader.readValue([]const u8);
- return this;
-}
+ 1 => {
+ this.path = try reader.readValue([]const u8);
+ },
+ 2 => {
+ this.env = try reader.readValue(EnvConfig);
+ },
+ else => {
+ return error.InvalidMessage;
+ },
+ }
+ }
+ unreachable;
+ }
-pub fn encode(this: *const @This(), writer: anytype) anyerror!void {
- try writer.writeValue(this.dir);
- try writer.writeArray([]const u8, this.extensions);
- try writer.writeValue(this.static_dir);
- try writer.writeValue(this.asset_prefix);
-}
+ pub fn encode(this: *const @This(), writer: anytype) anyerror!void {
+ if (this.path) |path| {
+ try writer.writeFieldID(1);
+ try writer.writeValue(path);
+ }
+ if (this.env) |env| {
+ try writer.writeFieldID(2);
+ try writer.writeValue(env);
+ }
+ try writer.endMessage();
+ }
+ };
-};
+ pub const LoadedFramework = struct {
+ /// package
+ package: []const u8,
-pub const RouteConfig = struct {
-/// dir
-dir: []const []const u8,
-
-/// extensions
-extensions: []const []const u8,
-
-/// static_dir
-static_dir: ?[]const u8 = null,
-
-/// asset_prefix
-asset_prefix: ?[]const u8 = null,
-
-
-pub fn decode(reader: anytype) anyerror!RouteConfig {
- var this = std.mem.zeroes(RouteConfig);
-
- while(true) {
- switch (try reader.readByte()) {
- 0 => { return this; },
-
- 1 => {
- this.dir = try reader.readArray([]const u8);
-},
- 2 => {
- this.extensions = try reader.readArray([]const u8);
-},
- 3 => {
- this.static_dir = try reader.readValue([]const u8);
-},
- 4 => {
- this.asset_prefix = try reader.readValue([]const u8);
-},
- else => {
- return error.InvalidMessage;
- },
- }
- }
-unreachable;
-}
+ /// display_name
+ display_name: []const u8,
-pub fn encode(this: *const @This(), writer: anytype) anyerror!void {
-if (this.dir) |dir| {
- try writer.writeFieldID(1);
- try writer.writeArray([]const u8, dir);
-}
-if (this.extensions) |extensions| {
- try writer.writeFieldID(2);
- try writer.writeArray([]const u8, extensions);
-}
-if (this.static_dir) |static_dir| {
- try writer.writeFieldID(3);
- try writer.writeValue(static_dir);
-}
-if (this.asset_prefix) |asset_prefix| {
- try writer.writeFieldID(4);
- try writer.writeValue(asset_prefix);
-}
-try writer.endMessage();
-}
+ /// development
+ development: bool = false,
-};
+ /// entry_points
+ entry_points: FrameworkEntryPointMap,
-pub const TransformOptions = struct {
-/// jsx
-jsx: ?Jsx = null,
+ /// client_css_in_js
+ client_css_in_js: CssInJsBehavior,
-/// tsconfig_override
-tsconfig_override: ?[]const u8 = null,
+ pub fn decode(reader: anytype) anyerror!LoadedFramework {
+ var this = std.mem.zeroes(LoadedFramework);
-/// resolve
-resolve: ?ResolveMode = null,
+ this.package = try reader.readValue([]const u8);
+ this.display_name = try reader.readValue([]const u8);
+ this.development = try reader.readValue(bool);
+ this.entry_points = try reader.readValue(FrameworkEntryPointMap);
+ this.client_css_in_js = try reader.readValue(CssInJsBehavior);
+ return this;
+ }
-/// origin
-origin: ?[]const u8 = null,
-
-/// absolute_working_dir
-absolute_working_dir: ?[]const u8 = null,
-
-/// define
-define: ?StringMap = null,
-
-/// preserve_symlinks
-preserve_symlinks: ?bool = null,
-
-/// entry_points
-entry_points: []const []const u8,
-
-/// write
-write: ?bool = null,
-
-/// inject
-inject: []const []const u8,
-
-/// output_dir
-output_dir: ?[]const u8 = null,
-
-/// external
-external: []const []const u8,
-
-/// loaders
-loaders: ?LoaderMap = null,
-
-/// main_fields
-main_fields: []const []const u8,
-
-/// platform
-platform: ?Platform = null,
-
-/// serve
-serve: ?bool = null,
-
-/// extension_order
-extension_order: []const []const u8,
-
-/// generate_node_module_bundle
-generate_node_module_bundle: ?bool = null,
-
-/// node_modules_bundle_path
-node_modules_bundle_path: ?[]const u8 = null,
-
-/// node_modules_bundle_path_server
-node_modules_bundle_path_server: ?[]const u8 = null,
-
-/// framework
-framework: ?FrameworkConfig = null,
-
-/// router
-router: ?RouteConfig = null,
-
-/// no_summary
-no_summary: ?bool = null,
-
-
-pub fn decode(reader: anytype) anyerror!TransformOptions {
- var this = std.mem.zeroes(TransformOptions);
-
- while(true) {
- switch (try reader.readByte()) {
- 0 => { return this; },
-
- 1 => {
- this.jsx = try reader.readValue(Jsx);
-},
- 2 => {
- this.tsconfig_override = try reader.readValue([]const u8);
-},
- 3 => {
- this.resolve = try reader.readValue(ResolveMode);
-},
- 4 => {
- this.origin = try reader.readValue([]const u8);
-},
- 5 => {
- this.absolute_working_dir = try reader.readValue([]const u8);
-},
- 6 => {
- this.define = try reader.readValue(StringMap);
-},
- 7 => {
- this.preserve_symlinks = try reader.readValue(bool);
-},
- 8 => {
- this.entry_points = try reader.readArray([]const u8);
-},
- 9 => {
- this.write = try reader.readValue(bool);
-},
- 10 => {
- this.inject = try reader.readArray([]const u8);
-},
- 11 => {
- this.output_dir = try reader.readValue([]const u8);
-},
- 12 => {
- this.external = try reader.readArray([]const u8);
-},
- 13 => {
- this.loaders = try reader.readValue(LoaderMap);
-},
- 14 => {
- this.main_fields = try reader.readArray([]const u8);
-},
- 15 => {
- this.platform = try reader.readValue(Platform);
-},
- 16 => {
- this.serve = try reader.readValue(bool);
-},
- 17 => {
- this.extension_order = try reader.readArray([]const u8);
-},
- 18 => {
- this.generate_node_module_bundle = try reader.readValue(bool);
-},
- 19 => {
- this.node_modules_bundle_path = try reader.readValue([]const u8);
-},
- 20 => {
- this.node_modules_bundle_path_server = try reader.readValue([]const u8);
-},
- 21 => {
- this.framework = try reader.readValue(FrameworkConfig);
-},
- 22 => {
- this.router = try reader.readValue(RouteConfig);
-},
- 23 => {
- this.no_summary = try reader.readValue(bool);
-},
- else => {
- return error.InvalidMessage;
- },
- }
- }
-unreachable;
-}
+ pub fn encode(this: *const @This(), writer: anytype) anyerror!void {
+ try writer.writeValue(this.package);
+ try writer.writeValue(this.display_name);
+ try writer.writeInt(@intCast(u8, @boolToInt(this.development)));
+ try writer.writeValue(this.entry_points);
+ try writer.writeEnum(this.client_css_in_js);
+ }
+ };
-pub fn encode(this: *const @This(), writer: anytype) anyerror!void {
-if (this.jsx) |jsx| {
- try writer.writeFieldID(1);
- try writer.writeValue(jsx);
-}
-if (this.tsconfig_override) |tsconfig_override| {
- try writer.writeFieldID(2);
- try writer.writeValue(tsconfig_override);
-}
-if (this.resolve) |resolve| {
- try writer.writeFieldID(3);
- try writer.writeEnum(resolve);
-}
-if (this.origin) |origin| {
- try writer.writeFieldID(4);
- try writer.writeValue(origin);
-}
-if (this.absolute_working_dir) |absolute_working_dir| {
- try writer.writeFieldID(5);
- try writer.writeValue(absolute_working_dir);
-}
-if (this.define) |define| {
- try writer.writeFieldID(6);
- try writer.writeValue(define);
-}
-if (this.preserve_symlinks) |preserve_symlinks| {
- try writer.writeFieldID(7);
- try writer.writeInt(@intCast(u8, @boolToInt(preserve_symlinks)));
-}
-if (this.entry_points) |entry_points| {
- try writer.writeFieldID(8);
- try writer.writeArray([]const u8, entry_points);
-}
-if (this.write) |write| {
- try writer.writeFieldID(9);
- try writer.writeInt(@intCast(u8, @boolToInt(write)));
-}
-if (this.inject) |inject| {
- try writer.writeFieldID(10);
- try writer.writeArray([]const u8, inject);
-}
-if (this.output_dir) |output_dir| {
- try writer.writeFieldID(11);
- try writer.writeValue(output_dir);
-}
-if (this.external) |external| {
- try writer.writeFieldID(12);
- try writer.writeArray([]const u8, external);
-}
-if (this.loaders) |loaders| {
- try writer.writeFieldID(13);
- try writer.writeValue(loaders);
-}
-if (this.main_fields) |main_fields| {
- try writer.writeFieldID(14);
- try writer.writeArray([]const u8, main_fields);
-}
-if (this.platform) |platform| {
- try writer.writeFieldID(15);
- try writer.writeEnum(platform);
-}
-if (this.serve) |serve| {
- try writer.writeFieldID(16);
- try writer.writeInt(@intCast(u8, @boolToInt(serve)));
-}
-if (this.extension_order) |extension_order| {
- try writer.writeFieldID(17);
- try writer.writeArray([]const u8, extension_order);
-}
-if (this.generate_node_module_bundle) |generate_node_module_bundle| {
- try writer.writeFieldID(18);
- try writer.writeInt(@intCast(u8, @boolToInt(generate_node_module_bundle)));
-}
-if (this.node_modules_bundle_path) |node_modules_bundle_path| {
- try writer.writeFieldID(19);
- try writer.writeValue(node_modules_bundle_path);
-}
-if (this.node_modules_bundle_path_server) |node_modules_bundle_path_server| {
- try writer.writeFieldID(20);
- try writer.writeValue(node_modules_bundle_path_server);
-}
-if (this.framework) |framework| {
- try writer.writeFieldID(21);
- try writer.writeValue(framework);
-}
-if (this.router) |router| {
- try writer.writeFieldID(22);
- try writer.writeValue(router);
-}
-if (this.no_summary) |no_summary| {
- try writer.writeFieldID(23);
- try writer.writeInt(@intCast(u8, @boolToInt(no_summary)));
-}
-try writer.endMessage();
-}
+ pub const LoadedRouteConfig = struct {
+ /// dir
+ dir: []const u8,
-};
+ /// extensions
+ extensions: []const []const u8,
-pub const FileHandle = struct {
-/// path
-path: []const u8,
+ /// static_dir
+ static_dir: []const u8,
-/// size
-size: u32 = 0,
+ /// asset_prefix
+ asset_prefix: []const u8,
-/// fd
-fd: u32 = 0,
+ pub fn decode(reader: anytype) anyerror!LoadedRouteConfig {
+ var this = std.mem.zeroes(LoadedRouteConfig);
+ this.dir = try reader.readValue([]const u8);
+ this.extensions = try reader.readArray([]const u8);
+ this.static_dir = try reader.readValue([]const u8);
+ this.asset_prefix = try reader.readValue([]const u8);
+ return this;
+ }
-pub fn decode(reader: anytype) anyerror!FileHandle {
- var this = std.mem.zeroes(FileHandle);
+ pub fn encode(this: *const @This(), writer: anytype) anyerror!void {
+ try writer.writeValue(this.dir);
+ try writer.writeArray([]const u8, this.extensions);
+ try writer.writeValue(this.static_dir);
+ try writer.writeValue(this.asset_prefix);
+ }
+ };
- this.path = try reader.readValue([]const u8);
- this.size = try reader.readValue(u32);
- this.fd = try reader.readValue(u32);
- return this;
-}
+ pub const RouteConfig = struct {
+ /// dir
+ dir: []const []const u8,
-pub fn encode(this: *const @This(), writer: anytype) anyerror!void {
- try writer.writeValue(this.path);
- try writer.writeInt(this.size);
- try writer.writeInt(this.fd);
-}
+ /// extensions
+ extensions: []const []const u8,
-};
+ /// static_dir
+ static_dir: ?[]const u8 = null,
-pub const Transform = struct {
-/// handle
-handle: ?FileHandle = null,
-
-/// path
-path: ?[]const u8 = null,
-
-/// contents
-contents: []const u8,
-
-/// loader
-loader: ?Loader = null,
-
-/// options
-options: ?TransformOptions = null,
-
-
-pub fn decode(reader: anytype) anyerror!Transform {
- var this = std.mem.zeroes(Transform);
-
- while(true) {
- switch (try reader.readByte()) {
- 0 => { return this; },
-
- 1 => {
- this.handle = try reader.readValue(FileHandle);
-},
- 2 => {
- this.path = try reader.readValue([]const u8);
-},
- 3 => {
- this.contents = try reader.readArray(u8);
-},
- 4 => {
- this.loader = try reader.readValue(Loader);
-},
- 5 => {
- this.options = try reader.readValue(TransformOptions);
-},
- else => {
- return error.InvalidMessage;
- },
- }
- }
-unreachable;
-}
+ /// asset_prefix
+ asset_prefix: ?[]const u8 = null,
-pub fn encode(this: *const @This(), writer: anytype) anyerror!void {
-if (this.handle) |handle| {
- try writer.writeFieldID(1);
- try writer.writeValue(handle);
-}
-if (this.path) |path| {
- try writer.writeFieldID(2);
- try writer.writeValue(path);
-}
-if (this.contents) |contents| {
- try writer.writeFieldID(3);
- try writer.writeArray(u8, contents);
-}
-if (this.loader) |loader| {
- try writer.writeFieldID(4);
- try writer.writeEnum(loader);
-}
-if (this.options) |options| {
- try writer.writeFieldID(5);
- try writer.writeValue(options);
-}
-try writer.endMessage();
-}
+ pub fn decode(reader: anytype) anyerror!RouteConfig {
+ var this = std.mem.zeroes(RouteConfig);
-};
+ while (true) {
+ switch (try reader.readByte()) {
+ 0 => {
+ return this;
+ },
-pub const TransformResponseStatus = enum(u32) {
+ 1 => {
+ this.dir = try reader.readArray([]const u8);
+ },
+ 2 => {
+ this.extensions = try reader.readArray([]const u8);
+ },
+ 3 => {
+ this.static_dir = try reader.readValue([]const u8);
+ },
+ 4 => {
+ this.asset_prefix = try reader.readValue([]const u8);
+ },
+ else => {
+ return error.InvalidMessage;
+ },
+ }
+ }
+ unreachable;
+ }
-_none,
- /// success
- success,
+ pub fn encode(this: *const @This(), writer: anytype) anyerror!void {
+ if (this.dir) |dir| {
+ try writer.writeFieldID(1);
+ try writer.writeArray([]const u8, dir);
+ }
+ if (this.extensions) |extensions| {
+ try writer.writeFieldID(2);
+ try writer.writeArray([]const u8, extensions);
+ }
+ if (this.static_dir) |static_dir| {
+ try writer.writeFieldID(3);
+ try writer.writeValue(static_dir);
+ }
+ if (this.asset_prefix) |asset_prefix| {
+ try writer.writeFieldID(4);
+ try writer.writeValue(asset_prefix);
+ }
+ try writer.endMessage();
+ }
+ };
- /// fail
- fail,
+ pub const TransformOptions = struct {
+ /// jsx
+ jsx: ?Jsx = null,
-_,
+ /// tsconfig_override
+ tsconfig_override: ?[]const u8 = null,
- pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void {
- return try std.json.stringify(@tagName(self), opts, o);
- }
+ /// resolve
+ resolve: ?ResolveMode = null,
-
-};
+ /// origin
+ origin: ?[]const u8 = null,
-pub const OutputFile = struct {
-/// data
-data: []const u8,
+ /// absolute_working_dir
+ absolute_working_dir: ?[]const u8 = null,
-/// path
-path: []const u8,
+ /// define
+ define: ?StringMap = null,
+ /// preserve_symlinks
+ preserve_symlinks: ?bool = null,
-pub fn decode(reader: anytype) anyerror!OutputFile {
- var this = std.mem.zeroes(OutputFile);
+ /// entry_points
+ entry_points: []const []const u8,
- this.data = try reader.readArray(u8);
- this.path = try reader.readValue([]const u8);
- return this;
-}
+ /// write
+ write: ?bool = null,
-pub fn encode(this: *const @This(), writer: anytype) anyerror!void {
- try writer.writeArray(u8, this.data);
- try writer.writeValue(this.path);
-}
+ /// inject
+ inject: []const []const u8,
-};
+ /// output_dir
+ output_dir: ?[]const u8 = null,
-pub const TransformResponse = struct {
-/// status
-status: TransformResponseStatus,
+ /// external
+ external: []const []const u8,
-/// files
-files: []const OutputFile,
+ /// loaders
+ loaders: ?LoaderMap = null,
-/// errors
-errors: []const Message,
+ /// main_fields
+ main_fields: []const []const u8,
+ /// platform
+ platform: ?Platform = null,
-pub fn decode(reader: anytype) anyerror!TransformResponse {
- var this = std.mem.zeroes(TransformResponse);
+ /// serve
+ serve: ?bool = null,
- this.status = try reader.readValue(TransformResponseStatus);
- this.files = try reader.readArray(OutputFile);
- this.errors = try reader.readArray(Message);
- return this;
-}
+ /// extension_order
+ extension_order: []const []const u8,
-pub fn encode(this: *const @This(), writer: anytype) anyerror!void {
- try writer.writeEnum(this.status);
- try writer.writeArray(OutputFile, this.files);
- try writer.writeArray(Message, this.errors);
-}
+ /// generate_node_module_bundle
+ generate_node_module_bundle: ?bool = null,
-};
+ /// node_modules_bundle_path
+ node_modules_bundle_path: ?[]const u8 = null,
-pub const MessageLevel = enum(u32) {
+ /// node_modules_bundle_path_server
+ node_modules_bundle_path_server: ?[]const u8 = null,
-_none,
- /// err
- err,
+ /// framework
+ framework: ?FrameworkConfig = null,
- /// warn
- warn,
+ /// router
+ router: ?RouteConfig = null,
- /// note
- note,
+ /// no_summary
+ no_summary: ?bool = null,
- /// debug
- debug,
+ pub fn decode(reader: anytype) anyerror!TransformOptions {
+ var this = std.mem.zeroes(TransformOptions);
-_,
+ while (true) {
+ switch (try reader.readByte()) {
+ 0 => {
+ return this;
+ },
- pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void {
- return try std.json.stringify(@tagName(self), opts, o);
+ 1 => {
+ this.jsx = try reader.readValue(Jsx);
+ },
+ 2 => {
+ this.tsconfig_override = try reader.readValue([]const u8);
+ },
+ 3 => {
+ this.resolve = try reader.readValue(ResolveMode);
+ },
+ 4 => {
+ this.origin = try reader.readValue([]const u8);
+ },
+ 5 => {
+ this.absolute_working_dir = try reader.readValue([]const u8);
+ },
+ 6 => {
+ this.define = try reader.readValue(StringMap);
+ },
+ 7 => {
+ this.preserve_symlinks = try reader.readValue(bool);
+ },
+ 8 => {
+ this.entry_points = try reader.readArray([]const u8);
+ },
+ 9 => {
+ this.write = try reader.readValue(bool);
+ },
+ 10 => {
+ this.inject = try reader.readArray([]const u8);
+ },
+ 11 => {
+ this.output_dir = try reader.readValue([]const u8);
+ },
+ 12 => {
+ this.external = try reader.readArray([]const u8);
+ },
+ 13 => {
+ this.loaders = try reader.readValue(LoaderMap);
+ },
+ 14 => {
+ this.main_fields = try reader.readArray([]const u8);
+ },
+ 15 => {
+ this.platform = try reader.readValue(Platform);
+ },
+ 16 => {
+ this.serve = try reader.readValue(bool);
+ },
+ 17 => {
+ this.extension_order = try reader.readArray([]const u8);
+ },
+ 18 => {
+ this.generate_node_module_bundle = try reader.readValue(bool);
+ },
+ 19 => {
+ this.node_modules_bundle_path = try reader.readValue([]const u8);
+ },
+ 20 => {
+ this.node_modules_bundle_path_server = try reader.readValue([]const u8);
+ },
+ 21 => {
+ this.framework = try reader.readValue(FrameworkConfig);
+ },
+ 22 => {
+ this.router = try reader.readValue(RouteConfig);
+ },
+ 23 => {
+ this.no_summary = try reader.readValue(bool);
+ },
+ else => {
+ return error.InvalidMessage;
+ },
}
+ }
+ unreachable;
+ }
-
-};
+ pub fn encode(this: *const @This(), writer: anytype) anyerror!void {
+ if (this.jsx) |jsx| {
+ try writer.writeFieldID(1);
+ try writer.writeValue(jsx);
+ }
+ if (this.tsconfig_override) |tsconfig_override| {
+ try writer.writeFieldID(2);
+ try writer.writeValue(tsconfig_override);
+ }
+ if (this.resolve) |resolve| {
+ try writer.writeFieldID(3);
+ try writer.writeEnum(resolve);
+ }
+ if (this.origin) |origin| {
+ try writer.writeFieldID(4);
+ try writer.writeValue(origin);
+ }
+ if (this.absolute_working_dir) |absolute_working_dir| {
+ try writer.writeFieldID(5);
+ try writer.writeValue(absolute_working_dir);
+ }
+ if (this.define) |define| {
+ try writer.writeFieldID(6);
+ try writer.writeValue(define);
+ }
+ if (this.preserve_symlinks) |preserve_symlinks| {
+ try writer.writeFieldID(7);
+ try writer.writeInt(@intCast(u8, @boolToInt(preserve_symlinks)));
+ }
+ if (this.entry_points) |entry_points| {
+ try writer.writeFieldID(8);
+ try writer.writeArray([]const u8, entry_points);
+ }
+ if (this.write) |write| {
+ try writer.writeFieldID(9);
+ try writer.writeInt(@intCast(u8, @boolToInt(write)));
+ }
+ if (this.inject) |inject| {
+ try writer.writeFieldID(10);
+ try writer.writeArray([]const u8, inject);
+ }
+ if (this.output_dir) |output_dir| {
+ try writer.writeFieldID(11);
+ try writer.writeValue(output_dir);
+ }
+ if (this.external) |external| {
+ try writer.writeFieldID(12);
+ try writer.writeArray([]const u8, external);
+ }
+ if (this.loaders) |loaders| {
+ try writer.writeFieldID(13);
+ try writer.writeValue(loaders);
+ }
+ if (this.main_fields) |main_fields| {
+ try writer.writeFieldID(14);
+ try writer.writeArray([]const u8, main_fields);
+ }
+ if (this.platform) |platform| {
+ try writer.writeFieldID(15);
+ try writer.writeEnum(platform);
+ }
+ if (this.serve) |serve| {
+ try writer.writeFieldID(16);
+ try writer.writeInt(@intCast(u8, @boolToInt(serve)));
+ }
+ if (this.extension_order) |extension_order| {
+ try writer.writeFieldID(17);
+ try writer.writeArray([]const u8, extension_order);
+ }
+ if (this.generate_node_module_bundle) |generate_node_module_bundle| {
+ try writer.writeFieldID(18);
+ try writer.writeInt(@intCast(u8, @boolToInt(generate_node_module_bundle)));
+ }
+ if (this.node_modules_bundle_path) |node_modules_bundle_path| {
+ try writer.writeFieldID(19);
+ try writer.writeValue(node_modules_bundle_path);
+ }
+ if (this.node_modules_bundle_path_server) |node_modules_bundle_path_server| {
+ try writer.writeFieldID(20);
+ try writer.writeValue(node_modules_bundle_path_server);
+ }
+ if (this.framework) |framework| {
+ try writer.writeFieldID(21);
+ try writer.writeValue(framework);
+ }
+ if (this.router) |router| {
+ try writer.writeFieldID(22);
+ try writer.writeValue(router);
+ }
+ if (this.no_summary) |no_summary| {
+ try writer.writeFieldID(23);
+ try writer.writeInt(@intCast(u8, @boolToInt(no_summary)));
+ }
+ try writer.endMessage();
+ }
+ };
-pub const Location = struct {
-/// file
-file: []const u8,
+ pub const FileHandle = struct {
+ /// path
+ path: []const u8,
-/// namespace
-namespace: []const u8,
+ /// size
+ size: u32 = 0,
-/// line
-line: i32 = 0,
+ /// fd
+ fd: u32 = 0,
-/// column
-column: i32 = 0,
+ pub fn decode(reader: anytype) anyerror!FileHandle {
+ var this = std.mem.zeroes(FileHandle);
-/// line_text
-line_text: []const u8,
+ this.path = try reader.readValue([]const u8);
+ this.size = try reader.readValue(u32);
+ this.fd = try reader.readValue(u32);
+ return this;
+ }
-/// suggestion
-suggestion: []const u8,
+ pub fn encode(this: *const @This(), writer: anytype) anyerror!void {
+ try writer.writeValue(this.path);
+ try writer.writeInt(this.size);
+ try writer.writeInt(this.fd);
+ }
+ };
-/// offset
-offset: u32 = 0,
+ pub const Transform = struct {
+ /// handle
+ handle: ?FileHandle = null,
+ /// path
+ path: ?[]const u8 = null,
-pub fn decode(reader: anytype) anyerror!Location {
- var this = std.mem.zeroes(Location);
+ /// contents
+ contents: []const u8,
- this.file = try reader.readValue([]const u8);
- this.namespace = try reader.readValue([]const u8);
- this.line = try reader.readValue(i32);
- this.column = try reader.readValue(i32);
- this.line_text = try reader.readValue([]const u8);
- this.suggestion = try reader.readValue([]const u8);
- this.offset = try reader.readValue(u32);
- return this;
-}
+ /// loader
+ loader: ?Loader = null,
-pub fn encode(this: *const @This(), writer: anytype) anyerror!void {
- try writer.writeValue(this.file);
- try writer.writeValue(this.namespace);
- try writer.writeInt(this.line);
- try writer.writeInt(this.column);
- try writer.writeValue(this.line_text);
- try writer.writeValue(this.suggestion);
- try writer.writeInt(this.offset);
-}
+ /// options
+ options: ?TransformOptions = null,
-};
+ pub fn decode(reader: anytype) anyerror!Transform {
+ var this = std.mem.zeroes(Transform);
-pub const MessageData = struct {
-/// text
-text: ?[]const u8 = null,
-
-/// location
-location: ?Location = null,
-
-
-pub fn decode(reader: anytype) anyerror!MessageData {
- var this = std.mem.zeroes(MessageData);
-
- while(true) {
- switch (try reader.readByte()) {
- 0 => { return this; },
-
- 1 => {
- this.text = try reader.readValue([]const u8);
-},
- 2 => {
- this.location = try reader.readValue(Location);
-},
- else => {
- return error.InvalidMessage;
- },
- }
- }
-unreachable;
-}
+ while (true) {
+ switch (try reader.readByte()) {
+ 0 => {
+ return this;
+ },
-pub fn encode(this: *const @This(), writer: anytype) anyerror!void {
-if (this.text) |text| {
- try writer.writeFieldID(1);
- try writer.writeValue(text);
-}
-if (this.location) |location| {
- try writer.writeFieldID(2);
- try writer.writeValue(location);
-}
-try writer.endMessage();
-}
+ 1 => {
+ this.handle = try reader.readValue(FileHandle);
+ },
+ 2 => {
+ this.path = try reader.readValue([]const u8);
+ },
+ 3 => {
+ this.contents = try reader.readArray(u8);
+ },
+ 4 => {
+ this.loader = try reader.readValue(Loader);
+ },
+ 5 => {
+ this.options = try reader.readValue(TransformOptions);
+ },
+ else => {
+ return error.InvalidMessage;
+ },
+ }
+ }
+ unreachable;
+ }
-};
+ pub fn encode(this: *const @This(), writer: anytype) anyerror!void {
+ if (this.handle) |handle| {
+ try writer.writeFieldID(1);
+ try writer.writeValue(handle);
+ }
+ if (this.path) |path| {
+ try writer.writeFieldID(2);
+ try writer.writeValue(path);
+ }
+ if (this.contents) |contents| {
+ try writer.writeFieldID(3);
+ try writer.writeArray(u8, contents);
+ }
+ if (this.loader) |loader| {
+ try writer.writeFieldID(4);
+ try writer.writeEnum(loader);
+ }
+ if (this.options) |options| {
+ try writer.writeFieldID(5);
+ try writer.writeValue(options);
+ }
+ try writer.endMessage();
+ }
+ };
-pub const MessageMeta = struct {
-/// resolve
-resolve: ?[]const u8 = null,
-
-/// build
-build: ?bool = null,
-
-
-pub fn decode(reader: anytype) anyerror!MessageMeta {
- var this = std.mem.zeroes(MessageMeta);
-
- while(true) {
- switch (try reader.readByte()) {
- 0 => { return this; },
-
- 1 => {
- this.resolve = try reader.readValue([]const u8);
-},
- 2 => {
- this.build = try reader.readValue(bool);
-},
- else => {
- return error.InvalidMessage;
- },
- }
- }
-unreachable;
-}
+ pub const TransformResponseStatus = enum(u32) {
+ _none,
+ /// success
+ success,
-pub fn encode(this: *const @This(), writer: anytype) anyerror!void {
-if (this.resolve) |resolve| {
- try writer.writeFieldID(1);
- try writer.writeValue(resolve);
-}
-if (this.build) |build| {
- try writer.writeFieldID(2);
- try writer.writeInt(@intCast(u8, @boolToInt(build)));
-}
-try writer.endMessage();
-}
+ /// fail
+ fail,
-};
+ _,
-pub const Message = struct {
-/// level
-level: MessageLevel,
+ pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void {
+ return try std.json.stringify(@tagName(self), opts, o);
+ }
+ };
-/// data
-data: MessageData,
+ pub const OutputFile = struct {
+ /// data
+ data: []const u8,
-/// notes
-notes: []const MessageData,
+ /// path
+ path: []const u8,
-/// on
-on: MessageMeta,
+ pub fn decode(reader: anytype) anyerror!OutputFile {
+ var this = std.mem.zeroes(OutputFile);
+ this.data = try reader.readArray(u8);
+ this.path = try reader.readValue([]const u8);
+ return this;
+ }
-pub fn decode(reader: anytype) anyerror!Message {
- var this = std.mem.zeroes(Message);
+ pub fn encode(this: *const @This(), writer: anytype) anyerror!void {
+ try writer.writeArray(u8, this.data);
+ try writer.writeValue(this.path);
+ }
+ };
- this.level = try reader.readValue(MessageLevel);
- this.data = try reader.readValue(MessageData);
- this.notes = try reader.readArray(MessageData);
- this.on = try reader.readValue(MessageMeta);
- return this;
-}
+ pub const TransformResponse = struct {
+ /// status
+ status: TransformResponseStatus,
-pub fn encode(this: *const @This(), writer: anytype) anyerror!void {
- try writer.writeEnum(this.level);
- try writer.writeValue(this.data);
- try writer.writeArray(MessageData, this.notes);
- try writer.writeValue(this.on);
-}
+ /// files
+ files: []const OutputFile,
-};
+ /// errors
+ errors: []const Message,
-pub const Log = struct {
-/// warnings
-warnings: u32 = 0,
+ pub fn decode(reader: anytype) anyerror!TransformResponse {
+ var this = std.mem.zeroes(TransformResponse);
-/// errors
-errors: u32 = 0,
+ this.status = try reader.readValue(TransformResponseStatus);
+ this.files = try reader.readArray(OutputFile);
+ this.errors = try reader.readArray(Message);
+ return this;
+ }
-/// msgs
-msgs: []const Message,
+ pub fn encode(this: *const @This(), writer: anytype) anyerror!void {
+ try writer.writeEnum(this.status);
+ try writer.writeArray(OutputFile, this.files);
+ try writer.writeArray(Message, this.errors);
+ }
+ };
+ pub const MessageLevel = enum(u32) {
+ _none,
+ /// err
+ err,
-pub fn decode(reader: anytype) anyerror!Log {
- var this = std.mem.zeroes(Log);
+ /// warn
+ warn,
- this.warnings = try reader.readValue(u32);
- this.errors = try reader.readValue(u32);
- this.msgs = try reader.readArray(Message);
- return this;
-}
+ /// note
+ note,
-pub fn encode(this: *const @This(), writer: anytype) anyerror!void {
- try writer.writeInt(this.warnings);
- try writer.writeInt(this.errors);
- try writer.writeArray(Message, this.msgs);
-}
+ /// debug
+ debug,
-};
+ _,
-pub const Reloader = enum(u8) {
+ pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void {
+ return try std.json.stringify(@tagName(self), opts, o);
+ }
+ };
-_none,
- /// disable
- disable,
+ pub const Location = struct {
+ /// file
+ file: []const u8,
- /// live
- live,
+ /// namespace
+ namespace: []const u8,
- /// fast_refresh
- fast_refresh,
+ /// line
+ line: i32 = 0,
-_,
+ /// column
+ column: i32 = 0,
- pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void {
- return try std.json.stringify(@tagName(self), opts, o);
- }
+ /// line_text
+ line_text: []const u8,
-
-};
+ /// suggestion
+ suggestion: []const u8,
-pub const WebsocketMessageKind = enum(u8) {
+ /// offset
+ offset: u32 = 0,
-_none,
- /// welcome
- welcome,
+ pub fn decode(reader: anytype) anyerror!Location {
+ var this = std.mem.zeroes(Location);
- /// file_change_notification
- file_change_notification,
+ this.file = try reader.readValue([]const u8);
+ this.namespace = try reader.readValue([]const u8);
+ this.line = try reader.readValue(i32);
+ this.column = try reader.readValue(i32);
+ this.line_text = try reader.readValue([]const u8);
+ this.suggestion = try reader.readValue([]const u8);
+ this.offset = try reader.readValue(u32);
+ return this;
+ }
- /// build_success
- build_success,
+ pub fn encode(this: *const @This(), writer: anytype) anyerror!void {
+ try writer.writeValue(this.file);
+ try writer.writeValue(this.namespace);
+ try writer.writeInt(this.line);
+ try writer.writeInt(this.column);
+ try writer.writeValue(this.line_text);
+ try writer.writeValue(this.suggestion);
+ try writer.writeInt(this.offset);
+ }
+ };
- /// build_fail
- build_fail,
+ pub const MessageData = struct {
+ /// text
+ text: ?[]const u8 = null,
- /// manifest_success
- manifest_success,
+ /// location
+ location: ?Location = null,
- /// manifest_fail
- manifest_fail,
+ pub fn decode(reader: anytype) anyerror!MessageData {
+ var this = std.mem.zeroes(MessageData);
-_,
+ while (true) {
+ switch (try reader.readByte()) {
+ 0 => {
+ return this;
+ },
- pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void {
- return try std.json.stringify(@tagName(self), opts, o);
+ 1 => {
+ this.text = try reader.readValue([]const u8);
+ },
+ 2 => {
+ this.location = try reader.readValue(Location);
+ },
+ else => {
+ return error.InvalidMessage;
+ },
}
+ }
+ unreachable;
+ }
-
-};
+ pub fn encode(this: *const @This(), writer: anytype) anyerror!void {
+ if (this.text) |text| {
+ try writer.writeFieldID(1);
+ try writer.writeValue(text);
+ }
+ if (this.location) |location| {
+ try writer.writeFieldID(2);
+ try writer.writeValue(location);
+ }
+ try writer.endMessage();
+ }
+ };
-pub const WebsocketCommandKind = enum(u8) {
+ pub const MessageMeta = struct {
+ /// resolve
+ resolve: ?[]const u8 = null,
-_none,
- /// build
- build,
+ /// build
+ build: ?bool = null,
- /// manifest
- manifest,
+ pub fn decode(reader: anytype) anyerror!MessageMeta {
+ var this = std.mem.zeroes(MessageMeta);
-_,
+ while (true) {
+ switch (try reader.readByte()) {
+ 0 => {
+ return this;
+ },
- pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void {
- return try std.json.stringify(@tagName(self), opts, o);
+ 1 => {
+ this.resolve = try reader.readValue([]const u8);
+ },
+ 2 => {
+ this.build = try reader.readValue(bool);
+ },
+ else => {
+ return error.InvalidMessage;
+ },
}
+ }
+ unreachable;
+ }
-
-};
+ pub fn encode(this: *const @This(), writer: anytype) anyerror!void {
+ if (this.resolve) |resolve| {
+ try writer.writeFieldID(1);
+ try writer.writeValue(resolve);
+ }
+ if (this.build) |build| {
+ try writer.writeFieldID(2);
+ try writer.writeInt(@intCast(u8, @boolToInt(build)));
+ }
+ try writer.endMessage();
+ }
+ };
-pub const WebsocketMessage = struct {
-/// timestamp
-timestamp: u32 = 0,
+ pub const Message = struct {
+ /// level
+ level: MessageLevel,
-/// kind
-kind: WebsocketMessageKind,
+ /// data
+ data: MessageData,
+ /// notes
+ notes: []const MessageData,
-pub fn decode(reader: anytype) anyerror!WebsocketMessage {
- var this = std.mem.zeroes(WebsocketMessage);
+ /// on
+ on: MessageMeta,
- this.timestamp = try reader.readValue(u32);
- this.kind = try reader.readValue(WebsocketMessageKind);
- return this;
-}
+ pub fn decode(reader: anytype) anyerror!Message {
+ var this = std.mem.zeroes(Message);
-pub fn encode(this: *const @This(), writer: anytype) anyerror!void {
- try writer.writeInt(this.timestamp);
- try writer.writeEnum(this.kind);
-}
+ this.level = try reader.readValue(MessageLevel);
+ this.data = try reader.readValue(MessageData);
+ this.notes = try reader.readArray(MessageData);
+ this.on = try reader.readValue(MessageMeta);
+ return this;
+ }
-};
+ pub fn encode(this: *const @This(), writer: anytype) anyerror!void {
+ try writer.writeEnum(this.level);
+ try writer.writeValue(this.data);
+ try writer.writeArray(MessageData, this.notes);
+ try writer.writeValue(this.on);
+ }
+ };
-pub const WebsocketMessageWelcome = struct {
-/// epoch
-epoch: u32 = 0,
+ pub const Log = struct {
+ /// warnings
+ warnings: u32 = 0,
-/// javascriptReloader
-javascript_reloader: Reloader,
+ /// errors
+ errors: u32 = 0,
+ /// msgs
+ msgs: []const Message,
-pub fn decode(reader: anytype) anyerror!WebsocketMessageWelcome {
- var this = std.mem.zeroes(WebsocketMessageWelcome);
+ pub fn decode(reader: anytype) anyerror!Log {
+ var this = std.mem.zeroes(Log);
- this.epoch = try reader.readValue(u32);
- this.javascript_reloader = try reader.readValue(Reloader);
- return this;
-}
+ this.warnings = try reader.readValue(u32);
+ this.errors = try reader.readValue(u32);
+ this.msgs = try reader.readArray(Message);
+ return this;
+ }
-pub fn encode(this: *const @This(), writer: anytype) anyerror!void {
- try writer.writeInt(this.epoch);
- try writer.writeEnum(this.javascript_reloader);
-}
+ pub fn encode(this: *const @This(), writer: anytype) anyerror!void {
+ try writer.writeInt(this.warnings);
+ try writer.writeInt(this.errors);
+ try writer.writeArray(Message, this.msgs);
+ }
+ };
-};
+ pub const Reloader = enum(u8) {
+ _none,
+ /// disable
+ disable,
-pub const WebsocketMessageFileChangeNotification = struct {
-/// id
-id: u32 = 0,
+ /// live
+ live,
-/// loader
-loader: Loader,
+ /// fast_refresh
+ fast_refresh,
+ _,
-pub fn decode(reader: anytype) anyerror!WebsocketMessageFileChangeNotification {
- var this = std.mem.zeroes(WebsocketMessageFileChangeNotification);
+ pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void {
+ return try std.json.stringify(@tagName(self), opts, o);
+ }
+ };
- this.id = try reader.readValue(u32);
- this.loader = try reader.readValue(Loader);
- return this;
-}
+ pub const WebsocketMessageKind = enum(u8) {
+ _none,
+ /// welcome
+ welcome,
-pub fn encode(this: *const @This(), writer: anytype) anyerror!void {
- try writer.writeInt(this.id);
- try writer.writeEnum(this.loader);
-}
+ /// file_change_notification
+ file_change_notification,
-};
+ /// build_success
+ build_success,
-pub const WebsocketCommand = struct {
-/// kind
-kind: WebsocketCommandKind,
+ /// build_fail
+ build_fail,
-/// timestamp
-timestamp: u32 = 0,
+ /// manifest_success
+ manifest_success,
+ /// manifest_fail
+ manifest_fail,
-pub fn decode(reader: anytype) anyerror!WebsocketCommand {
- var this = std.mem.zeroes(WebsocketCommand);
+ _,
- this.kind = try reader.readValue(WebsocketCommandKind);
- this.timestamp = try reader.readValue(u32);
- return this;
-}
+ pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void {
+ return try std.json.stringify(@tagName(self), opts, o);
+ }
+ };
-pub fn encode(this: *const @This(), writer: anytype) anyerror!void {
- try writer.writeEnum(this.kind);
- try writer.writeInt(this.timestamp);
-}
+ pub const WebsocketCommandKind = enum(u8) {
+ _none,
+ /// build
+ build,
-};
+ /// manifest
+ manifest,
-pub const WebsocketCommandBuild = packed struct {
-/// id
-id: u32 = 0,
+ _,
+ pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void {
+ return try std.json.stringify(@tagName(self), opts, o);
+ }
+ };
-pub fn decode(reader: anytype) anyerror!WebsocketCommandBuild {
- var this = std.mem.zeroes(WebsocketCommandBuild);
+ pub const WebsocketMessage = struct {
+ /// timestamp
+ timestamp: u32 = 0,
- this.id = try reader.readValue(u32);
- return this;
-}
+ /// kind
+ kind: WebsocketMessageKind,
-pub fn encode(this: *const @This(), writer: anytype) anyerror!void {
- try writer.writeInt(this.id);
-}
+ pub fn decode(reader: anytype) anyerror!WebsocketMessage {
+ var this = std.mem.zeroes(WebsocketMessage);
-};
+ this.timestamp = try reader.readValue(u32);
+ this.kind = try reader.readValue(WebsocketMessageKind);
+ return this;
+ }
-pub const WebsocketCommandManifest = packed struct {
-/// id
-id: u32 = 0,
+ pub fn encode(this: *const @This(), writer: anytype) anyerror!void {
+ try writer.writeInt(this.timestamp);
+ try writer.writeEnum(this.kind);
+ }
+ };
+ pub const WebsocketMessageWelcome = struct {
+ /// epoch
+ epoch: u32 = 0,
-pub fn decode(reader: anytype) anyerror!WebsocketCommandManifest {
- var this = std.mem.zeroes(WebsocketCommandManifest);
+ /// javascriptReloader
+ javascript_reloader: Reloader,
- this.id = try reader.readValue(u32);
- return this;
-}
+ pub fn decode(reader: anytype) anyerror!WebsocketMessageWelcome {
+ var this = std.mem.zeroes(WebsocketMessageWelcome);
-pub fn encode(this: *const @This(), writer: anytype) anyerror!void {
- try writer.writeInt(this.id);
-}
+ this.epoch = try reader.readValue(u32);
+ this.javascript_reloader = try reader.readValue(Reloader);
+ return this;
+ }
-};
+ pub fn encode(this: *const @This(), writer: anytype) anyerror!void {
+ try writer.writeInt(this.epoch);
+ try writer.writeEnum(this.javascript_reloader);
+ }
+ };
-pub const WebsocketMessageBuildSuccess = struct {
-/// id
-id: u32 = 0,
+ pub const WebsocketMessageFileChangeNotification = struct {
+ /// id
+ id: u32 = 0,
-/// from_timestamp
-from_timestamp: u32 = 0,
+ /// loader
+ loader: Loader,
-/// loader
-loader: Loader,
+ pub fn decode(reader: anytype) anyerror!WebsocketMessageFileChangeNotification {
+ var this = std.mem.zeroes(WebsocketMessageFileChangeNotification);
-/// module_path
-module_path: []const u8,
+ this.id = try reader.readValue(u32);
+ this.loader = try reader.readValue(Loader);
+ return this;
+ }
-/// blob_length
-blob_length: u32 = 0,
+ pub fn encode(this: *const @This(), writer: anytype) anyerror!void {
+ try writer.writeInt(this.id);
+ try writer.writeEnum(this.loader);
+ }
+ };
+ pub const WebsocketCommand = struct {
+ /// kind
+ kind: WebsocketCommandKind,
-pub fn decode(reader: anytype) anyerror!WebsocketMessageBuildSuccess {
- var this = std.mem.zeroes(WebsocketMessageBuildSuccess);
+ /// timestamp
+ timestamp: u32 = 0,
- this.id = try reader.readValue(u32);
- this.from_timestamp = try reader.readValue(u32);
- this.loader = try reader.readValue(Loader);
- this.module_path = try reader.readValue([]const u8);
- this.blob_length = try reader.readValue(u32);
- return this;
-}
+ pub fn decode(reader: anytype) anyerror!WebsocketCommand {
+ var this = std.mem.zeroes(WebsocketCommand);
-pub fn encode(this: *const @This(), writer: anytype) anyerror!void {
- try writer.writeInt(this.id);
- try writer.writeInt(this.from_timestamp);
- try writer.writeEnum(this.loader);
- try writer.writeValue(this.module_path);
- try writer.writeInt(this.blob_length);
-}
+ this.kind = try reader.readValue(WebsocketCommandKind);
+ this.timestamp = try reader.readValue(u32);
+ return this;
+ }
-};
+ pub fn encode(this: *const @This(), writer: anytype) anyerror!void {
+ try writer.writeEnum(this.kind);
+ try writer.writeInt(this.timestamp);
+ }
+ };
-pub const WebsocketMessageBuildFailure = struct {
-/// id
-id: u32 = 0,
+ pub const WebsocketCommandBuild = packed struct {
+ /// id
+ id: u32 = 0,
-/// from_timestamp
-from_timestamp: u32 = 0,
+ pub fn decode(reader: anytype) anyerror!WebsocketCommandBuild {
+ var this = std.mem.zeroes(WebsocketCommandBuild);
-/// loader
-loader: Loader,
+ this.id = try reader.readValue(u32);
+ return this;
+ }
-/// module_path
-module_path: []const u8,
+ pub fn encode(this: *const @This(), writer: anytype) anyerror!void {
+ try writer.writeInt(this.id);
+ }
+ };
-/// log
-log: Log,
+ pub const WebsocketCommandManifest = packed struct {
+ /// id
+ id: u32 = 0,
+ pub fn decode(reader: anytype) anyerror!WebsocketCommandManifest {
+ var this = std.mem.zeroes(WebsocketCommandManifest);
-pub fn decode(reader: anytype) anyerror!WebsocketMessageBuildFailure {
- var this = std.mem.zeroes(WebsocketMessageBuildFailure);
+ this.id = try reader.readValue(u32);
+ return this;
+ }
- this.id = try reader.readValue(u32);
- this.from_timestamp = try reader.readValue(u32);
- this.loader = try reader.readValue(Loader);
- this.module_path = try reader.readValue([]const u8);
- this.log = try reader.readValue(Log);
- return this;
-}
+ pub fn encode(this: *const @This(), writer: anytype) anyerror!void {
+ try writer.writeInt(this.id);
+ }
+ };
-pub fn encode(this: *const @This(), writer: anytype) anyerror!void {
- try writer.writeInt(this.id);
- try writer.writeInt(this.from_timestamp);
- try writer.writeEnum(this.loader);
- try writer.writeValue(this.module_path);
- try writer.writeValue(this.log);
-}
+ pub const WebsocketMessageBuildSuccess = struct {
+ /// id
+ id: u32 = 0,
-};
+ /// from_timestamp
+ from_timestamp: u32 = 0,
-pub const DependencyManifest = struct {
-/// ids
-ids: []const u32,
+ /// loader
+ loader: Loader,
+ /// module_path
+ module_path: []const u8,
-pub fn decode(reader: anytype) anyerror!DependencyManifest {
- var this = std.mem.zeroes(DependencyManifest);
+ /// blob_length
+ blob_length: u32 = 0,
- this.ids = try reader.readArray(u32);
- return this;
-}
+ pub fn decode(reader: anytype) anyerror!WebsocketMessageBuildSuccess {
+ var this = std.mem.zeroes(WebsocketMessageBuildSuccess);
-pub fn encode(this: *const @This(), writer: anytype) anyerror!void {
- try writer.writeArray(u32, this.ids);
-}
+ this.id = try reader.readValue(u32);
+ this.from_timestamp = try reader.readValue(u32);
+ this.loader = try reader.readValue(Loader);
+ this.module_path = try reader.readValue([]const u8);
+ this.blob_length = try reader.readValue(u32);
+ return this;
+ }
-};
+ pub fn encode(this: *const @This(), writer: anytype) anyerror!void {
+ try writer.writeInt(this.id);
+ try writer.writeInt(this.from_timestamp);
+ try writer.writeEnum(this.loader);
+ try writer.writeValue(this.module_path);
+ try writer.writeInt(this.blob_length);
+ }
+ };
-pub const FileList = struct {
-/// ptrs
-ptrs: []const StringPointer,
+ pub const WebsocketMessageBuildFailure = struct {
+ /// id
+ id: u32 = 0,
-/// files
-files: []const u8,
+ /// from_timestamp
+ from_timestamp: u32 = 0,
+ /// loader
+ loader: Loader,
-pub fn decode(reader: anytype) anyerror!FileList {
- var this = std.mem.zeroes(FileList);
+ /// module_path
+ module_path: []const u8,
- this.ptrs = try reader.readArray(StringPointer);
- this.files = try reader.readValue([]const u8);
- return this;
-}
+ /// log
+ log: Log,
-pub fn encode(this: *const @This(), writer: anytype) anyerror!void {
- try writer.writeArray(StringPointer, this.ptrs);
- try writer.writeValue(this.files);
-}
+ pub fn decode(reader: anytype) anyerror!WebsocketMessageBuildFailure {
+ var this = std.mem.zeroes(WebsocketMessageBuildFailure);
-};
+ this.id = try reader.readValue(u32);
+ this.from_timestamp = try reader.readValue(u32);
+ this.loader = try reader.readValue(Loader);
+ this.module_path = try reader.readValue([]const u8);
+ this.log = try reader.readValue(Log);
+ return this;
+ }
-pub const WebsocketMessageResolveIDs = struct {
-/// id
-id: []const u32,
+ pub fn encode(this: *const @This(), writer: anytype) anyerror!void {
+ try writer.writeInt(this.id);
+ try writer.writeInt(this.from_timestamp);
+ try writer.writeEnum(this.loader);
+ try writer.writeValue(this.module_path);
+ try writer.writeValue(this.log);
+ }
+ };
-/// list
-list: FileList,
+ pub const DependencyManifest = struct {
+ /// ids
+ ids: []const u32,
+ pub fn decode(reader: anytype) anyerror!DependencyManifest {
+ var this = std.mem.zeroes(DependencyManifest);
-pub fn decode(reader: anytype) anyerror!WebsocketMessageResolveIDs {
- var this = std.mem.zeroes(WebsocketMessageResolveIDs);
+ this.ids = try reader.readArray(u32);
+ return this;
+ }
- this.id = try reader.readArray(u32);
- this.list = try reader.readValue(FileList);
- return this;
-}
+ pub fn encode(this: *const @This(), writer: anytype) anyerror!void {
+ try writer.writeArray(u32, this.ids);
+ }
+ };
-pub fn encode(this: *const @This(), writer: anytype) anyerror!void {
- try writer.writeArray(u32, this.id);
- try writer.writeValue(this.list);
-}
+ pub const FileList = struct {
+ /// ptrs
+ ptrs: []const StringPointer,
-};
+ /// files
+ files: []const u8,
-pub const WebsocketCommandResolveIDs = struct {
-/// ptrs
-ptrs: []const StringPointer,
+ pub fn decode(reader: anytype) anyerror!FileList {
+ var this = std.mem.zeroes(FileList);
-/// files
-files: []const u8,
+ this.ptrs = try reader.readArray(StringPointer);
+ this.files = try reader.readValue([]const u8);
+ return this;
+ }
+ pub fn encode(this: *const @This(), writer: anytype) anyerror!void {
+ try writer.writeArray(StringPointer, this.ptrs);
+ try writer.writeValue(this.files);
+ }
+ };
-pub fn decode(reader: anytype) anyerror!WebsocketCommandResolveIDs {
- var this = std.mem.zeroes(WebsocketCommandResolveIDs);
+ pub const WebsocketMessageResolveIDs = struct {
+ /// id
+ id: []const u32,
- this.ptrs = try reader.readArray(StringPointer);
- this.files = try reader.readValue([]const u8);
- return this;
-}
+ /// list
+ list: FileList,
-pub fn encode(this: *const @This(), writer: anytype) anyerror!void {
- try writer.writeArray(StringPointer, this.ptrs);
- try writer.writeValue(this.files);
-}
+ pub fn decode(reader: anytype) anyerror!WebsocketMessageResolveIDs {
+ var this = std.mem.zeroes(WebsocketMessageResolveIDs);
-};
+ this.id = try reader.readArray(u32);
+ this.list = try reader.readValue(FileList);
+ return this;
+ }
-pub const WebsocketMessageManifestSuccess = struct {
-/// id
-id: u32 = 0,
+ pub fn encode(this: *const @This(), writer: anytype) anyerror!void {
+ try writer.writeArray(u32, this.id);
+ try writer.writeValue(this.list);
+ }
+ };
-/// module_path
-module_path: []const u8,
+ pub const WebsocketCommandResolveIDs = struct {
+ /// ptrs
+ ptrs: []const StringPointer,
-/// loader
-loader: Loader,
+ /// files
+ files: []const u8,
-/// manifest
-manifest: DependencyManifest,
+ pub fn decode(reader: anytype) anyerror!WebsocketCommandResolveIDs {
+ var this = std.mem.zeroes(WebsocketCommandResolveIDs);
+ this.ptrs = try reader.readArray(StringPointer);
+ this.files = try reader.readValue([]const u8);
+ return this;
+ }
-pub fn decode(reader: anytype) anyerror!WebsocketMessageManifestSuccess {
- var this = std.mem.zeroes(WebsocketMessageManifestSuccess);
+ pub fn encode(this: *const @This(), writer: anytype) anyerror!void {
+ try writer.writeArray(StringPointer, this.ptrs);
+ try writer.writeValue(this.files);
+ }
+ };
- this.id = try reader.readValue(u32);
- this.module_path = try reader.readValue([]const u8);
- this.loader = try reader.readValue(Loader);
- this.manifest = try reader.readValue(DependencyManifest);
- return this;
-}
+ pub const WebsocketMessageManifestSuccess = struct {
+ /// id
+ id: u32 = 0,
-pub fn encode(this: *const @This(), writer: anytype) anyerror!void {
- try writer.writeInt(this.id);
- try writer.writeValue(this.module_path);
- try writer.writeEnum(this.loader);
- try writer.writeValue(this.manifest);
-}
+ /// module_path
+ module_path: []const u8,
-};
+ /// loader
+ loader: Loader,
-pub const WebsocketMessageManifestFailure = struct {
-/// id
-id: u32 = 0,
+ /// manifest
+ manifest: DependencyManifest,
-/// from_timestamp
-from_timestamp: u32 = 0,
+ pub fn decode(reader: anytype) anyerror!WebsocketMessageManifestSuccess {
+ var this = std.mem.zeroes(WebsocketMessageManifestSuccess);
-/// loader
-loader: Loader,
+ this.id = try reader.readValue(u32);
+ this.module_path = try reader.readValue([]const u8);
+ this.loader = try reader.readValue(Loader);
+ this.manifest = try reader.readValue(DependencyManifest);
+ return this;
+ }
-/// log
-log: Log,
+ pub fn encode(this: *const @This(), writer: anytype) anyerror!void {
+ try writer.writeInt(this.id);
+ try writer.writeValue(this.module_path);
+ try writer.writeEnum(this.loader);
+ try writer.writeValue(this.manifest);
+ }
+ };
+ pub const WebsocketMessageManifestFailure = struct {
+ /// id
+ id: u32 = 0,
-pub fn decode(reader: anytype) anyerror!WebsocketMessageManifestFailure {
- var this = std.mem.zeroes(WebsocketMessageManifestFailure);
+ /// from_timestamp
+ from_timestamp: u32 = 0,
- this.id = try reader.readValue(u32);
- this.from_timestamp = try reader.readValue(u32);
- this.loader = try reader.readValue(Loader);
- this.log = try reader.readValue(Log);
- return this;
-}
+ /// loader
+ loader: Loader,
-pub fn encode(this: *const @This(), writer: anytype) anyerror!void {
- try writer.writeInt(this.id);
- try writer.writeInt(this.from_timestamp);
- try writer.writeEnum(this.loader);
- try writer.writeValue(this.log);
-}
+ /// log
+ log: Log,
-};
+ pub fn decode(reader: anytype) anyerror!WebsocketMessageManifestFailure {
+ var this = std.mem.zeroes(WebsocketMessageManifestFailure);
+ this.id = try reader.readValue(u32);
+ this.from_timestamp = try reader.readValue(u32);
+ this.loader = try reader.readValue(Loader);
+ this.log = try reader.readValue(Log);
+ return this;
+ }
+ pub fn encode(this: *const @This(), writer: anytype) anyerror!void {
+ try writer.writeInt(this.id);
+ try writer.writeInt(this.from_timestamp);
+ try writer.writeEnum(this.loader);
+ try writer.writeValue(this.log);
+ }
+ };
};
-
const ExamplePackedStruct = packed struct {
len: u32 = 0,
offset: u32 = 0,
diff --git a/src/bundler.zig b/src/bundler.zig
index f308fc204..53b3a2f04 100644
--- a/src/bundler.zig
+++ b/src/bundler.zig
@@ -1914,8 +1914,18 @@ pub fn NewBundler(cache_files: bool) type {
opts.enable_bundling = false;
opts.transform_require_to_import = true;
opts.can_import_from_bundle = bundler.options.node_modules_bundle != null;
- opts.features.hot_module_reloading = bundler.options.hot_module_reloading and bundler.options.platform != .bun and (opts.can_import_from_bundle or !path.isNodeModule()); // and client_entry_point_ == null;
- opts.features.react_fast_refresh = opts.features.hot_module_reloading and jsx.parse and bundler.options.jsx.supports_fast_refresh;
+
+ // HMR is enabled when devserver is running
+ // unless you've explicitly disabled it
+ // or you're running in SSR
+ // or the file is a node_module
+ opts.features.hot_module_reloading = bundler.options.hot_module_reloading and
+ bundler.options.platform != .bun and
+ (!opts.can_import_from_bundle or
+ (opts.can_import_from_bundle and !path.isNodeModule()));
+ opts.features.react_fast_refresh = opts.features.hot_module_reloading and
+ jsx.parse and
+ bundler.options.jsx.supports_fast_refresh;
opts.filepath_hash_for_hmr = file_hash orelse 0;
opts.warn_about_unbundled_modules = bundler.options.platform != .bun;
const value = (bundler.resolver.caches.js.parse(allocator, opts, bundler.options.define, bundler.log, &source) catch null) orelse return null;
@@ -2639,26 +2649,38 @@ pub const FallbackEntryPoint = struct {
var code: string = undefined;
if (disable_css_imports) {
- code = try std.fmt.bufPrint(
- &entry.code_buffer,
+ const fmt =
\\globalThis.Bun_disableCSSImports = true;
\\import boot from '{s}';
\\boot(globalThis.__BUN_DATA__);
- ,
- .{
- input_path,
- },
- );
+ ;
+
+ const args = .{
+ input_path,
+ };
+
+ const count = std.fmt.count(fmt, args);
+ if (count < entry.code_buffer.len) {
+ code = try std.fmt.bufPrint(&entry.code_buffer, fmt, args);
+ } else {
+ code = try std.fmt.allocPrint(bundler.allocator, fmt, args);
+ }
} else {
- code = try std.fmt.bufPrint(
- &entry.code_buffer,
+ const fmt =
\\import boot from '{s}';
\\boot(globalThis.__BUN_DATA__);
- ,
- .{
- input_path,
- },
- );
+ ;
+
+ const args = .{
+ input_path,
+ };
+
+ const count = std.fmt.count(fmt, args);
+ if (count < entry.code_buffer.len) {
+ code = try std.fmt.bufPrint(&entry.code_buffer, fmt, args);
+ } else {
+ code = try std.fmt.allocPrint(bundler.allocator, fmt, args);
+ }
}
entry.source = logger.Source.initPathString(input_path, code);
diff --git a/src/fallback.ts b/src/fallback.ts
index cf4195c4d..ae969062c 100644
--- a/src/fallback.ts
+++ b/src/fallback.ts
@@ -6,10 +6,9 @@ import {
} from "./api/schema";
function getFallbackInfo(): FallbackMessageContainer {
- var binary_string = window.atob(
- document.querySelector("#__bunfallback").textContent.trim()
+ var binary_string = globalThis.atob(
+ document.getElementById("#__bunfallback").textContent.trim()
);
- document.querySelector("#__bunfallback").remove();
var len = binary_string.length;
var bytes = new Uint8Array(len);
@@ -21,4 +20,10 @@ function getFallbackInfo(): FallbackMessageContainer {
}
globalThis.__BUN_DATA__ = getFallbackInfo();
-document.getElementById("__bun_fallback_script")?.remove();
+// It's probably better to remove potentially large content from the DOM when not in use
+if ("requestIdleCallback" in globalThis) {
+ globalThis.requestIdleCallback(() => {
+ document.getElementById("__bunfallback")?.remove();
+ document.getElementById("__bun_fallback_script")?.remove();
+ });
+}
diff --git a/src/fallback.version b/src/fallback.version
index 3b2d7e4b9..767db23f0 100644
--- a/src/fallback.version
+++ b/src/fallback.version
@@ -1 +1 @@
-8bf9555fd27e865d \ No newline at end of file
+f6c1d621b6e90172 \ No newline at end of file
diff --git a/src/feature_flags.zig b/src/feature_flags.zig
index 036f86dda..c5b11c5f9 100644
--- a/src/feature_flags.zig
+++ b/src/feature_flags.zig
@@ -27,7 +27,7 @@ pub const bundle_node_modules = true;
pub const tracing = true;
-pub const verbose_watcher = true;
+pub const verbose_watcher = false;
pub const css_supports_fence = true;
diff --git a/src/global.zig b/src/global.zig
index b4289a1ba..2ca225aeb 100644
--- a/src/global.zig
+++ b/src/global.zig
@@ -119,6 +119,17 @@ pub const Output = struct {
pub fn printElapsed(elapsed: f64) void {
Output.prettyError("<r><d>[<b>{d:>.2}ms<r><d>]<r>", .{elapsed});
}
+
+ pub fn printStartEnd(start: i128, end: i128) void {
+ const elapsed = @divTrunc(end - start, @as(i128, std.time.ns_per_ms));
+ printElapsed(@intToFloat(f64, elapsed));
+ }
+
+ pub fn printTimer(timer: *std.time.Timer) void {
+ const elapsed = @divTrunc(timer.read(), @as(u64, std.time.ns_per_ms));
+ printElapsed(@intToFloat(f64, elapsed));
+ }
+
pub fn printErrorable(comptime fmt: string, args: anytype) !void {
if (comptime isWasm) {
try source.stream.seekTo(0);
diff --git a/src/http.zig b/src/http.zig
index d70daf2e0..a967b466d 100644
--- a/src/http.zig
+++ b/src/http.zig
@@ -268,7 +268,11 @@ pub const RequestContext = struct {
defer this.done();
try this.writeStatus(500);
-
+ const route_name = if (route_index > -1) this.matched_route.?.name else this.url.pathname;
+ Output.prettyErrorln("<r><red>500<r> - <b>{s}<r> rendering <b>/{s}<r>", .{
+ @errorName(err),
+ route_name,
+ });
this.appendHeader("Content-Type", MimeType.html.value);
var bb = std.ArrayList(u8).init(allocator);
defer bb.deinit();
@@ -659,7 +663,7 @@ pub const RequestContext = struct {
return WatchBuildResult{
.value = .{ .fail = std.mem.zeroes(Api.WebsocketMessageBuildFailure) },
.id = id,
- .timestamp = WebsocketHandler.toTimestamp(this.timer.read()),
+ .timestamp = WebsocketHandler.toTimestamp(Server.global_start_time.read()),
};
};
@@ -698,7 +702,7 @@ pub const RequestContext = struct {
return WatchBuildResult{
.value = .{ .fail = std.mem.zeroes(Api.WebsocketMessageBuildFailure) },
.id = id,
- .timestamp = WebsocketHandler.toTimestamp(this.timer.read()),
+ .timestamp = WebsocketHandler.toTimestamp(Server.global_start_time.read()),
};
};
@@ -715,7 +719,7 @@ pub const RequestContext = struct {
return WatchBuildResult{
.value = .{ .fail = std.mem.zeroes(Api.WebsocketMessageBuildFailure) },
.id = id,
- .timestamp = WebsocketHandler.toTimestamp(this.timer.read()),
+ .timestamp = WebsocketHandler.toTimestamp(Server.global_start_time.read()),
};
};
@@ -733,7 +737,7 @@ pub const RequestContext = struct {
.id = id,
.bytes = this.printer.ctx.written,
.approximate_newline_count = parse_result.ast.approximate_newline_count,
- .timestamp = WebsocketHandler.toTimestamp(this.timer.read()),
+ .timestamp = WebsocketHandler.toTimestamp(Server.global_start_time.read()),
};
},
.css => {
@@ -802,14 +806,14 @@ pub const RequestContext = struct {
.bytes = this.printer.ctx.written,
.approximate_newline_count = count.approximate_newline_count,
// .approximate_newline_count = parse_result.ast.approximate_newline_count,
- .timestamp = WebsocketHandler.toTimestamp(this.timer.read()),
+ .timestamp = WebsocketHandler.toTimestamp(Server.global_start_time.read()),
};
},
else => {
return WatchBuildResult{
.value = .{ .fail = std.mem.zeroes(Api.WebsocketMessageBuildFailure) },
.id = id,
- .timestamp = WebsocketHandler.toTimestamp(this.timer.read()),
+ .timestamp = WebsocketHandler.toTimestamp(Server.global_start_time.read()),
};
},
}
@@ -976,6 +980,7 @@ pub const RequestContext = struct {
defer {
javascript_disabled = true;
}
+ var start_timer = std.time.Timer.start() catch unreachable;
var stdout = std.io.getStdOut();
// var stdout = std.io.bufferedWriter(stdout_file.writer());
@@ -1086,14 +1091,38 @@ pub const RequestContext = struct {
js_ast.Stmt.Data.Store.reset();
js_ast.Expr.Data.Store.reset();
JavaScript.Bun.flushCSSImports();
+ const resolved_count = vm.resolved_count;
+ const transpiled_count = vm.transpiled_count;
vm.flush();
- try runLoop(vm, handler);
+ Output.printElapsed(@intToFloat(f64, (start_timer.read())) / std.time.ns_per_ms);
+
+ if (vm.bundler.options.framework.?.display_name.len > 0) {
+ Output.prettyError(
+ " {s} ready<d>! (powered by Bun)\n<r>",
+ .{
+ vm.bundler.options.framework.?.display_name,
+ },
+ );
+ } else {
+ Output.prettyError(
+ " Bun.js started\n<r>",
+ .{},
+ );
+ }
+
+ Output.flush();
+
+ try runLoop(
+ vm,
+ handler,
+ );
}
pub fn runLoop(vm: *JavaScript.VirtualMachine, thread: *HandlerThread) !void {
var module_map = ZigGlobalObject.getModuleRegistryMap(vm.global);
JavaScript.VirtualMachine.vm.has_loaded = true;
+
while (true) {
defer {
JavaScript.VirtualMachine.vm.flush();
@@ -1101,10 +1130,12 @@ pub const RequestContext = struct {
js_ast.Stmt.Data.Store.reset();
js_ast.Expr.Data.Store.reset();
JavaScript.Bun.flushCSSImports();
+ Output.flush();
}
var handler: *JavaScriptHandler = try channel.readItem();
JavaScript.VirtualMachine.vm.preflush();
+
JavaScript.EventListenerMixin.emitFetchEvent(
vm,
&handler.ctx,
@@ -1117,8 +1148,22 @@ pub const RequestContext = struct {
var one: [1]*JavaScriptHandler = undefined;
pub fn enqueue(ctx: *RequestContext, server: *Server, filepath_buf: []u8, params: *Router.Param.List) !void {
+ if (JavaScriptHandler.javascript_disabled) {
+ try ctx.renderFallback(
+ ctx.allocator,
+ ctx.bundler,
+ Api.FallbackStep.ssr_disabled,
+ &ctx.log,
+ error.JSDisabled,
+ &.{},
+ "",
+ .{},
+ );
+ return;
+ }
var clone = try ctx.allocator.create(JavaScriptHandler);
clone.ctx = ctx.*;
+
clone.conn = ctx.conn.*;
clone.ctx.conn = &clone.conn;
@@ -1129,11 +1174,16 @@ pub const RequestContext = struct {
}
clone.ctx.matched_route.?.params = &clone.params;
-
clone.ctx.matched_route.?.file_path = filepath_buf[0..ctx.matched_route.?.file_path.len];
+
// this copy may be unnecessary, i'm not 100% sure where when
std.mem.copy(u8, &clone.ctx.match_file_path_buf, filepath_buf[0..ctx.matched_route.?.file_path.len]);
+ // Ensure the matched route name pointers to the filepath buffer instead of whatever it was before
+ if (strings.indexOf(clone.ctx.matched_route.?.file_path, ctx.matched_route.?.name)) |i| {
+ clone.ctx.matched_route.?.name = Router.Match.nameWithBasename(clone.ctx.matched_route.?.file_path, ctx.bundler.router.?.config.dir);
+ }
+
if (!has_loaded_channel) {
var handler_thread = try server.allocator.create(HandlerThread);
@@ -1348,8 +1398,8 @@ pub const RequestContext = struct {
ctx.appendHeader("Sec-WebSocket-Protocol", "bun-hmr");
try ctx.writeStatus(101);
try ctx.flushHeaders();
- Output.prettyln("<r><green>101<r><d> Hot Module Reloading connected.", .{});
- Output.flush();
+ // Output.prettyln("<r><green>101<r><d> Hot Module Reloading connected.<r>", .{});
+ // Output.flush();
var cmd: Api.WebsocketCommand = undefined;
var msg: Api.WebsocketMessage = .{
@@ -1387,7 +1437,7 @@ pub const RequestContext = struct {
while (!handler.tombstone) {
defer Output.flush();
handler.conn.client.getError() catch |err| {
- Output.prettyErrorln("<r><red>ERR:<r> <b>{s}<r>", .{err});
+ Output.prettyErrorln("<r><red>Websocket ERR:<r> <b>{s}<r>", .{err});
handler.tombstone = true;
is_socket_closed = true;
};
@@ -1395,20 +1445,20 @@ pub const RequestContext = struct {
var frame = handler.websocket.read() catch |err| {
switch (err) {
error.ConnectionClosed => {
- Output.prettyln("Websocket closed.", .{});
+ // Output.prettyln("Websocket closed.", .{});
handler.tombstone = true;
is_socket_closed = true;
continue;
},
else => {
- Output.prettyErrorln("<r><red>ERR:<r> <b>{s}<r>", .{err});
+ Output.prettyErrorln("<r><red>Websocket ERR:<r> <b>{s}<r>", .{err});
},
}
return;
};
switch (frame.header.opcode) {
.Close => {
- Output.prettyln("Websocket closed.", .{});
+ // Output.prettyln("Websocket closed.", .{});
is_socket_closed = true;
return;
},
@@ -1438,14 +1488,16 @@ pub const RequestContext = struct {
);
},
.success => {
- Output.prettyln(
- "<r><b><green>{d}ms<r> <d>built<r> <b>{s}<r><b> <r><d>({d}+ LOC)",
- .{
- build_result.timestamp - cmd.timestamp,
- file_path,
- build_result.approximate_newline_count,
- },
- );
+ if (build_result.timestamp < cmd.timestamp) {
+ Output.prettyln(
+ "<r><b><green>{d}ms<r> <d>built<r> <b>{s}<r><b> <r><d>({d}+ LOC)",
+ .{
+ build_result.timestamp - cmd.timestamp,
+ file_path,
+ build_result.approximate_newline_count,
+ },
+ );
+ }
},
}
@@ -2197,14 +2249,16 @@ pub const Server = struct {
server.bundler.options.origin.port = try std.fmt.allocPrint(server.allocator, "{d}", .{addr.ipv4.port});
}
}
-
+ const start_time = @import("root").start_time;
+ const now = std.time.nanoTimestamp();
+ Output.printStartEnd(start_time, now);
// This is technically imprecise.
// However, we want to optimize for easy to copy paste
// Nobody should get weird CORS errors when you go to the printed url.
if (std.mem.readIntNative(u32, &addr.ipv4.host.octets) == 0 or std.mem.readIntNative(u128, &addr.ipv6.host.octets) == 0) {
- Output.prettyln("<r>Started Bun at <b><cyan>http://localhost:{d}<r>", .{addr.ipv4.port});
+ Output.prettyError(" Bun!!<r>\n\n\n<d> Link:<r> <b><cyan>http://localhost:{d}<r>\n\n\n", .{addr.ipv4.port});
} else {
- Output.prettyln("<r>Started Bun at <b><cyan>http://{s}<r>", .{addr});
+ Output.prettyError(" Bun!!<r>\n\n\n<d> Link:<r> <b><cyan>http://{s}<r>\n\n\n", .{addr});
}
Output.flush();
@@ -2276,6 +2330,7 @@ pub const Server = struct {
conn.client.deinit();
return;
};
+ req_ctx.timer.reset();
if (req_ctx.url.needs_redirect) {
req_ctx.handleRedirect(req_ctx.url.path) catch |err| {
@@ -2318,7 +2373,11 @@ pub const Server = struct {
if (log.msgs.items.len == 0) {
if (!did_print) {
switch (status) {
- 101, 199...399 => {
+ // For success codes, just don't print anything.
+ // It's really noisy.
+ 200, 304, 101 => {},
+
+ 201...303, 305...399 => {
Output.prettyln("<r><green>{d}<r><d> {s} <r>{s}<d> as {s}<r>", .{ status, @tagName(req_ctx.method), req.path, req_ctx.mime_type.value });
},
400...499 => {
@@ -2336,7 +2395,11 @@ pub const Server = struct {
if (!did_print) {
switch (status) {
- 101, 199...399 => {
+ // For success codes, just don't print anything.
+ // It's really noisy.
+ 200, 304, 101 => {},
+
+ 201...303, 305...399 => {
Output.prettyln("<r><green>{d}<r><d> <r>{s}<d> {s} as {s}<r>", .{ status, @tagName(req_ctx.method), req.path, req_ctx.mime_type.value });
},
400...499 => {
@@ -2460,6 +2523,7 @@ pub const Server = struct {
};
}
+ pub var global_start_time: std.time.Timer = undefined;
pub fn start(allocator: *std.mem.Allocator, options: Api.TransformOptions) !void {
var log = logger.Log.init(allocator);
var server = try allocator.create(Server);
@@ -2471,7 +2535,7 @@ pub const Server = struct {
.transform_options = options,
.timer = try std.time.Timer.start(),
};
-
+ global_start_time = server.timer;
server.bundler = try Bundler.init(allocator, &server.log, options, null, null);
server.bundler.configureLinker();
try server.bundler.configureRouter(true);
diff --git a/src/javascript/jsc/bindings/ZigGlobalObject.cpp b/src/javascript/jsc/bindings/ZigGlobalObject.cpp
index 762f8b5cc..a251d49f1 100644
--- a/src/javascript/jsc/bindings/ZigGlobalObject.cpp
+++ b/src/javascript/jsc/bindings/ZigGlobalObject.cpp
@@ -319,7 +319,7 @@ JSC::JSInternalPromise *GlobalObject::moduleLoaderFetch(JSGlobalObject *globalOb
promise->resolve(globalObject, jsSourceCode);
globalObject->vm().drainMicrotasks();
return promise;
-}
+ }
JSC::JSObject *GlobalObject::moduleLoaderCreateImportMetaProperties(JSGlobalObject *globalObject,
JSModuleLoader *loader,
diff --git a/src/javascript/jsc/bindings/exports.zig b/src/javascript/jsc/bindings/exports.zig
index c6a6c2b88..41e13d98e 100644
--- a/src/javascript/jsc/bindings/exports.zig
+++ b/src/javascript/jsc/bindings/exports.zig
@@ -45,6 +45,9 @@ pub const ZigGlobalObject = extern struct {
sigaction.handler = .{ .sigaction = Handler.global_signal_handler_fn };
std.os.sigaction(std.os.SIGABRT, &sigaction, null);
+ if (comptime !isDebug) {
+ std.os.sigaction(std.os.SIGTRAP, &sigaction, null);
+ }
}
return shim.cppFn("create", .{ class_ref, count, console });
@@ -421,7 +424,7 @@ pub const ZigStackFrame = extern struct {
position: ZigStackFramePosition,
enable_color: bool,
origin: *const ZigURL,
-
+ root_path: string = "",
pub fn format(this: SourceURLFormatter, comptime fmt: []const u8, options: std.fmt.FormatOptions, writer: anytype) !void {
try writer.writeAll(this.origin.displayProtocol());
try writer.writeAll("://");
@@ -429,7 +432,13 @@ pub const ZigStackFrame = extern struct {
try writer.writeAll(":");
try writer.writeAll(this.origin.port);
try writer.writeAll("/blob:");
- try writer.writeAll(this.source_url.slice());
+
+ var source_slice = this.source_url.slice();
+ if (strings.startsWith(source_slice, this.root_path)) {
+ source_slice = source_slice[this.root_path.len..];
+ }
+
+ try writer.writeAll(source_slice);
if (this.position.line > -1 and this.position.column_start > -1) {
try std.fmt.format(writer, ":{d}:{d}", .{ this.position.line + 1, this.position.column_start });
} else if (this.position.line > -1) {
@@ -491,8 +500,8 @@ pub const ZigStackFrame = extern struct {
return NameFormatter{ .function_name = this.function_name, .code_type = this.code_type, .enable_color = enable_color };
}
- pub fn sourceURLFormatter(this: *const ZigStackFrame, origin: *const ZigURL, comptime enable_color: bool) SourceURLFormatter {
- return SourceURLFormatter{ .source_url = this.source_url, .origin = origin, .position = this.position, .enable_color = enable_color };
+ pub fn sourceURLFormatter(this: *const ZigStackFrame, root_path: string, origin: *const ZigURL, comptime enable_color: bool) SourceURLFormatter {
+ return SourceURLFormatter{ .source_url = this.source_url, .origin = origin, .root_path = root_path, .position = this.position, .enable_color = enable_color };
}
};
diff --git a/src/javascript/jsc/javascript.zig b/src/javascript/jsc/javascript.zig
index 8bace87e9..7c7fb48c2 100644
--- a/src/javascript/jsc/javascript.zig
+++ b/src/javascript/jsc/javascript.zig
@@ -352,6 +352,9 @@ pub const VirtualMachine = struct {
has_loaded: bool = false,
+ transpiled_count: usize = 0,
+ resolved_count: usize = 0,
+ had_errors: bool = false,
pub var vm_loaded = false;
pub var vm: *VirtualMachine = undefined;
@@ -383,6 +386,7 @@ pub const VirtualMachine = struct {
VirtualMachine.vm.* = VirtualMachine{
.global = undefined,
.allocator = allocator,
+ .entry_point = ServerEntryPoint{},
.require_cache = RequireCacheType.init(allocator),
.event_listeners = EventListenerMixin.Map.init(allocator),
.bundler = bundler,
@@ -428,10 +432,13 @@ pub const VirtualMachine = struct {
}
pub fn flush(this: *VirtualMachine) void {
+ this.had_errors = false;
for (this.flush_list.items) |item| {
this.allocator.free(item);
}
this.flush_list.shrinkRetainingCapacity(0);
+ this.transpiled_count = 0;
+ this.resolved_count = 0;
}
inline fn _fetch(
@@ -477,6 +484,8 @@ pub const VirtualMachine = struct {
// so it consistently handles bundled imports
// we can't take the shortcut of just directly importing the file, sadly.
} else if (strings.eqlComptime(_specifier, main_file_name)) {
+ defer vm.transpiled_count += 1;
+
var bundler = &vm.bundler;
var old = vm.bundler.log;
vm.bundler.log = log;
@@ -551,6 +560,7 @@ pub const VirtualMachine = struct {
switch (loader) {
.js, .jsx, .ts, .tsx, .json => {
+ vm.transpiled_count += 1;
vm.bundler.resetStore();
const hash = http.Watcher.getHash(path.text);
@@ -584,6 +594,7 @@ pub const VirtualMachine = struct {
return error.ParseError;
};
+ const start_count = vm.bundler.linker.import_counter;
// We _must_ link because:
// - node_modules bundle won't be properly
try vm.bundler.linker.link(
@@ -592,6 +603,8 @@ pub const VirtualMachine = struct {
.absolute_path,
true,
);
+ vm.resolved_count += vm.bundler.linker.import_counter - start_count;
+ vm.bundler.linker.import_counter = 0;
if (!source_code_printer_loaded) {
var writer = try js_printer.BufferWriter.init(vm.allocator);
@@ -641,6 +654,7 @@ pub const VirtualMachine = struct {
fn _resolve(ret: *ResolveFunctionResult, global: *JSGlobalObject, specifier: string, source: string) !void {
std.debug.assert(VirtualMachine.vm_loaded);
std.debug.assert(VirtualMachine.vm.global == global);
+
if (vm.node_modules == null and strings.eqlComptime(specifier, Runtime.Runtime.Imports.Name)) {
ret.path = Runtime.Runtime.Imports.Name;
return;
@@ -658,8 +672,10 @@ pub const VirtualMachine = struct {
specifier,
.stmt,
);
+
ret.result = result;
const result_path = result.pathConst() orelse return error.ModuleNotFound;
+ vm.resolved_count += 1;
if (vm.node_modules != null and result.isLikelyNodeModule()) {
const node_modules_bundle = vm.node_modules.?;
@@ -772,7 +788,8 @@ pub const VirtualMachine = struct {
threadlocal var errors_stack: [256]*c_void = undefined;
pub fn fetch(ret: *ErrorableResolvedSource, global: *JSGlobalObject, specifier: ZigString, source: ZigString) callconv(.C) void {
var log = logger.Log.init(vm.bundler.allocator);
- const result = _fetch(global, specifier.slice(), source.slice(), &log) catch |err| {
+ const spec = specifier.slice();
+ const result = _fetch(global, spec, source.slice(), &log) catch |err| {
processFetchLog(specifier, source, &log, ret, err);
return;
};
@@ -793,10 +810,17 @@ pub const VirtualMachine = struct {
ret.result.value = result;
+ const specifier_blob = brk: {
+ if (strings.startsWith(spec, VirtualMachine.vm.bundler.fs.top_level_dir)) {
+ break :brk spec[VirtualMachine.vm.bundler.fs.top_level_dir.len..];
+ }
+ break :brk spec;
+ };
+
if (vm.has_loaded) {
- vm.blobs.temporary.put(specifier.slice(), .{ .ptr = result.source_code.ptr, .len = result.source_code.len }) catch {};
+ vm.blobs.temporary.put(specifier_blob, .{ .ptr = result.source_code.ptr, .len = result.source_code.len }) catch {};
} else {
- vm.blobs.persistent.put(specifier.slice(), .{ .ptr = result.source_code.ptr, .len = result.source_code.len }) catch {};
+ vm.blobs.persistent.put(specifier_blob, .{ .ptr = result.source_code.ptr, .len = result.source_code.len }) catch {};
}
ret.success = true;
@@ -994,6 +1018,7 @@ pub const VirtualMachine = struct {
build_error.msg.formatWriter(@TypeOf(writer), writer, allow_ansi_color) catch {};
build_error.logged = true;
}
+ this.had_errors = this.had_errors or build_error.msg.kind == .err;
if (exception_list != null) {
this.log.addMsg(
build_error.msg,
@@ -1010,6 +1035,8 @@ pub const VirtualMachine = struct {
resolve_error.logged = true;
}
+ this.had_errors = this.had_errors or resolve_error.msg.kind == .err;
+
if (exception_list != null) {
this.log.addMsg(
resolve_error.msg,
@@ -1047,7 +1074,16 @@ pub const VirtualMachine = struct {
"<r> <d>at <r>{any} <d>(<r>{any}<d>)<r>\n",
allow_ansi_colors,
),
- .{ frame.nameFormatter(allow_ansi_colors), frame.sourceURLFormatter(&vm.bundler.options.origin, allow_ansi_colors) },
+ .{
+ frame.nameFormatter(
+ allow_ansi_colors,
+ ),
+ frame.sourceURLFormatter(
+ vm.bundler.fs.top_level_dir,
+ &vm.bundler.options.origin,
+ allow_ansi_colors,
+ ),
+ },
);
// if (!frame.position.isInvalid()) {
@@ -1109,6 +1145,8 @@ pub const VirtualMachine = struct {
try exception.addToErrorList(list);
}
+ this.had_errors = true;
+
var stderr: std.fs.File = Output.errorStream();
var buffered = std.io.bufferedWriter(stderr.writer());
var writer = buffered.writer();
diff --git a/src/javascript/jsc/webcore/response.zig b/src/javascript/jsc/webcore/response.zig
index 55e4a753e..b62645218 100644
--- a/src/javascript/jsc/webcore/response.zig
+++ b/src/javascript/jsc/webcore/response.zig
@@ -1132,7 +1132,21 @@ pub const FetchEvent = struct {
return js.JSValueMakeUndefined(ctx);
};
- defer this.request_context.arena.deinit();
+ defer {
+ if (!VirtualMachine.vm.had_errors) {
+ Output.printElapsed(@intToFloat(f64, (this.request_context.timer.lap())) / std.time.ns_per_ms);
+
+ Output.prettyError(
+ " <b>/{s}<r><d> - <b>{d}<r> <d>transpiled, <d><b>{d}<r> <d>imports<r>\n",
+ .{
+ this.request_context.matched_route.?.name,
+ VirtualMachine.vm.transpiled_count,
+ VirtualMachine.vm.resolved_count,
+ },
+ );
+ }
+ this.request_context.arena.deinit();
+ }
var needs_mime_type = true;
var content_length: ?usize = null;
diff --git a/src/js_parser/js_parser.zig b/src/js_parser/js_parser.zig
index f6c43a452..a1d4f04a4 100644
--- a/src/js_parser/js_parser.zig
+++ b/src/js_parser/js_parser.zig
@@ -452,6 +452,8 @@ pub const ImportScanner = struct {
}
},
.s_export_default => |st| {
+ // This is defer'd so that we still record export default for identifiers
+ defer p.recordExport(st.default_name.loc, "default", st.default_name.ref.?) catch {};
// Rewrite this export to be:
// exports.default =
@@ -523,7 +525,7 @@ pub const ImportScanner = struct {
stmt = p.s(S.Local{
.decls = decls,
.kind = S.Local.Kind.k_var,
- .is_export = true,
+ .is_export = false,
}, stmt.loc);
},
.s_class => |class| {
@@ -560,8 +562,6 @@ pub const ImportScanner = struct {
}
}
}
-
- try p.recordExport(st.default_name.loc, "default", st.default_name.ref.?);
},
.s_export_clause => |st| {
for (st.items) |item| {
diff --git a/src/js_printer.zig b/src/js_printer.zig
index 0f0a493de..bf9286a9d 100644
--- a/src/js_printer.zig
+++ b/src/js_printer.zig
@@ -3427,6 +3427,12 @@ pub fn NewPrinter(
}
pub fn printLoadFromBundleWithoutCall(p: *Printer, import_record_index: u32) void {
const record = p.import_records[import_record_index];
+ if (record.path.is_disabled) {
+ p.print("(() => ({}))");
+ return;
+ }
+
+ std.debug.assert(record.module_id != 0); // either module_id is forgotten or it should be disabled
p.print("$");
std.fmt.formatInt(record.module_id, 16, .lower, .{}, p) catch unreachable;
}
diff --git a/src/linker.zig b/src/linker.zig
index d6ed3d8fc..09fac6845 100644
--- a/src/linker.zig
+++ b/src/linker.zig
@@ -47,6 +47,7 @@ pub fn NewLinker(comptime BundlerType: type) type {
runtime_import_record: ?ImportRecord = null,
runtime_source_path: string,
hashed_filenames: HashedFileNameMap,
+ import_counter: usize = 0,
onImportCSS: ?OnImportCallback = null,
@@ -566,7 +567,7 @@ pub fn NewLinker(comptime BundlerType: type) type {
import_record: *ImportRecord,
comptime import_path_format: Options.BundleOptions.ImportPathFormat,
) !void {
-
+ linker.import_counter += 1;
// lazy means:
// Run the resolver
// Don't parse/print automatically.
diff --git a/src/main.zig b/src/main.zig
index 22631e58d..133e4f10f 100644
--- a/src/main.zig
+++ b/src/main.zig
@@ -24,8 +24,10 @@ pub fn panic(msg: []const u8, error_return_trace: ?*std.builtin.StackTrace) nore
panicky.default_panic(msg, error_return_trace);
}
}
-
+pub var start_time: i128 = 0;
pub fn main() anyerror!void {
+ start_time = std.time.nanoTimestamp();
+
// The memory allocator makes a massive difference.
// std.heap.raw_c_allocator and default_allocator perform similarly.
// std.heap.GeneralPurposeAllocator makes this about 3x _slower_ than esbuild.
diff --git a/src/options.zig b/src/options.zig
index f5b636d5f..6d73afe6d 100644
--- a/src/options.zig
+++ b/src/options.zig
@@ -1602,6 +1602,7 @@ pub const Framework = struct {
server: EntryPoint = EntryPoint{},
fallback: EntryPoint = EntryPoint{},
+ display_name: string = "",
package: string = "",
development: bool = true,
resolved: bool = false,
@@ -1628,6 +1629,7 @@ pub const Framework = struct {
.development = loaded.development,
.from_bundle = true,
.client_css_in_js = loaded.client_css_in_js,
+ .display_name = loaded.display_name,
};
if (loaded.entry_points.fallback) |fallback| {
@@ -1655,6 +1657,7 @@ pub const Framework = struct {
return Api.LoadedFramework{
.package = this.package,
.development = this.development,
+ .display_name = this.display_name,
.entry_points = .{
.client = try this.client.toAPI(allocator, toplevel_path, .client),
.fallback = try this.fallback.toAPI(allocator, toplevel_path, .fallback),
@@ -1693,6 +1696,7 @@ pub const Framework = struct {
.server = server,
.fallback = fallback,
.package = transform.package orelse "",
+ .display_name = transform.display_name orelse "",
.development = transform.development orelse true,
.resolved = false,
.client_css_in_js = switch (transform.client_css_in_js orelse .auto_onimportcss) {
diff --git a/src/renamer.zig b/src/renamer.zig
index c867b71be..0ed434105 100644
--- a/src/renamer.zig
+++ b/src/renamer.zig
@@ -20,6 +20,7 @@ pub const Renamer = struct {
}
const resolved = renamer.symbols.follow(ref);
+
if (renamer.symbols.get(resolved)) |symbol| {
return symbol.original_name;
} else {
@@ -30,7 +31,7 @@ pub const Renamer = struct {
pub const DisabledRenamer = struct {
pub fn init(symbols: js_ast.Symbol.Map) DisabledRenamer {}
- pub fn nameForSymbol(renamer: *Renamer, ref: js_ast.Ref) callconv(.Inline) string {
+ pub inline fn nameForSymbol(renamer: *Renamer, ref: js_ast.Ref) string {
@compileError("DisabledRunner called");
}
};
diff --git a/src/resolver/package_json.zig b/src/resolver/package_json.zig
index 13ac223e5..4547be9db 100644
--- a/src/resolver/package_json.zig
+++ b/src/resolver/package_json.zig
@@ -242,6 +242,14 @@ pub const PackageJSON = struct {
) void {
const framework_object = json.asProperty("framework") orelse return;
+ if (framework_object.expr.asProperty("displayName")) |name| {
+ if (name.expr.asString(allocator)) |str| {
+ if (str.len > 0) {
+ pair.framework.display_name = str;
+ }
+ }
+ }
+
if (framework_object.expr.asProperty("static")) |static_prop| {
if (static_prop.expr.asString(allocator)) |str| {
if (str.len > 0) {
diff --git a/src/router.zig b/src/router.zig
index 53c7f126f..6b05a498b 100644
--- a/src/router.zig
+++ b/src/router.zig
@@ -417,7 +417,7 @@ pub const RouteMap = struct {
match_result = Match{
.path = head.path,
- .name = file_path,
+ .name = Match.nameWithBasename(file_path, this.map.config.dir),
.params = this.params,
.hash = head.full_hash,
.query_string = this.url_path.query_string,
@@ -533,15 +533,15 @@ pub const RouteMap = struct {
if (child_hash == index_route_hash) {
const entry = Fs.FileSystem.DirEntry.EntryStore.instance.at(routes_slice.items(.entry_index)[i + route.children.offset]).?;
const parts = [_]string{ entry.dir, entry.base() };
-
+ const file_path = Fs.FileSystem.instance.absBuf(&parts, file_path_buf);
return Match{
.params = params,
- .name = routes_slice.items(.name)[i],
+ .name = Match.nameWithBasename(file_path, this.config.dir),
.path = routes_slice.items(.path)[i],
.pathname = url_path.pathname,
.basename = entry.base(),
.hash = child_hash,
- .file_path = Fs.FileSystem.instance.absBuf(&parts, file_path_buf),
+ .file_path = file_path,
.query_string = url_path.query_string,
.client_framework_enabled = this.client_framework_enabled,
};
@@ -552,16 +552,17 @@ pub const RouteMap = struct {
} else {
const entry = Fs.FileSystem.DirEntry.EntryStore.instance.at(route.entry_index).?;
const parts = [_]string{ entry.dir, entry.base() };
+ const file_path = Fs.FileSystem.instance.absBuf(&parts, file_path_buf);
return Match{
.params = params,
- .name = route.name,
+ .name = Match.nameWithBasename(file_path, this.config.dir),
.path = route.path,
.redirect_path = if (redirect) path else null,
.hash = full_hash,
.basename = entry.base(),
.pathname = url_path.pathname,
.query_string = url_path.query_string,
- .file_path = Fs.FileSystem.instance.absBuf(&parts, file_path_buf),
+ .file_path = file_path,
.client_framework_enabled = this.client_framework_enabled,
};
}
@@ -604,10 +605,6 @@ pub const RouteMap = struct {
if (ctx.matchDynamicRoute(0, 0)) |_dynamic_route| {
// route name == the filesystem path relative to the pages dir excluding the file extension
var dynamic_route = _dynamic_route;
- dynamic_route.name = dynamic_route.name[this.config.dir.len..];
- dynamic_route.name = dynamic_route.name[0 .. dynamic_route.name.len - std.fs.path.extension(dynamic_route.file_path).len];
- std.debug.assert(dynamic_route.name.len > 0);
- if (dynamic_route.name[0] == '/') dynamic_route.name = dynamic_route.name[1..];
dynamic_route.client_framework_enabled = this.client_framework_enabled;
return dynamic_route;
}
@@ -745,6 +742,15 @@ pub const Match = struct {
redirect_path: ?string = null,
query_string: string = "",
+ pub fn nameWithBasename(file_path: string, dir: string) string {
+ var name = file_path;
+ if (strings.indexOf(name, dir)) |i| {
+ name = name[i + dir.len ..];
+ }
+
+ return name[0 .. name.len - std.fs.path.extension(name).len];
+ }
+
pub fn pathnameWithoutLeadingSlash(this: *const Match) string {
return std.mem.trimLeft(u8, this.pathname, "/");
}
diff --git a/src/test/fixtures/default_export_hmr_identifier_ref.tsx b/src/test/fixtures/default_export_hmr_identifier_ref.tsx
new file mode 100644
index 000000000..4c742c6ef
--- /dev/null
+++ b/src/test/fixtures/default_export_hmr_identifier_ref.tsx
@@ -0,0 +1,5 @@
+const Button = forwardRef<HTMLButtonElement, Props>(({}, ref) => {});
+
+Button.displayName = "Button";
+
+export default React.memo(Button);
diff --git a/src/test/fixtures/keyword-in-property-binding.tsx b/src/test/fixtures/keyword-in-property-binding.tsx
new file mode 100644
index 000000000..1a667cde4
--- /dev/null
+++ b/src/test/fixtures/keyword-in-property-binding.tsx
@@ -0,0 +1,8 @@
+const FooBar = {};
+const ImportNamespace = {
+ default: FooBar,
+};
+
+const { default: App } = ImportNamespace;
+
+console.log(FooBar || App);