jsbundling-rails 1.2.0 → 1.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/install/dev +1 -1
- data/lib/install/esbuild/install.rb +1 -1
- data/lib/install/install.rb +2 -2
- data/lib/install/rollup/rollup.config.js +1 -1
- data/lib/install/webpack/webpack.config.js +1 -0
- data/lib/jsbundling/version.rb +1 -1
- data/lib/tasks/jsbundling/build.rake +22 -14
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3cd9756300244b2e031344a063f93d4e6ed124fc2cb324a6d70ee6e69385304f
|
4
|
+
data.tar.gz: 2618a978134e255ec4b69a6cefddeb593ba0c8dfba9d1e12fc37215b556968bb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dbcf7c0772469872dfea9667f852a0dc64012b55896c3a8cef480a57ae49adbd7d8e001faee1b48c8b99de659e39e27c45e1b086470c4d7070fbec442735c8b8
|
7
|
+
data.tar.gz: 07d134a6c2b6765c83cac64b85314ceb91666ef6ca93c7d997c820e6c588f7085be61bbad3a0fae8c250be8cb29ed314dbf76890bb975b8b64b998b70fef7ebc
|
data/lib/install/dev
CHANGED
@@ -2,7 +2,7 @@ say "Install esbuild"
|
|
2
2
|
run "yarn add esbuild"
|
3
3
|
|
4
4
|
say "Add build script"
|
5
|
-
build_script = "esbuild app/javascript/*.* --bundle --sourcemap --outdir=app/assets/builds --public-path=/assets"
|
5
|
+
build_script = "esbuild app/javascript/*.* --bundle --sourcemap --format=esm --outdir=app/assets/builds --public-path=/assets"
|
6
6
|
|
7
7
|
case `npx -v`.to_f
|
8
8
|
when 7.1...8.0
|
data/lib/install/install.rb
CHANGED
@@ -14,10 +14,10 @@ end
|
|
14
14
|
if (app_layout_path = Rails.root.join("app/views/layouts/application.html.erb")).exist?
|
15
15
|
say "Add JavaScript include tag in application layout"
|
16
16
|
insert_into_file app_layout_path.to_s,
|
17
|
-
%(\n <%= javascript_include_tag "application", "data-turbo-track": "reload",
|
17
|
+
%(\n <%= javascript_include_tag "application", "data-turbo-track": "reload", type: "module" %>), before: /\s*<\/head>/
|
18
18
|
else
|
19
19
|
say "Default application.html.erb is missing!", :red
|
20
|
-
say %( Add <%= javascript_include_tag "application", "data-turbo-track": "reload",
|
20
|
+
say %( Add <%= javascript_include_tag "application", "data-turbo-track": "reload", type: "module" %> within the <head> tag in your custom layout.)
|
21
21
|
end
|
22
22
|
|
23
23
|
unless (app_js_entrypoint_path = Rails.root.join("app/javascript/application.js")).exist?
|
data/lib/jsbundling/version.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
namespace :javascript do
|
2
2
|
desc "Install JavaScript dependencies"
|
3
3
|
task :install do
|
4
|
-
command = install_command
|
4
|
+
command = Jsbundling::Tasks.install_command
|
5
5
|
unless system(command)
|
6
6
|
raise "jsbundling-rails: Command install failed, ensure #{command.split.first} is installed"
|
7
7
|
end
|
@@ -9,7 +9,7 @@ namespace :javascript do
|
|
9
9
|
|
10
10
|
desc "Build your JavaScript bundle"
|
11
11
|
build_task = task :build do
|
12
|
-
command = build_command
|
12
|
+
command = Jsbundling::Tasks.build_command
|
13
13
|
unless system(command)
|
14
14
|
raise "jsbundling-rails: Command build failed, ensure `#{command}` runs without errors"
|
15
15
|
end
|
@@ -18,20 +18,28 @@ namespace :javascript do
|
|
18
18
|
build_task.prereqs << :install unless ENV["SKIP_YARN_INSTALL"] || ENV["SKIP_BUN_INSTALL"]
|
19
19
|
end
|
20
20
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
raise "jsbundling-rails: No suitable tool found for installing JavaScript dependencies"
|
25
|
-
end
|
21
|
+
module Jsbundling
|
22
|
+
module Tasks
|
23
|
+
extend self
|
26
24
|
|
27
|
-
def
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
25
|
+
def install_command
|
26
|
+
return "bun install" if File.exist?('bun.lockb') || (tool_exists?('bun') && !File.exist?('yarn.lock'))
|
27
|
+
return "yarn install" if File.exist?('yarn.lock') || (tool_exists?('yarn') && !File.exist?('package-lock.json'))
|
28
|
+
return "npm install" if File.exist?('package-lock.json') || tool_exists?('npm')
|
29
|
+
raise "jsbundling-rails: No suitable tool found for installing JavaScript dependencies"
|
30
|
+
end
|
32
31
|
|
33
|
-
def
|
34
|
-
|
32
|
+
def build_command
|
33
|
+
return "bun run build" if File.exist?('bun.lockb') || (tool_exists?('bun') && !File.exist?('yarn.lock'))
|
34
|
+
return "yarn build" if File.exist?('yarn.lock') || (tool_exists?('yarn') && !File.exist?('package-lock.json'))
|
35
|
+
return "npm run build" if File.exist?('package-lock.json') || tool_exists?('npm')
|
36
|
+
raise "jsbundling-rails: No suitable tool found for building JavaScript"
|
37
|
+
end
|
38
|
+
|
39
|
+
def tool_exists?(tool)
|
40
|
+
system "command -v #{tool} > /dev/null"
|
41
|
+
end
|
42
|
+
end
|
35
43
|
end
|
36
44
|
|
37
45
|
unless ENV["SKIP_JS_BUILD"]
|
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.2.
|
4
|
+
version: 1.2.2
|
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:
|
11
|
+
date: 2024-01-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: railties
|
@@ -71,8 +71,9 @@ 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.14
|
75
75
|
signing_key:
|
76
76
|
specification_version: 4
|
77
|
-
summary: Bundle and transpile JavaScript in Rails with esbuild, rollup.js, or
|
77
|
+
summary: Bundle and transpile JavaScript in Rails with bun, esbuild, rollup.js, or
|
78
|
+
Webpack.
|
78
79
|
test_files: []
|