aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/bun.js/api/JSBundler.zig2
-rw-r--r--src/bundler/bundle_v2.zig6
-rw-r--r--src/fs.zig6
-rw-r--r--src/js_printer.zig2
4 files changed, 10 insertions, 6 deletions
diff --git a/src/bun.js/api/JSBundler.zig b/src/bun.js/api/JSBundler.zig
index 87fc29efc..d73dc80fe 100644
--- a/src/bun.js/api/JSBundler.zig
+++ b/src/bun.js/api/JSBundler.zig
@@ -756,7 +756,7 @@ pub const JSBundler = struct {
path: *const Fs.Path,
is_onLoad: bool,
) bool {
- const namespace_string = if (strings.eqlComptime(path.namespace, "file"))
+ const namespace_string = if (path.isFile())
ZigString.Empty
else
ZigString.fromUTF8(path.namespace);
diff --git a/src/bundler/bundle_v2.zig b/src/bundler/bundle_v2.zig
index 81c26f488..173d1c247 100644
--- a/src/bundler/bundle_v2.zig
+++ b/src/bundler/bundle_v2.zig
@@ -6442,7 +6442,7 @@ const LinkerContext = struct {
{
var path = sources[source_indices[0]].path;
- if (strings.eqlComptime(path.namespace, "file")) {
+ if (path.isFile()) {
const rel_path = try std.fs.path.relative(worker.allocator, chunk_abs_dir, path.text);
path.pretty = rel_path;
}
@@ -6455,7 +6455,7 @@ const LinkerContext = struct {
for (source_indices[1..]) |index| {
var path = sources[index].path;
- if (strings.eqlComptime(path.namespace, "file")) {
+ if (path.isFile()) {
const rel_path = try std.fs.path.relative(worker.allocator, chunk_abs_dir, path.text);
path.pretty = rel_path;
}
@@ -6560,7 +6560,7 @@ const LinkerContext = struct {
const source: Logger.Source = sources[part_range.source_index.get()];
const file_path = brk: {
- if (strings.eqlComptime(source.path.namespace, "file")) {
+ if (source.path.isFile()) {
// Use the pretty path as the file name since it should be platform-
// independent (relative paths and the "/" path separator)
break :brk source.path.pretty;
diff --git a/src/fs.zig b/src/fs.zig
index 924109345..ae2a9e352 100644
--- a/src/fs.zig
+++ b/src/fs.zig
@@ -1223,8 +1223,12 @@ pub const Path = struct {
is_disabled: bool = false,
is_symlink: bool = false,
+ pub fn isFile(this: *const Path) bool {
+ return this.namespace.len == 0 or strings.eqlComptime(this.namespace, "file");
+ }
+
pub fn hashKey(this: *const Path) u64 {
- if (this.namespace.len == 0 or strings.eqlComptime(this.namespace, "file")) {
+ if (this.isFile()) {
return bun.hash(this.text);
}
diff --git a/src/js_printer.zig b/src/js_printer.zig
index b1509bf6d..ea289eeed 100644
--- a/src/js_printer.zig
+++ b/src/js_printer.zig
@@ -4653,7 +4653,7 @@ fn NewPrinter(
p.print(":");
p.printModuleIdAssumeEnabled(import_record.module_id);
p.print(quote);
- } else if (import_record.print_namespace_in_path and import_record.path.namespace.len > 0 and !strings.eqlComptime(import_record.path.namespace, "file")) {
+ } else if (import_record.print_namespace_in_path and !import_record.path.isFile()) {
p.print(quote);
p.print(import_record.path.namespace);
p.print(":");