aboutsummaryrefslogtreecommitdiff
path: root/src/options.zig
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <jarred@jarredsumner.com> 2022-12-28 00:51:22 -0800
committerGravatar GitHub <noreply@github.com> 2022-12-28 00:51:22 -0800
commitc0dd2841362b67fdb5ede262b19688004a4eb9a4 (patch)
treea3cd6b353c25c30d66489de61b394af7d5568fed /src/options.zig
parent504972fa5deb92f2d0510d42f11b085351915a32 (diff)
downloadbun-c0dd2841362b67fdb5ede262b19688004a4eb9a4.tar.gz
bun-c0dd2841362b67fdb5ede262b19688004a4eb9a4.tar.zst
bun-c0dd2841362b67fdb5ede262b19688004a4eb9a4.zip
Upgrade to latest Zig (#1610)
* @min and @max * builtins and some trivial ones * Most of them * more * more! * More Progress * wip * Update tagged_pointer.zig * Update http_client_async.zig * Most of the iterable dir changes * alright * Remove usages of deprecated formatters * :camera: * fmt * Update shimmer.zig * wip * wip * wip * progress * more * Latest * stuck on error * latest * workaround stage2 * wip * Update string_immutable.zig * wip * Migrate `Dirent` and `require("fs')` to use JSC<>Zig bindings * Fix build errors * Fixup most of the test failures * Fix `make headers` * Fix "outside package path" error * Fixup aligned alloc * Add missing file * linux * More linux fixes * use latest peechy * Fix transpiler test failure * Forgot about these * Fixup test failure * Update node-timers.test.ts * [node:htt] Fix `undefined is not an object` error Fixes https://github.com/oven-sh/bun/issues/1618 * Update http.exports.js * Make this test less flaky * fix hashes * Fix hex formatting and zls issues * Download zig version * Update Dockerfile * Update Dockerfile * Update uws * Update Dockerfile * Set llvm version * Update README.md * Update uws * Update Dockerfile * Update io_linux.zig * Update bun.zig * Log output * workaround strange @cInclude error * Make ffi tests better * Don't use cImport * Update c.zig * Update c-bindings.cpp * call setOutputDir * Update Dockerfile * Use a longer name * latest * Update serve.test.ts Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> Co-authored-by: Veikka Tuominen <git@vexu.eu>
Diffstat (limited to 'src/options.zig')
-rw-r--r--src/options.zig31
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 = "",