├── .gitignore ├── Gemfile ├── Gemfile.lock ├── MIT-LICENSE ├── README.md ├── bin └── release ├── lib ├── install │ ├── application.js │ ├── install.rb │ ├── package.json │ └── rollup.config.js ├── rollup │ ├── engine.rb │ └── version.rb ├── rollupjs-rails.rb └── tasks │ └── rollup │ ├── compile.rake │ └── install.rake └── rollupjs-rails.gemspec /.gitignore: -------------------------------------------------------------------------------- 1 | .byebug_history 2 | *.gem 3 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | git_source(:github) { |repo| "https://github.com/#{repo}.git" } 3 | 4 | # Specify your gem's dependencies in importmap-rails.gemspec. 5 | gemspec 6 | 7 | rails_version = ENV["RAILS_VERSION"] || "6.1.0" 8 | gem "rails", "~> #{rails_version}" 9 | 10 | gem "sqlite3" 11 | 12 | group :test do 13 | gem "turbo-rails" 14 | gem "stimulus-rails" 15 | 16 | gem "byebug" 17 | 18 | gem "rexml" 19 | gem "capybara" 20 | gem "selenium-webdriver" 21 | gem "webdrivers" 22 | end 23 | -------------------------------------------------------------------------------- /Gemfile.lock: -------------------------------------------------------------------------------- 1 | PATH 2 | remote: . 3 | specs: 4 | rollupjs-rails (0.1.1) 5 | rails (>= 6.0.0) 6 | 7 | GEM 8 | remote: https://rubygems.org/ 9 | specs: 10 | actioncable (6.1.3.1) 11 | actionpack (= 6.1.3.1) 12 | activesupport (= 6.1.3.1) 13 | nio4r (~> 2.0) 14 | websocket-driver (>= 0.6.1) 15 | actionmailbox (6.1.3.1) 16 | actionpack (= 6.1.3.1) 17 | activejob (= 6.1.3.1) 18 | activerecord (= 6.1.3.1) 19 | activestorage (= 6.1.3.1) 20 | activesupport (= 6.1.3.1) 21 | mail (>= 2.7.1) 22 | actionmailer (6.1.3.1) 23 | actionpack (= 6.1.3.1) 24 | actionview (= 6.1.3.1) 25 | activejob (= 6.1.3.1) 26 | activesupport (= 6.1.3.1) 27 | mail (~> 2.5, >= 2.5.4) 28 | rails-dom-testing (~> 2.0) 29 | actionpack (6.1.3.1) 30 | actionview (= 6.1.3.1) 31 | activesupport (= 6.1.3.1) 32 | rack (~> 2.0, >= 2.0.9) 33 | rack-test (>= 0.6.3) 34 | rails-dom-testing (~> 2.0) 35 | rails-html-sanitizer (~> 1.0, >= 1.2.0) 36 | actiontext (6.1.3.1) 37 | actionpack (= 6.1.3.1) 38 | activerecord (= 6.1.3.1) 39 | activestorage (= 6.1.3.1) 40 | activesupport (= 6.1.3.1) 41 | nokogiri (>= 1.8.5) 42 | actionview (6.1.3.1) 43 | activesupport (= 6.1.3.1) 44 | builder (~> 3.1) 45 | erubi (~> 1.4) 46 | rails-dom-testing (~> 2.0) 47 | rails-html-sanitizer (~> 1.1, >= 1.2.0) 48 | activejob (6.1.3.1) 49 | activesupport (= 6.1.3.1) 50 | globalid (>= 0.3.6) 51 | activemodel (6.1.3.1) 52 | activesupport (= 6.1.3.1) 53 | activerecord (6.1.3.1) 54 | activemodel (= 6.1.3.1) 55 | activesupport (= 6.1.3.1) 56 | activestorage (6.1.3.1) 57 | actionpack (= 6.1.3.1) 58 | activejob (= 6.1.3.1) 59 | activerecord (= 6.1.3.1) 60 | activesupport (= 6.1.3.1) 61 | marcel (~> 1.0.0) 62 | mini_mime (~> 1.0.2) 63 | activesupport (6.1.3.1) 64 | concurrent-ruby (~> 1.0, >= 1.0.2) 65 | i18n (>= 1.6, < 2) 66 | minitest (>= 5.1) 67 | tzinfo (~> 2.0) 68 | zeitwerk (~> 2.3) 69 | addressable (2.8.0) 70 | public_suffix (>= 2.0.2, < 5.0) 71 | builder (3.2.4) 72 | byebug (11.1.3) 73 | capybara (3.35.3) 74 | addressable 75 | mini_mime (>= 0.1.3) 76 | nokogiri (~> 1.8) 77 | rack (>= 1.6.0) 78 | rack-test (>= 0.6.3) 79 | regexp_parser (>= 1.5, < 3.0) 80 | xpath (~> 3.2) 81 | childprocess (3.0.0) 82 | concurrent-ruby (1.1.9) 83 | crass (1.0.6) 84 | erubi (1.10.0) 85 | globalid (0.5.1) 86 | activesupport (>= 5.0) 87 | i18n (1.8.10) 88 | concurrent-ruby (~> 1.0) 89 | loofah (2.10.0) 90 | crass (~> 1.0.2) 91 | nokogiri (>= 1.5.9) 92 | mail (2.7.1) 93 | mini_mime (>= 0.1.1) 94 | marcel (1.0.1) 95 | method_source (1.0.0) 96 | mini_mime (1.0.3) 97 | minitest (5.14.4) 98 | nio4r (2.5.7) 99 | nokogiri (1.11.7-arm64-darwin) 100 | racc (~> 1.4) 101 | nokogiri (1.11.7-x86_64-darwin) 102 | racc (~> 1.4) 103 | nokogiri (1.11.7-x86_64-linux) 104 | racc (~> 1.4) 105 | public_suffix (4.0.6) 106 | racc (1.5.2) 107 | rack (2.2.3) 108 | rack-test (1.1.0) 109 | rack (>= 1.0, < 3) 110 | rails (6.1.3.1) 111 | actioncable (= 6.1.3.1) 112 | actionmailbox (= 6.1.3.1) 113 | actionmailer (= 6.1.3.1) 114 | actionpack (= 6.1.3.1) 115 | actiontext (= 6.1.3.1) 116 | actionview (= 6.1.3.1) 117 | activejob (= 6.1.3.1) 118 | activemodel (= 6.1.3.1) 119 | activerecord (= 6.1.3.1) 120 | activestorage (= 6.1.3.1) 121 | activesupport (= 6.1.3.1) 122 | bundler (>= 1.15.0) 123 | railties (= 6.1.3.1) 124 | sprockets-rails (>= 2.0.0) 125 | rails-dom-testing (2.0.3) 126 | activesupport (>= 4.2.0) 127 | nokogiri (>= 1.6) 128 | rails-html-sanitizer (1.3.0) 129 | loofah (~> 2.3) 130 | railties (6.1.3.1) 131 | actionpack (= 6.1.3.1) 132 | activesupport (= 6.1.3.1) 133 | method_source 134 | rake (>= 0.8.7) 135 | thor (~> 1.0) 136 | rake (13.0.6) 137 | regexp_parser (2.1.1) 138 | rexml (3.2.5) 139 | rubyzip (2.3.2) 140 | selenium-webdriver (3.142.7) 141 | childprocess (>= 0.5, < 4.0) 142 | rubyzip (>= 1.2.2) 143 | sprockets (4.0.2) 144 | concurrent-ruby (~> 1.0) 145 | rack (> 1, < 3) 146 | sprockets-rails (3.2.2) 147 | actionpack (>= 4.0) 148 | activesupport (>= 4.0) 149 | sprockets (>= 3.0.0) 150 | sqlite3 (1.4.2) 151 | stimulus-rails (0.3.8) 152 | rails (>= 6.0.0) 153 | thor (1.1.0) 154 | turbo-rails (0.7.4) 155 | rails (>= 6.0.0) 156 | tzinfo (2.0.4) 157 | concurrent-ruby (~> 1.0) 158 | webdrivers (4.6.0) 159 | nokogiri (~> 1.6) 160 | rubyzip (>= 1.3.0) 161 | selenium-webdriver (>= 3.0, < 4.0) 162 | websocket-driver (0.7.5) 163 | websocket-extensions (>= 0.1.0) 164 | websocket-extensions (0.1.5) 165 | xpath (3.2.0) 166 | nokogiri (~> 1.8) 167 | zeitwerk (2.4.2) 168 | 169 | PLATFORMS 170 | arm64-darwin-20 171 | x86_64-darwin-20 172 | x86_64-linux 173 | 174 | DEPENDENCIES 175 | byebug 176 | capybara 177 | rails (~> 6.1.0) 178 | rexml 179 | rollupjs-rails! 180 | selenium-webdriver 181 | sqlite3 182 | stimulus-rails 183 | turbo-rails 184 | webdrivers 185 | 186 | BUNDLED WITH 187 | 2.2.24 188 | -------------------------------------------------------------------------------- /MIT-LICENSE: -------------------------------------------------------------------------------- 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. 21 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # rollup.js for Rails 2 | 3 | This gem has been replaced by a [unified jsbundling-rails gem](https://github.com/rails/jsbundling-rails) that includes support for esbuild, rollup-js, and Webpack. 4 | -------------------------------------------------------------------------------- /bin/release: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | VERSION=$1 4 | 5 | printf "module Rollup\n VERSION = \"$VERSION\"\nend\n" > ./lib/rollup/version.rb 6 | bundle 7 | git add Gemfile.lock lib/rollup/version.rb 8 | git commit -m "Bump version for $VERSION" 9 | git push 10 | git tag v$VERSION 11 | git push --tags 12 | gem build rollupjs-rails.gemspec 13 | gem push "rollupjs-rails-$VERSION.gem" --host https://rubygems.org 14 | rm "rollupjs-rails-$VERSION.gem" 15 | -------------------------------------------------------------------------------- /lib/install/application.js: -------------------------------------------------------------------------------- 1 | // Entrypoint for the build script in your package.json 2 | -------------------------------------------------------------------------------- /lib/install/install.rb: -------------------------------------------------------------------------------- 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 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" 29 | -------------------------------------------------------------------------------- /lib/install/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "myapp", 3 | "private": "true", 4 | "scripts": { 5 | "build": "rollup -c rollup.config.js" 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /lib/install/rollup.config.js: -------------------------------------------------------------------------------- 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 | } 14 | -------------------------------------------------------------------------------- /lib/rollup/engine.rb: -------------------------------------------------------------------------------- 1 | module Rollup 2 | class Engine < ::Rails::Engine 3 | end 4 | end 5 | -------------------------------------------------------------------------------- /lib/rollup/version.rb: -------------------------------------------------------------------------------- 1 | module Rollup 2 | VERSION = "0.1.1" 3 | end 4 | -------------------------------------------------------------------------------- /lib/rollupjs-rails.rb: -------------------------------------------------------------------------------- 1 | module Rollup 2 | end 3 | 4 | require "rollup/version" 5 | require "rollup/engine" 6 | -------------------------------------------------------------------------------- /lib/tasks/rollup/compile.rake: -------------------------------------------------------------------------------- 1 | namespace :rollup do 2 | desc "Compile using rollup with yarn build" 3 | task :compile do 4 | system "yarn install && yarn build" 5 | end 6 | end 7 | 8 | Rake::Task["assets:precompile"].enhance(["rollup:compile"]) 9 | Rake::Task["test:prepare"].enhance(["rollup:compile"]) 10 | -------------------------------------------------------------------------------- /lib/tasks/rollup/install.rake: -------------------------------------------------------------------------------- 1 | namespace :rollup do 2 | desc "Setup rollup" 3 | task :install do 4 | system "#{RbConfig.ruby} ./bin/rails app:template LOCATION=#{File.expand_path("../../install/install.rb", __dir__)}" 5 | end 6 | end 7 | -------------------------------------------------------------------------------- /rollupjs-rails.gemspec: -------------------------------------------------------------------------------- 1 | require_relative "lib/rollup/version" 2 | 3 | Gem::Specification.new do |spec| 4 | spec.name = "rollupjs-rails" 5 | spec.version = Rollup::VERSION 6 | spec.authors = [ "David Heinemeier Hansson" ] 7 | spec.email = "david@loudthinking.com" 8 | spec.homepage = "https://github.com/rails/rollupjs-rails" 9 | spec.summary = "Bundle and transpile JavaScript in Rails with rollup.js." 10 | spec.license = "MIT" 11 | 12 | spec.files = Dir["lib/**/*", "MIT-LICENSE", "README.md"] 13 | 14 | spec.add_dependency "rails", ">= 6.0.0" 15 | end 16 | --------------------------------------------------------------------------------