Skip to content

Commit aa6e6ae

Browse files
committed
switch to esbuild for JS management
1 parent c856e88 commit aa6e6ae

14 files changed

Lines changed: 54 additions & 43 deletions

File tree

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,7 @@ spec/examples.txt
3030
*.local
3131
.env
3232

33+
/app/assets/builds/*
34+
!/app/assets/builds/.keep
35+
3336
/node_modules

Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ gem "sprockets"
2424
gem "sprockets-rails"
2525
gem "stripe"
2626
gem "thread"
27-
gem "uglifier"
27+
gem "jsbundling-rails"
2828
gem "will_paginate"
2929

3030
group :development do

Gemfile.lock

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,6 @@ GEM
142142
erubi (1.13.1)
143143
et-orbi (1.4.0)
144144
tzinfo
145-
execjs (2.10.0)
146145
factory_bot (6.5.6)
147146
activesupport (>= 6.1.0)
148147
feedbag (1.0.2)
@@ -178,6 +177,8 @@ GEM
178177
pp (>= 0.6.0)
179178
rdoc (>= 4.0.0)
180179
reline (>= 0.4.2)
180+
jsbundling-rails (1.3.1)
181+
railties (>= 6.0.0)
181182
json (2.18.1)
182183
language_server-protocol (3.17.0.5)
183184
lint_roller (1.1.0)
@@ -396,8 +397,6 @@ GEM
396397
tsort (0.2.0)
397398
tzinfo (2.0.6)
398399
concurrent-ruby (~> 1.0)
399-
uglifier (4.2.1)
400-
execjs (>= 0.3.0, < 3)
401400
unicode-display_width (3.2.0)
402401
unicode-emoji (~> 4.1)
403402
unicode-emoji (4.2.0)
@@ -448,6 +447,7 @@ DEPENDENCIES
448447
feedjira
449448
good_job (~> 4.13.0)
450449
httparty
450+
jsbundling-rails
451451
nokogiri (~> 1.19.0)
452452
pg
453453
pry-byebug
@@ -470,7 +470,6 @@ DEPENDENCIES
470470
sprockets-rails
471471
stripe
472472
thread
473-
uglifier
474473
web-console
475474
webdrivers
476475
webmock

Procfile.dev

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
web: PORT=3000 bundle exec puma -C config/puma.rb
2+
js: pnpm build --watch

app/assets/builds/.keep

Whitespace-only changes.

app/assets/config/manifest.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
//= link_tree ../images
22
//= link_directory ../stylesheets .css
3-
//= link_directory ../javascripts .js
3+
//= link_directory ../builds .js
Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
1-
//= require jquery.min.js
2-
//= require bootstrap.min.js
3-
//= require mousetrap.js
4-
//= require jquery.visible.min.js
5-
//= require underscore.js
6-
//= require backbone.js
1+
import "jquery";
2+
import "bootstrap";
3+
import "mousetrap";
4+
import "jquery-visible";
5+
import _ from "underscore";
6+
import Backbone from "backbone";
7+
8+
/* global jQuery, Mousetrap */
9+
var $ = jQuery;
10+
11+
window.$ = $;
12+
13+
Backbone.$ = $;
714

815
_.templateSettings = {
916
interpolate: /\{\{=(.+?)\}\}/g,
@@ -337,3 +344,8 @@ $(document).ready(function() {
337344
$("#shortcuts").modal('toggle');
338345
});
339346
});
347+
348+
window.StoryList = StoryList;
349+
window.AppView = AppView;
350+
351+
export { Story, StoryView, StoryList, AppView };

bin/dev

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
#!/usr/bin/env ruby
2-
# frozen_string_literal: true
1+
#!/usr/bin/env bash
32

4-
exec "./bin/rails", "server", *ARGV
3+
if ! gem list foreman -i --silent; then
4+
echo "Installing foreman..."
5+
gem install foreman
6+
fi
7+
8+
exec foreman start -f Procfile.dev "$@"

config/initializers/assets.rb

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,7 @@
77

88
# Add additional assets to the asset load path.
99
Rails.application.config.assets.paths += [
10-
Rails.root.join("node_modules/backbone"),
11-
Rails.root.join("node_modules/bootstrap/dist/js"),
1210
Rails.root.join("node_modules/bootstrap/dist/css"),
13-
Rails.root.join("node_modules/jquery"),
14-
Rails.root.join("node_modules/mousetrap"),
15-
Rails.root.join("node_modules/underscore"),
16-
Rails.root.join("node_modules/jquery-visible"),
1711
Rails.root.join("node_modules/@fontsource/lato/files"),
1812
Rails.root.join("node_modules/@fontsource/reenie-beanie/files"),
1913
Rails.root.join("node_modules/font-awesome/css"),

eslint.config.mjs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,11 @@ import globals from "globals";
44
export default [
55
js.configs.recommended,
66
{
7+
files: ["app/javascript/**"],
78
languageOptions: {
8-
sourceType: "script",
9+
sourceType: "module",
910
globals: {
1011
...globals.browser,
11-
Backbone: "readonly",
12-
_: "readonly",
13-
$: "readonly",
14-
jQuery: "readonly",
15-
Mousetrap: "readonly",
1612
},
1713
},
1814
rules: {
@@ -25,13 +21,15 @@ export default [
2521
languageOptions: {
2622
sourceType: "module",
2723
globals: {
24+
...globals.browser,
25+
jQuery: "readonly",
2826
Story: "readonly",
2927
StoryView: "readonly",
3028
StoryList: "readonly",
3129
},
3230
},
3331
},
3432
{
35-
ignores: ["vendor/", "coverage/", "spec/javascript/support/", "public/"],
33+
ignores: ["vendor/", "coverage/", "spec/javascript/support/", "public/", "app/assets/builds/"],
3634
},
3735
];

0 commit comments

Comments
 (0)