various bug fixes

This commit is contained in:
Jarred Sumner
2021-05-13 01:24:10 -07:00
parent 28fce4aac1
commit 87771ba895
6 changed files with 50 additions and 14 deletions

17
.vscode/launch.json vendored
View File

@@ -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"
}
]
}

3
.vscode/tasks.json vendored
View File

@@ -4,7 +4,8 @@
{
"label": "build",
"type": "process",
"command": "zig build",
"command": "zig",
"args": ["build"],
"group": {
"kind": "build",
"isDefault": true

View File

@@ -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)}),

View File

@@ -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;
}
}

View File

@@ -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 {

View File

@@ -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 {};