rollupjs-rails 0.1.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 +7 -0
- data/MIT-LICENSE +20 -0
- data/README.md +32 -0
- data/lib/install/application.js +1 -0
- data/lib/install/install.rb +28 -0
- data/lib/install/package.json +7 -0
- data/lib/install/rollup.config.js +13 -0
- data/lib/rollup/engine.rb +4 -0
- data/lib/rollup/version.rb +3 -0
- data/lib/rollupjs-rails.rb +5 -0
- data/lib/tasks/rollup/compile.rake +8 -0
- data/lib/tasks/rollup/install.rake +6 -0
- metadata +67 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: b6e88daac911ff6400da2b84ebc8be3cded0c243b3644a1ad3a4354aa19a143a
|
4
|
+
data.tar.gz: 67c7ffb6091d8ebc3b0314ef45dcffc72d8060ea10fcb76ffa823f8f32b3546e
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 7a675b399fd14abcca4a4df3cd83ffeaf32180bcdaa69c503760374dfa73e9953be03abeaeada11ed877d0ec7787e77a1bef4999996e18326f234d2a98275219
|
7
|
+
data.tar.gz: f5d4920d160822ba89236413616931a7c096258eaf9478096171126986df9cd3e4ae9c439fc979c5f42bb48c6614b1b9be0913915d50a224045c325abd036dc8
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2021 David Heinemeier Hansson
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
# rollup.js for Rails
|
2
|
+
|
3
|
+
Use [rollup.js](https://rollupjs.org) to bundle your JavaScript, then deliver it via the asset pipeline in Rails. This gem provides an installer to get you going with rollup in a new Rails application, and a convention to use `app/assets/builds` to hold your bundled output as artifacts that are not checked into source control (the installer adds this directory to `.gitignore` by default).
|
4
|
+
|
5
|
+
You develop using this approach by running rollup.js in watch mode in a terminal with `yarn build --watch` (and your Rails server in another, if you're not using something like [puma-dev](https://github.com/puma/puma-dev)). Whenever rollup.js detects changes to any of the JavaScript files in your project, it'll bundle `app/javascript/application.js` into `app/assets/builds/javascript.js`. You can refer to the build output in your layout using the standard asset pipeline approach with `<%= javascript_include_tag "application" %>`.
|
6
|
+
|
7
|
+
When you deploy your application to production, rollup.js attaches to the `assets:precompile` task to ensure that all your package dependencies from `package.json` have been installed via npm, and then runs `yarn build` to process `app/javascript/application.js` into `app/assets/builds/javascript.js`. The latter file is then picked up by the asset pipeline, digested, and copied into public/assets, as any other asset pipeline file.
|
8
|
+
|
9
|
+
That's it!
|
10
|
+
|
11
|
+
You can tailor the configuration of rollup.js through the `rollup.config.js` that's created in the root of your project by the installer.
|
12
|
+
|
13
|
+
|
14
|
+
## Installation
|
15
|
+
|
16
|
+
You must already have node and yarn installed on your system. Then:
|
17
|
+
|
18
|
+
1. Add `rollupjs-rails` to your Gemfile with `gem 'rollupjs-rails'`
|
19
|
+
2. Run `./bin/bundle install`
|
20
|
+
3. Run `./bin/rails rollup:install`
|
21
|
+
|
22
|
+
Or, in Rails 7+, you can preconfigure your new application to use rollup.js with `rails new myapp -j rollup`.
|
23
|
+
|
24
|
+
|
25
|
+
## The sister gem to esbuild-rails
|
26
|
+
|
27
|
+
This gem is almost identical in setup and purpose as [`esbuild-rails`](https://github.com/rails/esbuild-rails), which follows the same conventions, but uses [esbuild](https://esbuild.github.io) instead.
|
28
|
+
|
29
|
+
|
30
|
+
## License
|
31
|
+
|
32
|
+
rollup.js for Rails is released under the [MIT License](https://opensource.org/licenses/MIT).
|
@@ -0,0 +1 @@
|
|
1
|
+
// Entrypoint for the build script in your package.json
|
@@ -0,0 +1,28 @@
|
|
1
|
+
say "Compile into app/assets/builds"
|
2
|
+
empty_directory "app/assets/builds"
|
3
|
+
keep_file "app/assets/builds"
|
4
|
+
append_to_file "app/assets/config/manifest.js", %(//= link_tree ../builds .js\n)
|
5
|
+
|
6
|
+
if Rails.root.join(".gitignore").exist?
|
7
|
+
append_to_file ".gitignore", %(/app/assets/builds\n)
|
8
|
+
end
|
9
|
+
|
10
|
+
if (app_layout_path = Rails.root.join("app/views/layouts/application.html.erb")).exist?
|
11
|
+
say "Add JavaScript include tag in application layout"
|
12
|
+
insert_into_file app_layout_path.to_s,
|
13
|
+
%(\n <%= javascript_include_tag "application", "data-track-turbo": "true", defer: true %>), before: /\s*<\/head>/
|
14
|
+
else
|
15
|
+
say "Default application.html.erb is missing!", :red
|
16
|
+
say %( Add <%= javascript_include_tag "application", "data-track-turbo": "true", defer: true %> within the <head> tag in your custom layout.)
|
17
|
+
end
|
18
|
+
|
19
|
+
unless (app_js_entrypoint_path = Rails.root.join("app/javascript/application.js")).exist?
|
20
|
+
say "Create default entrypoint in app/javascript/application.js"
|
21
|
+
empty_directory app_js_entrypoint_path.parent.to_s
|
22
|
+
copy_file "#{__dir__}/application.js", app_js_entrypoint_path
|
23
|
+
end
|
24
|
+
|
25
|
+
say "Create default package.json and install rollup with config"
|
26
|
+
copy_file "#{__dir__}/package.json", "package.json"
|
27
|
+
copy_file "#{__dir__}/rollup.config.js", "rollup.config.js"
|
28
|
+
run "yarn add rollup @rollup/plugin-node-resolve"
|
@@ -0,0 +1,13 @@
|
|
1
|
+
import resolve from "@rollup/plugin-node-resolve"
|
2
|
+
|
3
|
+
export default {
|
4
|
+
input: "app/javascript/application.js",
|
5
|
+
output: {
|
6
|
+
file: "app/assets/builds/application.js",
|
7
|
+
format: "es",
|
8
|
+
inlineDynamicImports: true
|
9
|
+
},
|
10
|
+
plugins: [
|
11
|
+
resolve()
|
12
|
+
]
|
13
|
+
}
|
metadata
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rollupjs-rails
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- David Heinemeier Hansson
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2021-09-04 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rails
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 6.0.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 6.0.0
|
27
|
+
description:
|
28
|
+
email: david@loudthinking.com
|
29
|
+
executables: []
|
30
|
+
extensions: []
|
31
|
+
extra_rdoc_files: []
|
32
|
+
files:
|
33
|
+
- MIT-LICENSE
|
34
|
+
- README.md
|
35
|
+
- lib/install/application.js
|
36
|
+
- lib/install/install.rb
|
37
|
+
- lib/install/package.json
|
38
|
+
- lib/install/rollup.config.js
|
39
|
+
- lib/rollup/engine.rb
|
40
|
+
- lib/rollup/version.rb
|
41
|
+
- lib/rollupjs-rails.rb
|
42
|
+
- lib/tasks/rollup/compile.rake
|
43
|
+
- lib/tasks/rollup/install.rake
|
44
|
+
homepage: https://github.com/rails/rollupjs-rails
|
45
|
+
licenses:
|
46
|
+
- MIT
|
47
|
+
metadata: {}
|
48
|
+
post_install_message:
|
49
|
+
rdoc_options: []
|
50
|
+
require_paths:
|
51
|
+
- lib
|
52
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
53
|
+
requirements:
|
54
|
+
- - ">="
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: '0'
|
57
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
requirements: []
|
63
|
+
rubygems_version: 3.1.4
|
64
|
+
signing_key:
|
65
|
+
specification_version: 4
|
66
|
+
summary: Bundle and transpile JavaScript in Rails with rollup.js.
|
67
|
+
test_files: []
|