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

Use bun for installation if applicable #494

Merged
merged 3 commits into from Sep 25, 2023

Conversation

terracatta
Copy link
Contributor

@terracatta terracatta commented Sep 12, 2023

This PR is part of an overall effort to allow Rails developers to completely use the Bun JS runtime and bundler without needing to use Node.JS and Yarn.

This gem is automatically invoked when a new rails projects is created and before this PR would always use Yarn. After this PR this gem will detect which JS bundler is being used and use the correct one so that Yarn doesn't accidentally slip into your Rails project.

I have opened a companion PR to the stimulus-rails repo as well.

Example run of javascript:install:bun and bin/rails turbo:install

☁  test_app [main] ./bin/rails javascript:install:bun
Compile into app/assets/builds
      create  app/assets/builds
      create  app/assets/builds/.keep
      append  app/assets/config/manifest.js
      append  .gitignore
      append  .gitignore
Add JavaScript include tag in application layout
      insert  app/views/layouts/application.html.erb
Create default entrypoint in app/javascript/application.js
      create  app/javascript
      create  app/javascript/application.js
Add default package.json
      create  package.json
Add bin/dev to start foreman
      create  bin/dev
Add default Procfile.dev
      create  Procfile.dev
Ensure foreman is installed
         run  gem install foreman from "."
Successfully installed foreman-0.87.2
Parsing documentation for foreman-0.87.2
Done installing documentation for foreman after 0 seconds
1 gem installed
Add default bun.config.js
      create  bun.config.js
Add build script to package.json

☁  test_app [main] ⚡  bin/rails turbo:install
Import Turbo
      append  app/javascript/application.js
Install Turbo
         run  bun add @hotwired/turbo-rails from "."
bun add v1.0.0 (822a00c4)

 installed @hotwired/turbo-rails@7.3.0


 3 packages installed [2.01s]
Run turbo:install:redis to switch on Redis and use it in development for turbo streams

@seanpdoyle
Copy link
Contributor

@afcapel are you able to review this? It might be time-sensitive see this comment and this one too.

lib/tasks/turbo_tasks.rake Outdated Show resolved Hide resolved
lib/tasks/turbo_tasks.rake Outdated Show resolved Hide resolved
lib/tasks/turbo_tasks.rake Outdated Show resolved Hide resolved
@afcapel afcapel merged commit 8585e6a into hotwired:main Sep 25, 2023
11 checks passed
@afcapel
Copy link
Contributor

afcapel commented Sep 25, 2023

Thanks @terracatta

@terracatta terracatta deleted the add_bun_support branch September 25, 2023 13:23
@terracatta
Copy link
Contributor Author

Thanks @afcapel are you able to do a similar review for hotwired/stimulus-rails#125 ?

@afcapel afcapel mentioned this pull request Sep 25, 2023
@1st8
Copy link

1st8 commented Sep 27, 2023

Just saying: This needs to released to make rails new --js bun work with rails 7.1.0.rc1.

Currently turbo-rails runs yarn add, which generates a yarn.lock, which then makes cssbundling-rails also use yarn.

When using --skip-hotwire bun is used correctly.

Uses bun correctly: rails new --js bun --css tailwind --skip-hotwire bun_rails
Erroneously uses yarn: rails new --js bun --css tailwind bun_rails

@terracatta
Copy link
Contributor Author

cc/ @dhh any possibility you can cut a release for this gem before 7.1.0 final is out?

Can you also merge hotwired/stimulus-rails#125 can cut a release for stimulus-rails?

This will be the only way to ensure the new rails new --js bun option will work.

@ghiculescu
Copy link
Contributor

@dhh bump on this ^

ref: rails/rails#49522

@dhh
Copy link
Member

dhh commented Oct 10, 2023

cc @afcapel

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants