aboutsummaryrefslogtreecommitdiff
path: root/src/runtime.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/runtime.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/runtime.zig')
-rw-r--r--src/runtime.zig33
1 files changed, 14 insertions, 19 deletions
diff --git a/src/runtime.zig b/src/runtime.zig
index fcec8549b..c942afb13 100644
--- a/src/runtime.zig
+++ b/src/runtime.zig
@@ -15,6 +15,7 @@ const Fs = @import("./fs.zig");
const Schema = @import("./api/schema.zig");
const Ref = @import("ast/base.zig").Ref;
const JSAst = @import("./js_ast.zig");
+const content = @import("root").content;
// packages/bun-cli-*/bun
const BUN_ROOT = "../../";
@@ -31,27 +32,22 @@ fn embedDebugFallback(comptime msg: []const u8, comptime code: []const u8) []con
return code;
}
pub const ErrorCSS = struct {
- const ErrorCSSPath = "packages/bun-error/dist/bun-error.css";
- const ErrorCSSPathDev = "packages/bun-error/bun-error.css";
-
- pub const ProdSourceContent = @embedFile("../" ++ ErrorCSSPath);
-
pub inline fn sourceContent() string {
if (comptime Environment.isDebug) {
var out_buffer: [bun.MAX_PATH_BYTES]u8 = undefined;
var dirname = std.fs.selfExeDirPath(&out_buffer) catch unreachable;
- var paths = [_]string{ dirname, BUN_ROOT, ErrorCSSPathDev };
+ var paths = [_]string{ dirname, BUN_ROOT, content.error_css_path };
const file = std.fs.cwd().openFile(
resolve_path.joinAbsString(dirname, std.mem.span(&paths), .auto),
.{ .mode = .read_only },
) catch return embedDebugFallback(
"Missing packages/bun-error/bun-error.css. Please run \"make bun_error\"",
- ProdSourceContent,
+ content.error_css,
);
defer file.close();
return file.readToEndAlloc(default_allocator, (file.stat() catch unreachable).size) catch unreachable;
} else {
- return ProdSourceContent;
+ return content.error_css;
}
}
};
@@ -59,26 +55,22 @@ pub const ErrorCSS = struct {
pub const ReactRefresh = @embedFile("./react-refresh.js");
pub const ErrorJS = struct {
- const ErrorJSPath = "packages/bun-error/dist/index.js";
-
- pub const ProdSourceContent = @embedFile("../" ++ ErrorJSPath);
-
pub inline fn sourceContent() string {
if (comptime Environment.isDebug) {
var out_buffer: [bun.MAX_PATH_BYTES]u8 = undefined;
var dirname = std.fs.selfExeDirPath(&out_buffer) catch unreachable;
- var paths = [_]string{ dirname, BUN_ROOT, ErrorJSPath };
+ var paths = [_]string{ dirname, BUN_ROOT, content.error_js_path };
const file = std.fs.cwd().openFile(
resolve_path.joinAbsString(dirname, std.mem.span(&paths), .auto),
.{ .mode = .read_only },
) catch return embedDebugFallback(
- "Missing " ++ ErrorJSPath ++ ". Please run \"make bun_error\"",
- ProdSourceContent,
+ "Missing " ++ content.error_js_path ++ ". Please run \"make bun_error\"",
+ content.error_js,
);
defer file.close();
return file.readToEndAlloc(default_allocator, (file.stat() catch unreachable).size) catch unreachable;
} else {
- return ProdSourceContent;
+ return content.error_js;
}
}
};
@@ -124,8 +116,9 @@ pub const Fallback = struct {
};
pub inline fn scriptContent() string {
+ if (true) return;
if (comptime Environment.isDebug) {
- var dirpath = std.fs.path.dirname(@src().file).?;
+ var dirpath = comptime bun.Environment.base_path ++ std.fs.path.dirname(@src().file).?;
var env = std.process.getEnvMap(default_allocator) catch unreachable;
const dir = std.mem.replaceOwned(
@@ -173,6 +166,7 @@ pub const Fallback = struct {
fallback: string,
entry_point: string,
};
+ if (true) return;
try writer.print(HTMLTemplate, PrintArgs{
.blob = Base64FallbackMessage{ .msg = msg, .allocator = allocator },
.preload = preload,
@@ -194,6 +188,7 @@ pub const Fallback = struct {
fallback: string,
bun_error_page_css: string,
};
+ if (true) return;
try writer.print(HTMLBackendTemplate, PrintArgs{
.blob = Base64FallbackMessage{ .msg = msg, .allocator = allocator },
.bun_error_css = ErrorCSS.sourceContent(),
@@ -212,7 +207,7 @@ pub const Runtime = struct {
pub inline fn sourceContentWithoutRefresh() string {
if (comptime Environment.isDebug) {
- var dirpath = std.fs.path.dirname(@src().file).?;
+ var dirpath = comptime bun.Environment.base_path ++ std.fs.path.dirname(@src().file).?;
var env = std.process.getEnvMap(default_allocator) catch unreachable;
const dir = std.mem.replaceOwned(
@@ -249,7 +244,7 @@ pub const Runtime = struct {
pub inline fn sourceContentWithRefresh() string {
if (comptime Environment.isDebug) {
- var dirpath = std.fs.path.dirname(@src().file).?;
+ var dirpath = comptime bun.Environment.base_path ++ std.fs.path.dirname(@src().file).?;
var env = std.process.getEnvMap(default_allocator) catch unreachable;
const dir = std.mem.replaceOwned(