mirror of
https://github.com/oven-sh/bun
synced 2026-02-09 10:28:47 +00:00
fix: get bun build working on window (#8712)
* work on bundler * a * YAAAAYYAYAYAYYAYA * get some more bundler tests working * Update src/bundler/bundle_v2.zig * rev * ok * i converted the cmakelists into LF * personal review * we didnt win * okey they pass * revert :( * a --------- Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
This commit is contained in:
@@ -17,15 +17,44 @@ pub const StandaloneModuleGraph = struct {
|
||||
files: bun.StringArrayHashMap(File),
|
||||
entry_point_id: u32 = 0,
|
||||
|
||||
// We never want to hit the filesystem for these files
|
||||
// We use the `/$bunfs/` prefix to indicate that it's a virtual path
|
||||
// It is `/$bunfs/` because:
|
||||
//
|
||||
// - `$` makes it unlikely to collide with a real path
|
||||
// - `/$bunfs/` is 8 characters which is fast to compare for 64-bit CPUs
|
||||
pub const base_path = switch (Environment.os) {
|
||||
else => "/$bunfs/",
|
||||
// Special case for windows because of file URLs being invalid
|
||||
// if they do not have a drive letter. B drive because 'bun' but
|
||||
// also because it's more unlikely to collide with a real path.
|
||||
.windows => "B:\\~BUN\\",
|
||||
};
|
||||
|
||||
pub const base_public_path = switch (Environment.os) {
|
||||
else => "/$bunfs/",
|
||||
.windows => "B:/~BUN/",
|
||||
};
|
||||
|
||||
pub fn isBunStandaloneFilePath(str: []const u8) bool {
|
||||
return bun.strings.hasPrefixComptime(str, base_path) or
|
||||
(Environment.isWindows and bun.strings.hasPrefixComptime(str, base_public_path));
|
||||
}
|
||||
|
||||
pub fn entryPoint(this: *const StandaloneModuleGraph) *File {
|
||||
return &this.files.values()[this.entry_point_id];
|
||||
}
|
||||
|
||||
// by normalized file path
|
||||
pub fn find(this: *const StandaloneModuleGraph, name: []const u8) ?*File {
|
||||
if (!bun.strings.isBunStandaloneFilePath(name)) {
|
||||
if (!bun.strings.hasPrefixComptime(name, base_path)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (Environment.isWindows) {
|
||||
var normalized_buf: [bun.MAX_PATH_BYTES]u8 = undefined;
|
||||
const normalized = bun.path.platformToPosixBuf(u8, name, &normalized_buf);
|
||||
return this.files.getPtr(normalized);
|
||||
}
|
||||
return this.files.getPtr(name);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user