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

Detect Bun tool when using bun.lock and yarn.lock #213

Merged
merged 3 commits into from
Mar 9, 2025

Conversation

jbarrieault
Copy link
Contributor

@jbarrieault jbarrieault commented Mar 6, 2025

Summary

Resolves #212

The build task incorrectly detect yarn as the JS tool when using Bun's text-based lockfile (bun.lock) if a yarn.lock is also present. The text-based lockfile was introduced in Bun v1.1.39.

Why would bun.lock and yarn.lock both exist?

Bun supports generating a yarn.lock file in addition to its own lockfile. Producing the yarn.lock file can be useful for integrating with tools that only know (how) to parse yarn.lock files, such as dependency report generators.

The fix

This checks for bun.lock ahead of yarn.lock to ensure Bun is detected as the tool.

Add additional control?

The is adjacent to rails/cssbundling-rails#169.

Perhaps a config that allows setting & differentiating the package manager and bundler would be reasonable. On the other hand, it should already be possible to achieve that by monkey-patching Jsbundling::Tasks.

@dhh dhh merged commit 7d5afa9 into rails:main Mar 9, 2025
19 checks passed
@dhh
Copy link
Member

dhh commented Mar 9, 2025

Do bring this to cssbundling-rails too.

@navidemad
Copy link
Contributor

@dhh I made this one with a bit of refactor also:

rails/cssbundling-rails#171

@jbarrieault jbarrieault deleted the jb/bun-dot-lock branch March 10, 2025 16:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

assets:precompile breaks when using text based lock file of bun
3 participants