Skip to content

Commit

Permalink
fix: explicitly set our preferred package manager for js dependencies (
Browse files Browse the repository at this point in the history
…#528)

[`react-rails` now supports other package
managers](reactjs/react-rails#1306) using
`package_json`, meaning it now defaults to `npm` if a package manager is
not explicitly set in `package.json`, causing a stray
`package-lock.json` to be created.

I've specified an exact version because currently `corepack` requires
that ([ranges are not yet
supported](nodejs/corepack#95)) but we're not
actually expecting anyone to be using `corepack` and we're definitely
not using it in production (not explicitly at least...) so in theory
this shouldn't cause problems and it means `package.json` conforms to
the JSON schema - it'll also help to flush out any potential problems
early before(/if) `corepack` becomes more mainstream.
  • Loading branch information
G-Rath authored Jan 26, 2024
1 parent c6801a5 commit 5a59ebc
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions variants/frontend-base/template.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@
# this will create a package.json for us
run "rails shakapacker:install"

# explicitly set our preferred package manager for external tooling
update_package_json do |package_json|
package_json["packageManager"] = "[email protected]"
end

# this is added by shakapacker:install, but we've already got one (with some extra tags)
# in our template, so remove theirs otherwise the app will error when rendering this
gsub_file "app/views/layouts/application.html.erb",
Expand Down

0 comments on commit 5a59ebc

Please sign in to comment.