jsbundling-rails 1.2.2 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +2 -3
- data/lib/install/bun/install.rb +2 -0
- data/lib/install/esbuild/install.rb +3 -0
- data/lib/install/package.json +1 -1
- data/lib/install/rollup/install.rb +3 -0
- data/lib/install/webpack/install.rb +3 -0
- data/lib/jsbundling/version.rb +1 -1
- data/lib/tasks/jsbundling/build.rake +27 -8
- data/lib/tasks/jsbundling/install.rake +4 -14
- metadata +4 -4
- /data/lib/install/{install_node.rb → install_procfile.rb} +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c5eb0a7f2f82b82a508d4640babe1980234db73e9f97f2bcdd08db417ad1dfee
|
4
|
+
data.tar.gz: 9ba266bcf549a314d0968705626021566c993a1c7e771ecf886627c307c0300a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b9f055b3a8a676d91e3fb421e757a5e81e6b01b4c165c8f45f889de1a2c0bbdcf574c6934d17c7b39006ad05a87b52be9e5c4429f0265ddd87888129fc472c3c
|
7
|
+
data.tar.gz: a07320167dc646b5b9792e8d02c770b2e4c40283a5219baf92cfca6b29ae04c54b2d2ab7e0c995514b4bf646b092272f9a3133cd46b0571ebd9190d57682a3d2
|
data/README.md
CHANGED
@@ -6,7 +6,7 @@ You develop using this approach by running the bundler in watch mode in a termin
|
|
6
6
|
|
7
7
|
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 %>`.
|
8
8
|
|
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.
|
10
10
|
|
11
11
|
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.
|
12
12
|
|
@@ -19,8 +19,7 @@ If you're already using [`webpacker`](https://github.com/rails/webpacker) and yo
|
|
19
19
|
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).
|
20
20
|
|
21
21
|
## 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.
|
24
23
|
|
25
24
|
If you are using Bun, then you must have the Bun runtime already installed on
|
26
25
|
your system.
|
data/lib/install/bun/install.rb
CHANGED
data/lib/install/package.json
CHANGED
data/lib/jsbundling/version.rb
CHANGED
@@ -23,22 +23,41 @@ module Jsbundling
|
|
23
23
|
extend self
|
24
24
|
|
25
25
|
def install_command
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
26
|
+
case tool
|
27
|
+
when :bun then "bun install"
|
28
|
+
when :yarn then "yarn install"
|
29
|
+
when :pnpm then "pnpm install"
|
30
|
+
when :npm then "npm install"
|
31
|
+
else raise "jsbundling-rails: No suitable tool found for installing JavaScript dependencies"
|
32
|
+
end
|
30
33
|
end
|
31
34
|
|
32
35
|
def build_command
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
36
|
+
case tool
|
37
|
+
when :bun then "bun run build"
|
38
|
+
when :yarn then "yarn build"
|
39
|
+
when :pnpm then "pnpm build"
|
40
|
+
when :npm then "npm run build"
|
41
|
+
else raise "jsbundling-rails: No suitable tool found for building JavaScript"
|
42
|
+
end
|
37
43
|
end
|
38
44
|
|
39
45
|
def tool_exists?(tool)
|
40
46
|
system "command -v #{tool} > /dev/null"
|
41
47
|
end
|
48
|
+
|
49
|
+
def tool
|
50
|
+
case
|
51
|
+
when File.exist?('bun.lockb') then :bun
|
52
|
+
when File.exist?('yarn.lock') then :yarn
|
53
|
+
when File.exist?('pnpm-lock.yaml') then :pnpm
|
54
|
+
when File.exist?('package-lock.json') then :npm
|
55
|
+
when tool_exists?('bun') then :bun
|
56
|
+
when tool_exists?('yarn') then :yarn
|
57
|
+
when tool_exists?('pnpm') then :pnpm
|
58
|
+
when tool_exists?('npm') then :npm
|
59
|
+
end
|
60
|
+
end
|
42
61
|
end
|
43
62
|
end
|
44
63
|
|
@@ -1,32 +1,22 @@
|
|
1
1
|
namespace :javascript do
|
2
2
|
namespace :install do
|
3
|
-
desc "Install shared elements for all bundlers"
|
4
|
-
task :shared do
|
5
|
-
system "#{RbConfig.ruby} ./bin/rails app:template LOCATION=#{File.expand_path("../../install/install.rb", __dir__)}"
|
6
|
-
end
|
7
|
-
|
8
|
-
desc "Install node-specific elements for bundlers that use node/yarn."
|
9
|
-
task :node_shared do
|
10
|
-
system "#{RbConfig.ruby} ./bin/rails app:template LOCATION=#{File.expand_path("../../install/install_node.rb", __dir__)}"
|
11
|
-
end
|
12
|
-
|
13
3
|
desc "Install Bun"
|
14
|
-
task bun
|
4
|
+
task :bun do
|
15
5
|
system "#{RbConfig.ruby} ./bin/rails app:template LOCATION=#{File.expand_path("../../install/bun/install.rb", __dir__)}"
|
16
6
|
end
|
17
7
|
|
18
8
|
desc "Install esbuild"
|
19
|
-
task esbuild
|
9
|
+
task :esbuild do
|
20
10
|
system "#{RbConfig.ruby} ./bin/rails app:template LOCATION=#{File.expand_path("../../install/esbuild/install.rb", __dir__)}"
|
21
11
|
end
|
22
12
|
|
23
13
|
desc "Install rollup.js"
|
24
|
-
task rollup
|
14
|
+
task :rollup do
|
25
15
|
system "#{RbConfig.ruby} ./bin/rails app:template LOCATION=#{File.expand_path("../../install/rollup/install.rb", __dir__)}"
|
26
16
|
end
|
27
17
|
|
28
18
|
desc "Install Webpack"
|
29
|
-
task webpack
|
19
|
+
task :webpack do
|
30
20
|
system "#{RbConfig.ruby} ./bin/rails app:template LOCATION=#{File.expand_path("../../install/webpack/install.rb", __dir__)}"
|
31
21
|
end
|
32
22
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jsbundling-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Heinemeier Hansson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-01-
|
11
|
+
date: 2024-01-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: railties
|
@@ -40,7 +40,7 @@ files:
|
|
40
40
|
- lib/install/dev
|
41
41
|
- lib/install/esbuild/install.rb
|
42
42
|
- lib/install/install.rb
|
43
|
-
- lib/install/
|
43
|
+
- lib/install/install_procfile.rb
|
44
44
|
- lib/install/package.json
|
45
45
|
- lib/install/rollup/install.rb
|
46
46
|
- lib/install/rollup/rollup.config.js
|
@@ -71,7 +71,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
71
71
|
- !ruby/object:Gem::Version
|
72
72
|
version: '0'
|
73
73
|
requirements: []
|
74
|
-
rubygems_version: 3.4.
|
74
|
+
rubygems_version: 3.4.20
|
75
75
|
signing_key:
|
76
76
|
specification_version: 4
|
77
77
|
summary: Bundle and transpile JavaScript in Rails with bun, esbuild, rollup.js, or
|
File without changes
|