aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ast/base.zig10
-rw-r--r--src/bun.js/module_loader.zig2
-rw-r--r--src/fs.zig57
-rw-r--r--src/js_parser.zig2
-rw-r--r--src/resolver/resolver.zig10
5 files changed, 31 insertions, 50 deletions
diff --git a/src/ast/base.zig b/src/ast/base.zig
index 1ce91ccbe..f3cc34925 100644
--- a/src/ast/base.zig
+++ b/src/ast/base.zig
@@ -283,13 +283,3 @@ test "Ref" {
try std.testing.expectEqual(ref.isSourceContentsSlice(), first.is_source_contents_slice);
}
}
-
-// This is kind of the wrong place, but it's shared between files
-pub const RequireOrImportMeta = struct {
- // CommonJS files will return the "require_*" wrapper function and an invalid
- // exports object reference. Lazily-initialized ESM files will return the
- // "init_*" wrapper function and the exports object for that file.
- wrapper_ref: Ref = Ref.None,
- exports_ref: Ref = Ref.None,
- is_wrapper_async: bool = false,
-};
diff --git a/src/bun.js/module_loader.zig b/src/bun.js/module_loader.zig
index 0583a36ad..0bd379e63 100644
--- a/src/bun.js/module_loader.zig
+++ b/src/bun.js/module_loader.zig
@@ -1128,7 +1128,7 @@ pub const ModuleLoader = struct {
return resolved_source;
}
- return ResolvedSource{
+ return .{
.allocator = null,
.source_code = ZigString.init(try default_allocator.dupe(u8, printer.ctx.getWritten())),
.specifier = ZigString.init(display_specifier),
diff --git a/src/fs.zig b/src/fs.zig
index 68f8bfe33..05903fac2 100644
--- a/src/fs.zig
+++ b/src/fs.zig
@@ -203,22 +203,13 @@ pub const FileSystem = struct {
// }
pub fn addEntry(dir: *DirEntry, entry: std.fs.IterableDir.Entry, allocator: std.mem.Allocator, comptime Iterator: type, iterator: Iterator) !void {
- var _kind: Entry.Kind = undefined;
- switch (entry.kind) {
- .Directory => {
- _kind = Entry.Kind.dir;
- },
- .SymLink => {
- // This might be wrong!
- _kind = Entry.Kind.file;
- },
- .File => {
- _kind = Entry.Kind.file;
- },
- else => {
- return;
- },
- }
+ const _kind: Entry.Kind = switch (entry.kind) {
+ .Directory => .dir,
+ // This might be wrong!
+ .SymLink => .file,
+ .File => .file,
+ else => return,
+ };
// entry.name only lives for the duration of the iteration
const name = if (entry.name.len >= strings.StringOrTinyString.Max)
@@ -231,22 +222,20 @@ pub const FileSystem = struct {
else
strings.StringOrTinyString.initLowerCase(entry.name);
- var stored = try EntryStore.instance.append(
- Entry{
- .base_ = name,
- .base_lowercase_ = name_lowercased,
- .dir = dir.dir,
- .mutex = Mutex.init(),
- // Call "stat" lazily for performance. The "@material-ui/icons" package
- // contains a directory with over 11,000 entries in it and running "stat"
- // for each entry was a big performance issue for that package.
- .need_stat = entry.kind == .SymLink,
- .cache = Entry.Cache{
- .symlink = PathString.empty,
- .kind = _kind,
- },
+ const stored = try EntryStore.instance.append(.{
+ .base_ = name,
+ .base_lowercase_ = name_lowercased,
+ .dir = dir.dir,
+ .mutex = Mutex.init(),
+ // Call "stat" lazily for performance. The "@material-ui/icons" package
+ // contains a directory with over 11,000 entries in it and running "stat"
+ // for each entry was a big performance issue for that package.
+ .need_stat = entry.kind == .SymLink,
+ .cache = .{
+ .symlink = PathString.empty,
+ .kind = _kind,
},
- );
+ });
const stored_name = stored.base();
@@ -270,7 +259,7 @@ pub const FileSystem = struct {
Output.prettyln("\n {s}", .{dir});
}
- return DirEntry{ .dir = dir, .data = EntryMap{} };
+ return .{ .dir = dir, .data = .{} };
}
pub const Err = struct {
@@ -363,7 +352,7 @@ pub const FileSystem = struct {
};
pub const Entry = struct {
- cache: Cache = Cache{},
+ cache: Cache = .{},
dir: string,
base_: strings.StringOrTinyString,
@@ -406,7 +395,7 @@ pub const FileSystem = struct {
pub const Cache = struct {
symlink: PathString = PathString.empty,
fd: StoredFileDescriptorType = 0,
- kind: Kind = Kind.file,
+ kind: Kind = .file,
};
pub const Kind = enum {
diff --git a/src/js_parser.zig b/src/js_parser.zig
index 27c349f24..a8861875a 100644
--- a/src/js_parser.zig
+++ b/src/js_parser.zig
@@ -18902,7 +18902,7 @@ fn NewParser_(
// }
}
- return js_ast.Ast{
+ return .{
.runtime_imports = p.runtime_imports,
.parts = parts,
.module_scope = p.module_scope.*,
diff --git a/src/resolver/resolver.zig b/src/resolver/resolver.zig
index 3331e8b06..7be97a291 100644
--- a/src/resolver/resolver.zig
+++ b/src/resolver/resolver.zig
@@ -1819,7 +1819,7 @@ pub const Resolver = struct {
}
fn dirInfoForResolution(
r: *ThisResolver,
- dir_path: []const u8,
+ dir_path: string,
package_id: Install.PackageID,
) !?*DirInfo {
std.debug.assert(r.package_manager != null);
@@ -1833,7 +1833,7 @@ pub const Resolver = struct {
var cached_dir_entry_result = rfs.entries.getOrPut(dir_path) catch unreachable;
var dir_entries_option: *Fs.FileSystem.RealFS.EntriesOption = undefined;
- var needs_iter: bool = true;
+ var needs_iter = true;
var open_dir = std.fs.cwd().openIterableDir(dir_path, .{}) catch |err| {
switch (err) {
error.FileNotFound => unreachable,
@@ -1855,7 +1855,9 @@ pub const Resolver = struct {
if (needs_iter) {
const allocator = r.fs.allocator;
dir_entries_option = rfs.entries.put(&cached_dir_entry_result, .{
- .entries = Fs.FileSystem.DirEntry.init(dir_path),
+ .entries = Fs.FileSystem.DirEntry.init(
+ Fs.FileSystem.DirnameStore.instance.append(string, dir_path) catch unreachable,
+ ),
}) catch unreachable;
if (FeatureFlags.store_file_descriptors) {
@@ -1870,7 +1872,7 @@ pub const Resolver = struct {
// We must initialize it as empty so that the result index is correct.
// This is important so that browser_scope has a valid index.
- var dir_info_ptr = r.dir_cache.put(&dir_cache_info_result, DirInfo{}) catch unreachable;
+ var dir_info_ptr = r.dir_cache.put(&dir_cache_info_result, .{}) catch unreachable;
try r.dirInfoUncached(
dir_info_ptr,