-
Notifications
You must be signed in to change notification settings - Fork 2.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(bunfig): resolve preloads relative to bunfig.toml
#16390
base: don/fix/bunfig-preload
Are you sure you want to change the base?
fix(bunfig): resolve preloads relative to bunfig.toml
#16390
Conversation
Warning This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
This stack of pull requests is managed by Graphite. Learn more about stacking. |
af01c9d
to
58d60bc
Compare
39e22a9
to
6ce9749
Compare
c82d359
to
aa2c126
Compare
@@ -2126,4 +2126,15 @@ pub fn posixToPlatformInPlace(comptime T: type, path_buffer: []T) void { | |||
} | |||
} | |||
|
|||
/// Like `std.path.isAbsolute`, but allows posix paths on Windows. | |||
pub fn isAbsoluteCrossPlatform( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
delete this function. it's name is misleading, comment is incorrect, and behavior is already covered in std.fs.path.isAbsolute
const os = bun.Environment.os; | ||
const strings = bun.strings; | ||
|
||
pub fn isRelativePathCrossPlatform(path: []const u8) bool { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this function implementation is
- better placed in
bun.path.Platform.
, that way it doesn't readbun.Environment.os
and can use related utilities for slash direction and so on - does not handle
./hello
since it has a length of 6, hitting the else, and then it never checks. i think the 2 => branch can be eliminated entirely - incorrectly named since
hello.txt
is a relative path in most contexts (for example, in bash or the argument tofs.open()
).
What does this PR do?
Before, relative preloads were always resolved to the transpiler's root director. Preloads now store what path they were loaded from.
The preload list is also now an
ArrayListUnmanaged
instead of a slice. We kept clobbering existing slices, leading to memory leaks. This PR reduces, but does not fully fix, all such leaks.How did you verify your code works?
There are tests.