jsbundling-rails 1.2.2 → 1.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -3
- data/lib/install/bun/.gitattributes +2 -0
- data/lib/install/bun/install.rb +2 -0
- data/lib/install/dev +1 -1
- data/lib/install/esbuild/install.rb +4 -1
- data/lib/install/install.rb +1 -1
- data/lib/install/package.json +1 -1
- data/lib/install/rollup/install.rb +4 -1
- data/lib/install/webpack/install.rb +4 -1
- data/lib/jsbundling/version.rb +1 -1
- data/lib/tasks/jsbundling/build.rake +27 -8
- data/lib/tasks/jsbundling/install.rake +4 -14
- metadata +7 -5
- /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: 0f7a7198c114c9497a7bd5f14f0757f10b2d62ab9fad59a539c34c1c46a7f685
|
4
|
+
data.tar.gz: 5cb3d42e10398e2413bc2072a537171ff0ca72ad90e5d22de5a99368390879ce
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c154edf1116b480421286d4cb398ef052c46ee9555da212ef553f53d19be4ceadbf8e2b0d70c4248daa76c3a08688ae70d51d7d45e2fdd1334081104d5675b7e
|
7
|
+
data.tar.gz: 0daf53c907b3364dd55d41bb5141d883755240ac6d4e1105a65db3cf56b813f8bdfea66be183595b7ef513d60165dfbaad2e7036acc5d1ce0d4fca63e60a40ce
|
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/dev
CHANGED
@@ -1,5 +1,8 @@
|
|
1
|
+
apply "#{__dir__}/../install.rb"
|
2
|
+
apply "#{__dir__}/../install_procfile.rb"
|
3
|
+
|
1
4
|
say "Install esbuild"
|
2
|
-
run "yarn add esbuild"
|
5
|
+
run "yarn add --dev esbuild"
|
3
6
|
|
4
7
|
say "Add build script"
|
5
8
|
build_script = "esbuild app/javascript/*.* --bundle --sourcemap --format=esm --outdir=app/assets/builds --public-path=/assets"
|
data/lib/install/install.rb
CHANGED
data/lib/install/package.json
CHANGED
@@ -1,6 +1,9 @@
|
|
1
|
+
apply "#{__dir__}/../install.rb"
|
2
|
+
apply "#{__dir__}/../install_procfile.rb"
|
3
|
+
|
1
4
|
say "Install rollup with config"
|
2
5
|
copy_file "#{__dir__}/rollup.config.js", "rollup.config.js"
|
3
|
-
run "yarn add rollup @rollup/plugin-node-resolve"
|
6
|
+
run "yarn add --dev rollup @rollup/plugin-node-resolve"
|
4
7
|
|
5
8
|
say "Add build script"
|
6
9
|
build_script = "rollup -c --bundleConfigAsCjs rollup.config.js"
|
@@ -1,6 +1,9 @@
|
|
1
|
+
apply "#{__dir__}/../install.rb"
|
2
|
+
apply "#{__dir__}/../install_procfile.rb"
|
3
|
+
|
1
4
|
say "Install Webpack with config"
|
2
5
|
copy_file "#{__dir__}/webpack.config.js", "webpack.config.js"
|
3
|
-
run "yarn add webpack webpack-cli"
|
6
|
+
run "yarn add --dev webpack webpack-cli"
|
4
7
|
|
5
8
|
say "Add build script"
|
6
9
|
build_script = "webpack --config webpack.config.js"
|
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.1
|
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-
|
11
|
+
date: 2024-07-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: railties
|
@@ -34,13 +34,14 @@ files:
|
|
34
34
|
- README.md
|
35
35
|
- lib/install/Procfile.dev
|
36
36
|
- lib/install/application.js
|
37
|
+
- lib/install/bun/.gitattributes
|
37
38
|
- lib/install/bun/Procfile.dev
|
38
39
|
- lib/install/bun/bun.config.js
|
39
40
|
- lib/install/bun/install.rb
|
40
41
|
- lib/install/dev
|
41
42
|
- lib/install/esbuild/install.rb
|
42
43
|
- lib/install/install.rb
|
43
|
-
- lib/install/
|
44
|
+
- lib/install/install_procfile.rb
|
44
45
|
- lib/install/package.json
|
45
46
|
- lib/install/rollup/install.rb
|
46
47
|
- lib/install/rollup/rollup.config.js
|
@@ -55,7 +56,8 @@ files:
|
|
55
56
|
homepage: https://github.com/rails/jsbundling-rails
|
56
57
|
licenses:
|
57
58
|
- MIT
|
58
|
-
metadata:
|
59
|
+
metadata:
|
60
|
+
changelog_uri: https://github.com/rails/jsbundling-rails/releases
|
59
61
|
post_install_message:
|
60
62
|
rdoc_options: []
|
61
63
|
require_paths:
|
@@ -71,7 +73,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
71
73
|
- !ruby/object:Gem::Version
|
72
74
|
version: '0'
|
73
75
|
requirements: []
|
74
|
-
rubygems_version: 3.
|
76
|
+
rubygems_version: 3.5.11
|
75
77
|
signing_key:
|
76
78
|
specification_version: 4
|
77
79
|
summary: Bundle and transpile JavaScript in Rails with bun, esbuild, rollup.js, or
|
File without changes
|