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:
dave caruso
2024-02-08 17:56:26 -08:00
committed by GitHub
parent 1ccf0c2e9c
commit 2d7df726fd
32 changed files with 1617 additions and 1479 deletions

View File

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