diff options
Diffstat (limited to 'src/options.zig')
-rw-r--r-- | src/options.zig | 31 |
1 files changed, 17 insertions, 14 deletions
diff --git a/src/options.zig b/src/options.zig index cc0f5d9e4..024ff188a 100644 --- a/src/options.zig +++ b/src/options.zig @@ -79,9 +79,9 @@ pub fn stringHashMapFromArrays(comptime t: type, allocator: std.mem.Allocator, k } pub const ExternalModules = struct { - node_modules: std.BufSet, - abs_paths: std.BufSet, - patterns: []const WildcardPattern, + node_modules: std.BufSet = undefined, + abs_paths: std.BufSet = undefined, + patterns: []const WildcardPattern = undefined, pub const WildcardPattern = struct { prefix: string, suffix: string, @@ -169,7 +169,7 @@ pub const ExternalModules = struct { } } - result.patterns = patterns.toOwnedSlice(); + result.patterns = patterns.toOwnedSlice() catch @panic("TODO"); return result; } @@ -1160,7 +1160,7 @@ pub const SourceMapOption = enum { pub fn toAPI(source_map: ?SourceMapOption) Api.SourceMapMode { return switch (source_map orelse .none) { .external => .external, - .@"inline" => .@"inline_into_file", + .@"inline" => .inline_into_file, else => ._none, }; } @@ -1168,7 +1168,7 @@ pub const SourceMapOption = enum { pub const map = ComptimeStringMap(SourceMapOption, .{ .{ "none", .none }, .{ "inline", .@"inline" }, - .{ "external", .@"external" }, + .{ "external", .external }, }); }; @@ -1416,7 +1416,7 @@ pub const BundleOptions = struct { opts.node_modules_bundle = node_mods; const pretty_path = fs.relativeTo(transform.node_modules_bundle_path.?); opts.node_modules_bundle_url = try std.fmt.allocPrint(allocator, "{s}{s}", .{ - opts.origin, + opts.origin.href, pretty_path, }); } else if (transform.node_modules_bundle_path) |bundle_path| { @@ -1547,7 +1547,7 @@ pub const BundleOptions = struct { if (!disabled_static) { var _dirs = [_]string{chosen_dir}; opts.routes.static_dir = try fs.absAlloc(allocator, &_dirs); - opts.routes.static_dir_handle = std.fs.openDirAbsolute(opts.routes.static_dir, .{ .iterate = true }) catch |err| brk: { + const static_dir = std.fs.openIterableDirAbsolute(opts.routes.static_dir, .{}) catch |err| brk: { switch (err) { error.FileNotFound => { opts.routes.static_dir_enabled = false; @@ -1570,6 +1570,9 @@ pub const BundleOptions = struct { break :brk null; }; + if (static_dir) |handle| { + opts.routes.static_dir_handle = handle.dir; + } opts.routes.static_dir_enabled = opts.routes.static_dir_handle != null; } @@ -1669,13 +1672,13 @@ pub const BundleOptions = struct { }; pub fn openOutputDir(output_dir: string) !std.fs.Dir { - return std.fs.cwd().openDir(output_dir, std.fs.Dir.OpenDirOptions{ .iterate = true }) catch brk: { + return std.fs.cwd().openDir(output_dir, .{}) catch brk: { std.fs.cwd().makeDir(output_dir) catch |err| { Output.printErrorln("error: Unable to mkdir \"{s}\": \"{s}\"", .{ output_dir, @errorName(err) }); Global.crash(); }; - var handle = std.fs.cwd().openDir(output_dir, std.fs.Dir.OpenDirOptions{ .iterate = true }) catch |err2| { + var handle = std.fs.cwd().openDir(output_dir, .{}) catch |err2| { Output.printErrorln("error: Unable to open \"{s}\": \"{s}\"", .{ output_dir, @errorName(err2) }); Global.crash(); }; @@ -1875,8 +1878,8 @@ pub const TransformResult = struct { return TransformResult{ .outbase = outbase, .output_files = output_files, - .errors = errors.toOwnedSlice(), - .warnings = warnings.toOwnedSlice(), + .errors = try errors.toOwnedSlice(), + .warnings = try warnings.toOwnedSlice(), }; } }; @@ -2080,7 +2083,7 @@ pub const Framework = struct { from_bundle: bool = false, resolved_dir: string = "", - override_modules: Api.StringMap = Api.StringMap{}, + override_modules: Api.StringMap, override_modules_hashes: []u64 = &[_]u64{}, client_css_in_js: Api.CssInJsBehavior = .auto_onimportcss, @@ -2199,7 +2202,7 @@ pub const RouteConfig = struct { // I think it's fine to hardcode as .json for now, but if I personally were writing a framework // I would consider using a custom binary format to minimize request size // maybe like CBOR - extensions: []const string = &[_][]const string{}, + extensions: []const string = &[_]string{}, routes_enabled: bool = false, static_dir: string = "", |