Skip to content

Commit

Permalink
format: replace @import("./foo.zig") with @import("foo.zig")
Browse files Browse the repository at this point in the history
`@import("./foo.zig")` and `@import("foo.zig")` are equivalent, and
ziglang/zig uses `@import("foo.zig")` in their lib/std since `./` is
redundant.

Even in C++, this is not the case. `#include "foo.h"` is common, whereas
`#include "./foo.h"` is not.
  • Loading branch information
fel1x-developer committed Jan 22, 2025
1 parent 2cf247a commit c005053
Show file tree
Hide file tree
Showing 180 changed files with 890 additions and 890 deletions.
8 changes: 4 additions & 4 deletions root.zig
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
pub usingnamespace @import("./src/main.zig");
pub usingnamespace @import("src/main.zig");

/// These functions are used throughout Bun's codebase.
pub const bun = @import("./src/bun.zig");
pub const bun = @import("src/bun.zig");

pub const completions = struct {
pub const bash = @embedFile("./completions/bun.bash");
pub const zsh = @embedFile("./completions/bun.zsh");
pub const fish = @embedFile("./completions/bun.fish");
};

pub const JavaScriptCore = @import("./src/jsc.zig");
pub const C = @import("./src/c.zig");
pub const JavaScriptCore = @import("src/jsc.zig");
pub const C = @import("src/c.zig");
10 changes: 5 additions & 5 deletions src/Global.zig
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
const std = @import("std");
const Environment = @import("./env.zig");
const Environment = @import("env.zig");

const Output = @import("output.zig");
const use_mimalloc = bun.use_mimalloc;
const StringTypes = @import("./string_types.zig");
const StringTypes = @import("string_types.zig");
const Mimalloc = bun.Mimalloc;
const bun = @import("root").bun;

Expand Down Expand Up @@ -155,15 +155,15 @@ pub inline fn mimalloc_cleanup(force: bool) void {
Mimalloc.mi_collect(force);
}
}
pub const versions = @import("./generated_versions_list.zig");
pub const versions = @import("generated_versions_list.zig");

// Enabling huge pages slows down bun by 8x or so
// Keeping this code for:
// 1. documentation that an attempt was made
// 2. if I want to configure allocator later
pub inline fn configureAllocator(_: AllocatorConfiguration) void {
// if (comptime !use_mimalloc) return;
// const Mimalloc = @import("./allocators/mimalloc.zig");
// const Mimalloc = @import("allocators/mimalloc.zig");
// Mimalloc.mi_option_set_enabled(Mimalloc.mi_option_verbose, config.verbose);
// Mimalloc.mi_option_set_enabled(Mimalloc.mi_option_large_os_pages, config.long_running);
// if (!config.long_running) Mimalloc.mi_option_set(Mimalloc.mi_option_reset_delay, 0);
Expand All @@ -187,7 +187,7 @@ pub const BunInfo = struct {
bun_version: string,
platform: Analytics.GenerateHeader.GeneratePlatform.Platform,

const Analytics = @import("./analytics/analytics_thread.zig");
const Analytics = @import("analytics/analytics_thread.zig");
const JSON = bun.JSON;
const JSAst = bun.JSAst;
pub fn generate(comptime Bundler: type, _: Bundler, allocator: std.mem.Allocator) !JSAst.Expr {
Expand Down
6 changes: 3 additions & 3 deletions src/HTMLScanner.zig
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
const std = @import("std");
const bun = @import("root").bun;
const string = bun.string;
const ImportRecord = @import("./import_record.zig").ImportRecord;
const ImportKind = @import("./import_record.zig").ImportKind;
const lol = @import("./deps/lol-html.zig");
const ImportRecord = @import("import_record.zig").ImportRecord;
const ImportKind = @import("import_record.zig").ImportKind;
const lol = @import("deps/lol-html.zig");
const logger = bun.logger;
const fs = bun.fs;

Expand Down
8 changes: 4 additions & 4 deletions src/OutputFile.zig
Original file line number Diff line number Diff line change
Expand Up @@ -532,8 +532,8 @@ const std = @import("std");
const bun = @import("root").bun;
const JSC = bun.JSC;
const Fs = bun.fs;
const Loader = @import("./options.zig").Loader;
const resolver = @import("./resolver/resolver.zig");
const resolve_path = @import("./resolver/resolve_path.zig");
const Output = @import("./Global.zig").Output;
const Loader = @import("options.zig").Loader;
const resolver = @import("resolver/resolver.zig");
const resolve_path = @import("resolver/resolve_path.zig");
const Output = @import("Global.zig").Output;
const Environment = bun.Environment;
2 changes: 1 addition & 1 deletion src/StandaloneModuleGraph.zig
Original file line number Diff line number Diff line change
Expand Up @@ -652,7 +652,7 @@ pub const StandaloneModuleGraph = struct {
return cloned_executable_fd;
}

pub const CompileTarget = @import("./compile_target.zig");
pub const CompileTarget = @import("compile_target.zig");

pub fn download(allocator: std.mem.Allocator, target: *const CompileTarget, env: *bun.DotEnv.Loader) ![:0]const u8 {
var exe_path_buf: bun.PathBuffer = undefined;
Expand Down
12 changes: 6 additions & 6 deletions src/Watcher.zig
Original file line number Diff line number Diff line change
Expand Up @@ -121,13 +121,13 @@ pub const max_eviction_count = 8096;

const log = bun.Output.scoped(.watcher, false);

const WindowsWatcher = @import("./watcher/WindowsWatcher.zig");
const WindowsWatcher = @import("watcher/WindowsWatcher.zig");
// TODO: some platform-specific behavior is implemented in
// this file instead of the platform-specific file.
// ideally, the constants above can be inlined
const Platform = switch (Environment.os) {
.linux => @import("./watcher/INotifyWatcher.zig"),
.mac => @import("./watcher/KEventWatcher.zig"),
.linux => @import("watcher/INotifyWatcher.zig"),
.mac => @import("watcher/KEventWatcher.zig"),
.windows => WindowsWatcher,
else => @compileError("Unsupported platform"),
};
Expand Down Expand Up @@ -664,7 +664,7 @@ const Environment = bun.Environment;
const strings = bun.strings;
const stringZ = bun.stringZ;
const FeatureFlags = bun.FeatureFlags;
const options = @import("./options.zig");
const options = @import("options.zig");
const Mutex = bun.Mutex;
const Futex = @import("./futex.zig");
const PackageJSON = @import("./resolver/package_json.zig").PackageJSON;
const Futex = @import("futex.zig");
const PackageJSON = @import("resolver/package_json.zig").PackageJSON;
4 changes: 2 additions & 2 deletions src/allocators.zig
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const std = @import("std");

const FeatureFlags = @import("./feature_flags.zig");
const Environment = @import("./env.zig");
const FeatureFlags = @import("feature_flags.zig");
const Environment = @import("env.zig");
const FixedBufferAllocator = std.heap.FixedBufferAllocator;
const bun = @import("root").bun;
const OOM = bun.OOM;
Expand Down
2 changes: 1 addition & 1 deletion src/allocators/memory_allocator.zig
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const bun = @import("root").bun;
const log = bun.Output.scoped(.mimalloc, true);
const assert = bun.assert;
const Allocator = mem.Allocator;
const mimalloc = @import("./mimalloc.zig");
const mimalloc = @import("mimalloc.zig");
const FeatureFlags = @import("../feature_flags.zig");
const Environment = @import("../env.zig");

Expand Down
2 changes: 1 addition & 1 deletion src/allocators/mimalloc_arena.zig
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const mem = @import("std").mem;
const builtin = @import("std").builtin;
const std = @import("std");

const mimalloc = @import("./mimalloc.zig");
const mimalloc = @import("mimalloc.zig");
const Environment = @import("../env.zig");
const FeatureFlags = @import("../feature_flags.zig");
const Allocator = mem.Allocator;
Expand Down
4 changes: 2 additions & 2 deletions src/analytics/analytics_thread.zig
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ const HTTP = bun.http;

const URL = @import("../url.zig").URL;
const Fs = @import("../fs.zig");
const Analytics = @import("./analytics_schema.zig").analytics;
const Writer = @import("./analytics_schema.zig").Writer;
const Analytics = @import("analytics_schema.zig").analytics;
const Writer = @import("analytics_schema.zig").Writer;
const Headers = bun.http.Headers;
const Futex = @import("../futex.zig");
const Semver = @import("../install/semver.zig");
Expand Down
2 changes: 1 addition & 1 deletion src/async/windows_event_loop.zig
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ pub const KeepAlive = struct {
}
};

const Posix = @import("./posix_event_loop.zig");
const Posix = @import("posix_event_loop.zig");

pub const FilePoll = struct {
fd: bun.FileDescriptor,
Expand Down
4 changes: 2 additions & 2 deletions src/baby_list.zig
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const std = @import("std");
const Environment = @import("./env.zig");
const strings = @import("./string_immutable.zig");
const Environment = @import("env.zig");
const strings = @import("string_immutable.zig");
const bun = @import("root").bun;

/// This is like ArrayList except it stores the length and capacity as u32
Expand Down
6 changes: 3 additions & 3 deletions src/bake/bake.zig
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
//! server, server components, and other integrations. Instead of taking the
//! role as a framework, Bake is tool for frameworks to build on top of.

pub const production = @import("./production.zig");
pub const DevServer = @import("./DevServer.zig");
pub const FrameworkRouter = @import("./FrameworkRouter.zig");
pub const production = @import("production.zig");
pub const DevServer = @import("DevServer.zig");
pub const FrameworkRouter = @import("FrameworkRouter.zig");

/// export default { app: ... };
pub const api_name = "app";
Expand Down
8 changes: 4 additions & 4 deletions src/bindgen.zig
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
pub const bindgen = true;

pub const main = @import("./bun.js/bindings/bindings-generator.zig").main;
pub const main = @import("bun.js/bindings/bindings-generator.zig").main;
pub export fn PLCrashReportHandler(_: ?*anyopaque) void {}
pub export fn mkdirp(_: ?*anyopaque) void {}
pub const build_options = @import("build_options");
pub const bun = @import("./BunObject.zig");
pub const JavaScriptCore = @import("./jsc.zig");
pub const C = @import("./c.zig");
pub const bun = @import("BunObject.zig");
pub const JavaScriptCore = @import("jsc.zig");
pub const C = @import("c.zig");
6 changes: 3 additions & 3 deletions src/boringssl.zig
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
const boring = @import("./deps/boringssl.translated.zig");
const boring = @import("deps/boringssl.translated.zig");
pub usingnamespace boring;
const std = @import("std");
const bun = @import("root").bun;
const c_ares = @import("./deps/c_ares.zig");
const c_ares = @import("deps/c_ares.zig");
const strings = bun.strings;
const builtin = @import("builtin");
const X509 = @import("./bun.js/api/bun/x509.zig");
const X509 = @import("bun.js/api/bun/x509.zig");

var loaded = false;
pub fn load() void {
Expand Down
4 changes: 2 additions & 2 deletions src/brotli.zig
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
const bun = @import("root").bun;
const std = @import("std");
pub const c = struct {
pub usingnamespace @import("./deps/brotli_decoder.zig");
pub usingnamespace @import("./deps/brotli_encoder.zig");
pub usingnamespace @import("deps/brotli_decoder.zig");
pub usingnamespace @import("deps/brotli_encoder.zig");
};
const BrotliDecoder = c.BrotliDecoder;
const BrotliEncoder = c.BrotliEncoder;
Expand Down
4 changes: 2 additions & 2 deletions src/bun.js/ConsoleObject.zig
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const bun = @import("root").bun;
const JSC = bun.JSC;
const Output = bun.Output;
const ConsoleObject = @This();
const Shimmer = @import("./bindings/shimmer.zig").Shimmer;
const Shimmer = @import("bindings/shimmer.zig").Shimmer;
const String = bun.String;
const JSGlobalObject = JSC.JSGlobalObject;
const JSValue = JSC.JSValue;
Expand All @@ -18,7 +18,7 @@ const ScriptArguments = opaque {};
const JSPrinter = bun.js_printer;
const Environment = bun.Environment;
const default_allocator = bun.default_allocator;
const JestPrettyFormat = @import("./test/pretty_format.zig").JestPrettyFormat;
const JestPrettyFormat = @import("test/pretty_format.zig").JestPrettyFormat;
const JSPromise = JSC.JSPromise;
const EventType = JSC.EventType;
pub const shim = Shimmer("Bun", "ConsoleObject", @This());
Expand Down
6 changes: 3 additions & 3 deletions src/bun.js/api/BunObject.zig
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ const ImportKind = ast.ImportKind;
const Analytics = @import("../../analytics/analytics_thread.zig");
const ZigString = bun.JSC.ZigString;
const Runtime = @import("../../runtime.zig");
const Router = @import("./filesystem_router.zig");
const Router = @import("filesystem_router.zig");
const ImportRecord = ast.ImportRecord;
const DotEnv = @import("../../env_loader.zig");
const ParseResult = bun.transpiler.ParseResult;
Expand Down Expand Up @@ -3611,7 +3611,7 @@ const TOMLObject = struct {

const Debugger = JSC.Debugger;

pub const Timer = @import("./Timer.zig");
pub const Timer = @import("Timer.zig");

pub const FFIObject = struct {
const fields = .{
Expand Down Expand Up @@ -4597,7 +4597,7 @@ pub const JSZlib = struct {
}
};

pub usingnamespace @import("./bun/subprocess.zig");
pub usingnamespace @import("bun/subprocess.zig");

const InternalTestingAPIs = struct {
pub fn BunInternalFunction__syntaxHighlighter(globalThis: *JSGlobalObject, callframe: *JSC.CallFrame) bun.JSError!JSValue {
Expand Down
2 changes: 1 addition & 1 deletion src/bun.js/api/Timer.zig
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const Async = @import("async");
const uv = bun.windows.libuv;
const StatWatcherScheduler = @import("../node/node_fs_stat_watcher.zig").StatWatcherScheduler;
const Timer = @This();
const DNSResolver = @import("./bun/dns_resolver.zig").DNSResolver;
const DNSResolver = @import("bun/dns_resolver.zig").DNSResolver;

/// TimeoutMap is map of i32 to nullable Timeout structs
/// i32 is exposed to JavaScript and can be used with clearTimeout, clearInterval, etc.
Expand Down
6 changes: 3 additions & 3 deletions src/bun.js/api/bun/h2_frame_parser.zig
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ const std = @import("std");
const Allocator = std.mem.Allocator;
const JSC = bun.JSC;
const MutableString = bun.MutableString;
const lshpack = @import("./lshpack.zig");
const lshpack = @import("lshpack.zig");
const strings = bun.strings;
pub const AutoFlusher = @import("../../webcore/streams.zig").AutoFlusher;
const TLSSocket = @import("./socket.zig").TLSSocket;
const TCPSocket = @import("./socket.zig").TCPSocket;
const TLSSocket = @import("socket.zig").TLSSocket;
const TCPSocket = @import("socket.zig").TCPSocket;
const JSTLSSocket = JSC.Codegen.JSTLSSocket;
const JSTCPSocket = JSC.Codegen.JSTCPSocket;
const MAX_PAYLOAD_SIZE_WITHOUT_FRAME = 16384 - FrameHeader.byteSize - 1;
Expand Down
4 changes: 2 additions & 2 deletions src/bun.js/api/bun/socket.zig
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ const Which = @import("../../../which.zig");
const uws = bun.uws;
const ZigString = JSC.ZigString;
const BoringSSL = bun.BoringSSL;
const X509 = @import("./x509.zig");
const X509 = @import("x509.zig");
const Async = bun.Async;
const uv = bun.windows.libuv;
const H2FrameParser = @import("./h2_frame_parser.zig").H2FrameParser;
const H2FrameParser = @import("h2_frame_parser.zig").H2FrameParser;
const NodePath = @import("../../node/path.zig");
noinline fn getSSLException(globalThis: *JSC.JSGlobalObject, defaultMessage: []const u8) JSValue {
var zig_str: ZigString = ZigString.init("");
Expand Down
4 changes: 2 additions & 2 deletions src/bun.js/api/bun/spawn.zig
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,6 @@ pub const PosixSpawn = struct {
}
}

pub usingnamespace @import("./process.zig");
pub usingnamespace @import("./spawn/stdio.zig");
pub usingnamespace @import("process.zig");
pub usingnamespace @import("spawn/stdio.zig");
};
2 changes: 1 addition & 1 deletion src/bun.js/api/bun/ssl_wrapper.zig
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const bun = @import("root").bun;

const BoringSSL = bun.BoringSSL;
const X509 = @import("./x509.zig");
const X509 = @import("x509.zig");
const JSC = bun.JSC;
const uws = bun.uws;

Expand Down
2 changes: 1 addition & 1 deletion src/bun.js/api/bun/subprocess.zig
Original file line number Diff line number Diff line change
Expand Up @@ -2441,7 +2441,7 @@ pub const Subprocess = struct {
return globalThis.throwValue(err);
}

const node_cluster_binding = @import("./../../node/node_cluster_binding.zig");
const node_cluster_binding = @import("../../node/node_cluster_binding.zig");

pub fn handleIPCMessage(
this: *Subprocess,
Expand Down
2 changes: 1 addition & 1 deletion src/bun.js/api/server.zig
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ pub fn writeStatus(comptime ssl: bool, resp_ptr: ?*uws.NewApp(ssl).Response, sta
}
}

const StaticRoute = @import("./server/StaticRoute.zig");
const StaticRoute = @import("server/StaticRoute.zig");
const HTMLBundle = JSC.API.HTMLBundle;
const HTMLBundleRoute = HTMLBundle.HTMLBundleRoute;
pub const AnyStaticRoute = union(enum) {
Expand Down
2 changes: 1 addition & 1 deletion src/bun.js/api/server/HTMLBundle.zig
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,7 @@ const JSBundler = JSC.API.JSBundler;
const HTTPResponse = bun.uws.AnyResponse;
const uws = bun.uws;
const AnyServer = JSC.API.AnyServer;
const StaticRoute = @import("./StaticRoute.zig");
const StaticRoute = @import("StaticRoute.zig");

const debug = bun.Output.scoped(.HTMLBundle, true);
const strings = bun.strings;
14 changes: 7 additions & 7 deletions src/bun.js/base.zig
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ const MutableString = bun.MutableString;
const stringZ = bun.stringZ;
const default_allocator = bun.default_allocator;
const C = bun.C;
const JavaScript = @import("./javascript.zig");
const JavaScript = @import("javascript.zig");
const JSC = bun.JSC;
const WebCore = @import("./webcore.zig");
const Test = @import("./test/jest.zig");
const WebCore = @import("webcore.zig");
const Test = @import("test/jest.zig");
const Fetch = WebCore.Fetch;
const Response = WebCore.Response;
const Request = WebCore.Request;
const Router = @import("./api/filesystem_router.zig");
const Router = @import("api/filesystem_router.zig");
const IdentityContext = @import("../identity_context.zig").IdentityContext;
const uws = bun.uws;
const Body = WebCore.Body;
Expand Down Expand Up @@ -1318,9 +1318,9 @@ pub const Ref = struct {
}
};

pub const Strong = @import("./Strong.zig").Strong;
pub const Weak = @import("./Weak.zig").Weak;
pub const WeakRefType = @import("./Weak.zig").WeakRefType;
pub const Strong = @import("Strong.zig").Strong;
pub const Weak = @import("Weak.zig").Weak;
pub const WeakRefType = @import("Weak.zig").WeakRefType;

pub const BinaryType = enum(u4) {
Buffer,
Expand Down
Loading

0 comments on commit c005053

Please sign in to comment.