Skip to content
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

Draft
wants to merge 1 commit into
base: don/fix/bunfig-preload
Choose a base branch
from

Conversation

DonIsaac
Copy link
Contributor

@DonIsaac DonIsaac commented Jan 14, 2025

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.

@robobun
Copy link

robobun commented Jan 14, 2025

Updated 8:53 PM PT - Jan 13th, 2025

@DonIsaac, your commit aa2c126 has passed in #9567! 🎉


🧪   try this PR locally:

bunx bun-pr 16390

Copy link
Contributor Author

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.
Learn more

This stack of pull requests is managed by Graphite. Learn more about stacking.

@DonIsaac DonIsaac force-pushed the don/fix/bunfig-preload branch from af01c9d to 58d60bc Compare January 14, 2025 04:11
@DonIsaac DonIsaac force-pushed the 01-13-fix_bunfig_resolve_preloads_relative_to_bunfig.toml_ branch from 39e22a9 to 6ce9749 Compare January 14, 2025 04:11
@DonIsaac DonIsaac added the bug Something isn't working label Jan 14, 2025
@DonIsaac DonIsaac force-pushed the 01-13-fix_bunfig_resolve_preloads_relative_to_bunfig.toml_ branch from c82d359 to aa2c126 Compare January 14, 2025 04:17
@@ -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(
Copy link
Member

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 {
Copy link
Member

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 read bun.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 to fs.open()).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants