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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d27f6cc62feb84d7b81b8eba5aa68fec1232775b88ca5d16b6b2a5d2efb0183d
4
- data.tar.gz: 1d5e167c6802db6fe99ce8df513313597f42d586bd19bed864645e3db4682728
3
+ metadata.gz: 3cd9756300244b2e031344a063f93d4e6ed124fc2cb324a6d70ee6e69385304f
4
+ data.tar.gz: 2618a978134e255ec4b69a6cefddeb593ba0c8dfba9d1e12fc37215b556968bb
5
5
  SHA512:
6
- metadata.gz: a1f15e3bfe2fbfdf113990d126cc1e54e494e2666acaedd4969ee590446c1e4f5aa7395dd4da537e4d8fef7ef0c3e52a27513dc184b9950d821f98d942458081
7
- data.tar.gz: 8789b31503404c6f88fea2cf98517e01e31126004d061373242730a1d9de3dcc24bb470577cb6586117115ff79da63f37e7e51dd0d751fa9b37479f4a4048113
6
+ metadata.gz: dbcf7c0772469872dfea9667f852a0dc64012b55896c3a8cef480a57ae49adbd7d8e001faee1b48c8b99de659e39e27c45e1b086470c4d7070fbec442735c8b8
7
+ data.tar.gz: 07d134a6c2b6765c83cac64b85314ceb91666ef6ca93c7d997c820e6c588f7085be61bbad3a0fae8c250be8cb29ed314dbf76890bb975b8b64b998b70fef7ebc
data/lib/install/dev CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env sh
2
2
 
3
- if ! gem list foreman -i --silent; then
3
+ if gem list --no-installed --exact --silent foreman; then
4
4
  echo "Installing foreman..."
5
5
  gem install foreman
6
6
  fi
@@ -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
@@ -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", defer: true %>), before: /\s*<\/head>/
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", defer: true %> within the <head> tag in your custom layout.)
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?
@@ -4,7 +4,7 @@ export default {
4
4
  input: "app/javascript/application.js",
5
5
  output: {
6
6
  file: "app/assets/builds/application.js",
7
- format: "iife",
7
+ format: "esm",
8
8
  inlineDynamicImports: true,
9
9
  sourcemap: true
10
10
  },
@@ -10,6 +10,7 @@ module.exports = {
10
10
  output: {
11
11
  filename: "[name].js",
12
12
  sourceMapFilename: "[file].map",
13
+ chunkFormat: "module",
13
14
  path: path.resolve(__dirname, "app/assets/builds"),
14
15
  },
15
16
  plugins: [
@@ -1,3 +1,3 @@
1
1
  module Jsbundling
2
- VERSION = "1.2.0"
2
+ VERSION = "1.2.2"
3
3
  end
@@ -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
- def install_command
22
- return "bun install" if File.exist?('bun.lockb') || (tool_exists?('bun') && !File.exist?('yarn.lock'))
23
- return "yarn install" if File.exist?('yarn.lock') || tool_exists?('yarn')
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 build_command
28
- return "bun run build" if File.exist?('bun.lockb') || (tool_exists?('bun') && !File.exist?('yarn.lock'))
29
- return "yarn build" if File.exist?('yarn.lock') || tool_exists?('yarn')
30
- raise "jsbundling-rails: No suitable tool found for building JavaScript"
31
- end
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 tool_exists?(tool)
34
- system "command -v #{tool} > /dev/null"
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.0
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: 2023-09-12 00:00:00.000000000 Z
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.10
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 Webpack.
77
+ summary: Bundle and transpile JavaScript in Rails with bun, esbuild, rollup.js, or
78
+ Webpack.
78
79
  test_files: []