Skip to content

Commit 7d44e02

Browse files
authored
Support PNPM (#181)
* PNPM support * Document supported JS package managers
1 parent 4bce06b commit 7d44e02

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ You develop using this approach by running the bundler in watch mode in a termin
66

77
Whenever the bundler detects changes to any of the JavaScript files in your project, it'll bundle `app/javascript/application.js` into `app/assets/builds/application.js` (and all other entry points configured). You can refer to the build output in your layout using the standard asset pipeline approach with `<%= javascript_include_tag "application", defer: true %>`.
88

9-
When you deploy your application to production, the `javascript:build` task attaches to the `assets:precompile` task to ensure that all your package dependencies from `package.json` have been installed via your javascript package manager (bun or yarn), and then runs the build script defined in `package.json` to process all the entry points, as it would in development. The latter files are then picked up by the asset pipeline, digested, and copied into public/assets, as any other asset pipeline file.
9+
When you deploy your application to production, the `javascript:build` task attaches to the `assets:precompile` task to ensure that all your package dependencies from `package.json` have been installed via your javascript package manager ([bun](https://bun.sh), [npm](https://www.npmjs.com), [pnpm](https://pnpm.io), or [yarn](https://yarnpkg.com)), and then runs the build script defined in `package.json` to process all the entry points, as it would in development. The latter files are then picked up by the asset pipeline, digested, and copied into public/assets, as any other asset pipeline file.
1010

1111
This also happens in testing where the bundler attaches to the `test:prepare` task to ensure the JavaScript has been bundled before testing commences. If your testing library of choice does not call the `test:prepare` Rake task, ensure that your test suite runs `javascript:build` to bundle JavaScript before testing commences.
1212

@@ -19,8 +19,7 @@ If you're already using [`webpacker`](https://github.com/rails/webpacker) and yo
1919
If you want to use webpack features like [code splitting](https://webpack.js.org/guides/code-splitting/) and [hot module reloading](https://webpack.js.org/concepts/hot-module-replacement/), consider using the official fork of `webpacker`, [`shakapacker`](https://github.com/shakacode/shakapacker).
2020

2121
## Installation
22-
If you are installing esbuild, rollup, or webpack, you must already have node
23-
and yarn installed on your system. You will also need npx version 7.1.0 or later.
22+
If you are installing esbuild, rollup, or webpack, you must already have node installed on your system. You will also need npx version 7.1.0 or later.
2423

2524
If you are using Bun, then you must have the Bun runtime already installed on
2625
your system.

lib/tasks/jsbundling/build.rake

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ module Jsbundling
2626
case tool
2727
when :bun then "bun install"
2828
when :yarn then "yarn install"
29+
when :pnpm then "pnpm install"
2930
when :npm then "npm install"
3031
else raise "jsbundling-rails: No suitable tool found for installing JavaScript dependencies"
3132
end
@@ -35,6 +36,7 @@ module Jsbundling
3536
case tool
3637
when :bun then "bun run build"
3738
when :yarn then "yarn build"
39+
when :pnpm then "pnpm build"
3840
when :npm then "npm run build"
3941
else raise "jsbundling-rails: No suitable tool found for building JavaScript"
4042
end
@@ -48,9 +50,11 @@ module Jsbundling
4850
case
4951
when File.exist?('bun.lockb') then :bun
5052
when File.exist?('yarn.lock') then :yarn
53+
when File.exist?('pnpm-lock.yaml') then :pnpm
5154
when File.exist?('package-lock.json') then :npm
5255
when tool_exists?('bun') then :bun
5356
when tool_exists?('yarn') then :yarn
57+
when tool_exists?('pnpm') then :pnpm
5458
when tool_exists?('npm') then :npm
5559
end
5660
end

0 commit comments

Comments
 (0)