diff options
author | 2021-05-13 01:24:10 -0700 | |
---|---|---|
committer | 2021-05-13 01:24:10 -0700 | |
commit | f6f40b5b649507aee7555123e93a1b474b92f598 (patch) | |
tree | 6e262b821e6c5d62a089a3b03090335bbe622a55 | |
parent | bed0227a8f2d8b674a98803659922d08ac665bfe (diff) | |
download | bun-f6f40b5b649507aee7555123e93a1b474b92f598.tar.gz bun-f6f40b5b649507aee7555123e93a1b474b92f598.tar.zst bun-f6f40b5b649507aee7555123e93a1b474b92f598.zip |
various bug fixes
Former-commit-id: 87771ba895a2eb11b042a252fd1dff2a4dd54512
-rw-r--r-- | .vscode/launch.json | 17 | ||||
-rw-r--r-- | .vscode/tasks.json | 3 | ||||
-rw-r--r-- | src/bundler.zig | 11 | ||||
-rw-r--r-- | src/fs.zig | 2 | ||||
-rw-r--r-- | src/logger.zig | 25 | ||||
-rw-r--r-- | src/resolver/resolver.zig | 6 |
6 files changed, 50 insertions, 14 deletions
diff --git a/.vscode/launch.json b/.vscode/launch.json index ac4131710..11eb418eb 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -10,6 +10,23 @@ "args": ["/usr/local/bin/zig"], "cwd": "${workspaceFolder}", "console": "internalConsole" + }, + { + "type": "lldb", + "request": "launch", + "name": "Dev Launch", + "program": "${workspaceFolder}/build/bin/debug/esdev", + "preLaunchTask": "build", + "args": [ + "--resolve=dev", + "--cwd", + "./src/test", + "./fixtures/for-loop-bug", + "-o", + "out" + ], + "cwd": "${workspaceFolder}", + "console": "internalConsole" } ] } diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 345c1e3c3..313818895 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -4,7 +4,8 @@ { "label": "build", "type": "process", - "command": "zig build", + "command": "zig", + "args": ["build"], "group": { "kind": "build", "isDefault": true diff --git a/src/bundler.zig b/src/bundler.zig index 8df23e265..56f70b912 100644 --- a/src/bundler.zig +++ b/src/bundler.zig @@ -72,6 +72,11 @@ pub const Bundler = struct { var entry_points = try allocator.alloc(Resolver.Resolver.Result, bundler.options.entry_points.len); + if (isDebug) { + log.level = .verbose; + bundler.resolver.debug_logs = try Resolver.Resolver.DebugLogs.init(allocator); + } + var entry_point_i: usize = 0; for (bundler.options.entry_points) |entry| { const result = bundler.resolver.resolve(bundler.fs.top_level_dir, entry, .entry_point) catch { @@ -87,6 +92,12 @@ pub const Bundler = struct { entry_point_i += 1; } + if (isDebug) { + for (log.msgs.items) |msg| { + try msg.writeFormat(std.io.getStdOut().writer()); + } + } + switch (bundler.options.resolve_mode) { .lazy, .dev, .bundle => {}, else => Global.panic("Unsupported resolve mode: {s}", .{@tagName(bundler.options.resolve_mode)}), diff --git a/src/fs.zig b/src/fs.zig index 2577d4552..ed541d588 100644 --- a/src/fs.zig +++ b/src/fs.zig @@ -386,7 +386,7 @@ pub const FileSystem = struct { // First, check the cache if (fs.entries.get(dir)) |_dir| { - return EntriesOption{ .entries = _dir.entries }; + return _dir; } } diff --git a/src/logger.zig b/src/logger.zig index a07adc203..72c7ebc3d 100644 --- a/src/logger.zig +++ b/src/logger.zig @@ -140,15 +140,22 @@ pub const Msg = struct { msg: *const Msg, to: anytype, ) !void { - try std.fmt.format(to, "\n\n{s}: {s}\n{s}\n{s}:{}:{} {d}", .{ - msg.kind.string(), - msg.data.text, - msg.data.location.?.line_text, - msg.data.location.?.file, - msg.data.location.?.line, - msg.data.location.?.column, - msg.data.location.?.offset, - }); + if (msg.data.location) |location| { + try std.fmt.format(to, "\n\n{s}: {s}\n{s}\n{s}:{}:{} {d}", .{ + msg.kind.string(), + msg.data.text, + location.line_text, + location.file, + location.line, + location.column, + location.offset, + }); + } else { + try std.fmt.format(to, "\n\n{s}: {s}\n", .{ + msg.kind.string(), + msg.data.text, + }); + } } pub fn doFormat(msg: *const Msg, to: anytype, formatterFunc: anytype) !void { diff --git a/src/resolver/resolver.zig b/src/resolver/resolver.zig index 6d2425654..b272a7cbe 100644 --- a/src/resolver/resolver.zig +++ b/src/resolver/resolver.zig @@ -151,7 +151,7 @@ pub const Resolver = struct { if (len > 0) { var __text = try d.notes.allocator.alloc(u8, text.len + len); std.mem.copy(u8, __text, d.indent.list.items); - std.mem.copy(u8, __text[len..text.len], _text); + std.mem.copy(u8, __text[len..__text.len], _text); d.notes.allocator.free(_text); } @@ -1197,7 +1197,7 @@ pub const Resolver = struct { debug.addNoteFmt("Found file \"{s}\" ", .{base}) catch {}; } - return LoadResult{ .path = base, .diff_case = query.diff_case }; + return LoadResult{ .path = path, .diff_case = query.diff_case }; } } @@ -1211,7 +1211,7 @@ pub const Resolver = struct { debug.addNoteFmt("Checking for file \"{s}{s}\" ", .{ base, ext }) catch {}; } - if (entries.get(buffer)) |query| { + if (entries.get(buffer[path.len - base.len .. buffer.len])) |query| { if (query.entry.kind(rfs) == .file) { if (r.debug_logs) |*debug| { debug.addNoteFmt("Found file \"{s}\" ", .{buffer}) catch {}; |