Skip to content

fix(bunfig): resolve preloads relative to bunfig.toml - #16390

Closed
DonIsaac wants to merge 10 commits into
mainfrom
01-13-fix_bunfig_resolve_preloads_relative_to_bunfig.toml_
Closed

DonIsaac wants to merge 10 commits into
mainfrom
01-13-fix_bunfig_resolve_preloads_relative_to_bunfig.toml_

Conversation

@DonIsaac

@DonIsaac DonIsaac commented Jan 14, 2025 •

Copy link
Copy Markdown
Contributor

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

robobun commented Jan 14, 2025 •

Copy link
Copy Markdown
Collaborator
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
Copy Markdown
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
}

/// Like `std.path.isAbsolute`, but allows posix paths on Windows.
pub fn isAbsoluteCrossPlatform(

Copy link
Copy Markdown
Contributor

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

Comment thread src/path.zig
const os = bun.Environment.os;
const strings = bun.strings;

pub fn isRelativePathCrossPlatform(path: []const u8) bool {

Copy link
Copy Markdown
Contributor

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()).

Base automatically changed from don/fix/bunfig-preload to main March 3, 2025 23:45
@DonIsaac

DonIsaac commented Apr 9, 2025

Copy link
Copy Markdown
Contributor Author

Closed in favor of #18908

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