jsbundling-rails 0.1.4 → 0.1.8

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7a33dca86c8cca2151366ae5d1d18262cfca426ff330745c2168b621b9e66f2e
4
- data.tar.gz: 2ac326bf65dde1b8dbdc1c50d133188c307debab60f92938d790c508c81d7e6c
3
+ metadata.gz: e53bb1aef74de39d8fdbe9a5f234d0a34d9cc26cc84b708711c0eaadb77f4dcd
4
+ data.tar.gz: c5b34643c871c1d74f6c763fd6ebea88e305349b70500cc54e1f973cdbb6821f
5
5
  SHA512:
6
- metadata.gz: d1640ce2af097577e53947e1ac936ec815a67901d33856db90d17da4fa1ee42c412c50c69320de081fb935113e16752ca58f230cf091eb7093cb96c7c891faa0
7
- data.tar.gz: 315d928a0f866a1b9152bc2773f3f7168f4bee47726aa111414f43a60947953d511b433b47cbbcc9481062168617fd28c5d5137fe29f294381604fec954092ae
6
+ metadata.gz: 348217cf1a66e4b84f293102308fae17c48ef09ece24fe2cfbe408bdee570de7766704a82737a892a89d38e034282823ce2ac93ae18207f75ae76555c31c1499
7
+ data.tar.gz: 94ea08798d3ab189f4bdd89037a4a0fe547a1b27438b1a6127023f8fc3b87c44ae629e7b65871a79f55bc0dec15211d2b01b212acefcd96e0bad998cbb10925a
data/README.md CHANGED
@@ -8,10 +8,14 @@ When you deploy your application to production, the `javascript:build` task atta
8
8
 
9
9
  This also happens in testing where the bundler attaches to the `test:prepare` task to ensure the JavaScript has been bundled before testing commences. (Note that this currently only applies to rails `test:*` tasks (like `test:all` or `test:controllers`), not "rails test", as that doesn't load `test:prepare`).
10
10
 
11
+ If your testing library of choice does not define a `test:prepare` Rake task, ensure that your test suite runs `javascript:build` to bundle JavaScript before testing commences.
12
+
11
13
  That's it!
12
14
 
13
15
  You can configure your bundler options in the `build` script in `package.json` or via the installer-generated `rollup.config.js` for rollup.js or `webpack.config.json` for Webpack (esbuild does not have a default configuration format).
14
16
 
17
+ If you're already using [`webpacker`](https://github.com/rails/webpacker) and you're wondering if you should migrate to `jsbundling-rails`, have a look at [the high-level comparison](./docs/comparison_with_webpacker.md).
18
+
15
19
 
16
20
  ## Installation
17
21
 
@@ -1,10 +1,14 @@
1
1
  say "Compile into app/assets/builds"
2
2
  empty_directory "app/assets/builds"
3
3
  keep_file "app/assets/builds"
4
- append_to_file "app/assets/config/manifest.js", %(//= link_tree ../builds\n)
4
+
5
+ if (sprockets_manifest_path = Rails.root.join("app/assets/config/manifest.js")).exist?
6
+ append_to_file sprockets_manifest_path, %(//= link_tree ../builds\n)
7
+ end
5
8
 
6
9
  if Rails.root.join(".gitignore").exist?
7
- append_to_file(".gitignore", %(/app/assets/builds\n!/app/assets/builds/.keep\n))
10
+ append_to_file(".gitignore", %(\n/app/assets/builds/*\n!/app/assets/builds/.keep\n))
11
+ append_to_file(".gitignore", %(\n/node_modules\n))
8
12
  end
9
13
 
10
14
  if (app_layout_path = Rails.root.join("app/views/layouts/application.html.erb")).exist?
@@ -28,7 +32,7 @@ unless Rails.root.join("package.json").exist?
28
32
  end
29
33
 
30
34
  if Rails.root.join("Procfile.dev").exist?
31
- append_to_file "Procfile.dev", "js: yarn build --watch"
35
+ append_to_file "Procfile.dev", "js: yarn build --watch\n"
32
36
  else
33
37
  say "Add default Procfile.dev"
34
38
  copy_file "#{__dir__}/Procfile.dev", "Procfile.dev"
@@ -3,9 +3,11 @@ const webpack = require('webpack')
3
3
 
4
4
  module.exports = {
5
5
  mode: "production",
6
- entry: "./app/javascript/application.js",
6
+ entry: {
7
+ application: "./app/javascript/application.js"
8
+ },
7
9
  output: {
8
- filename: "application.js",
10
+ filename: "[name].js",
9
11
  path: path.resolve(__dirname, "app/assets/builds"),
10
12
  },
11
13
  plugins: [
@@ -1,3 +1,3 @@
1
1
  module Jsbundling
2
- VERSION = "0.1.4"
2
+ VERSION = "0.1.8"
3
3
  end
@@ -1,9 +1,16 @@
1
1
  namespace :javascript do
2
2
  desc "Build your JavaScript bundle"
3
3
  task :build do
4
- system "yarn install && yarn build"
4
+ unless system "yarn install && yarn build"
5
+ raise "jsbundling-rails: Command build failed, ensure yarn is installed and `yarn build` runs without errors"
6
+ end
5
7
  end
6
8
  end
7
9
 
8
10
  Rake::Task["assets:precompile"].enhance(["javascript:build"])
9
- Rake::Task["test:prepare"].enhance(["javascript:build"])
11
+
12
+ if Rake::Task.task_defined?("test:prepare")
13
+ Rake::Task["test:prepare"].enhance(["javascript:build"])
14
+ elsif Rake::Task.task_defined?("db:test:prepare")
15
+ Rake::Task["db:test:prepare"].enhance(["javascript:build"])
16
+ end
metadata CHANGED
@@ -1,17 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jsbundling-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.8
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: 2021-09-08 00:00:00.000000000 Z
11
+ date: 2021-09-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: rails
14
+ name: railties
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - ">="