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 #125

Merged
merged 3 commits into from
Sep 29, 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 turbo-rails repo as well.

Example run of javascript:install:bun and bin/rails stimulus: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 stimulus:install
Create controllers directory
      create  app/javascript/controllers
      create  app/javascript/controllers/index.js
      create  app/javascript/controllers/application.js
      create  app/javascript/controllers/hello_controller.js
Import Stimulus controllers
      append  app/javascript/application.js
Install Stimulus
         run  bun add @hotwired/stimulus from "."
bun add v1.0.0 (822a00c4)

 installed @hotwired/[email protected]


 1 packages installed [931.00ms]

@terracatta terracatta changed the title Add Bun support Use bun for installation if applicable Sep 12, 2023
@terracatta terracatta mentioned this pull request Sep 23, 2023
@1st8
Copy link

1st8 commented Sep 27, 2023

Can confirm that this works.

This must be released to allow rails new --js bun to work without --skip-hotwire in Rails 7.1.0

See hotwired/turbo-rails#494 (comment) for details.

@dhh dhh merged commit df761bb into hotwired:main Sep 29, 2023
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.

3 participants