Skip to content

Commit 3b23bae

Browse files
committed
Upgrade JS stack
1 parent 112dbad commit 3b23bae

23 files changed

+2505
-5536
lines changed

Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ ruby '3.1.2'
66
gem 'rails', '~> 6.1'
77
gem 'pg'
88
gem 'puma'
9-
gem 'webpacker'
9+
gem 'shakapacker'
1010
gem 'bootsnap'
1111
gem 'haml'
1212
gem 'draper'

Gemfile.lock

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,11 @@ GEM
156156
rack (>= 1.4)
157157
ruby2_keywords (0.0.5)
158158
semantic_range (3.0.0)
159+
shakapacker (6.2.1)
160+
activesupport (>= 5.2)
161+
rack-proxy (>= 0.6.1)
162+
railties (>= 5.2)
163+
semantic_range (>= 2.3.0)
159164
sprockets (4.0.3)
160165
concurrent-ruby (~> 1.0)
161166
rack (> 1, < 3)
@@ -169,11 +174,6 @@ GEM
169174
tilt (2.0.10)
170175
tzinfo (2.0.4)
171176
concurrent-ruby (~> 1.0)
172-
webpacker (5.4.3)
173-
activesupport (>= 5.2)
174-
rack-proxy (>= 0.6.1)
175-
railties (>= 5.2)
176-
semantic_range (>= 2.3.0)
177177
websocket-driver (0.7.5)
178178
websocket-extensions (>= 0.1.0)
179179
websocket-extensions (0.1.5)
@@ -192,8 +192,8 @@ DEPENDENCIES
192192
pg
193193
puma
194194
rails (~> 6.1)
195+
shakapacker
195196
sqlite3
196-
webpacker
197197

198198
RUBY VERSION
199199
ruby 3.1.2p20

app/frontend/assets/javascripts/my_app/datatables/cities_datatable.coffee

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { DatatableBase } from '@jbox-web/datatables-factory/src/index.coffee'
1+
import { DatatableBase } from '@jbox-web/datatables-factory'
22

33
class CitiesDatatable extends DatatableBase
44

app/frontend/assets/javascripts/my_app/datatables/posts_datatable.coffee

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { DatatableBase } from '@jbox-web/datatables-factory/src/index.coffee'
1+
import { DatatableBase } from '@jbox-web/datatables-factory'
22

33
class PostsDatatable extends DatatableBase
44

app/frontend/assets/javascripts/my_app/datatables/transactions_datatable.coffee

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { DatatableBase } from '@jbox-web/datatables-factory/src/index.coffee'
1+
import { DatatableBase } from '@jbox-web/datatables-factory'
22

33
class TransactionsDatatable extends DatatableBase
44

app/frontend/assets/javascripts/my_app/datatables/users_datatable.coffee

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { DatatableBase } from '@jbox-web/datatables-factory/src/index.coffee'
1+
import { DatatableBase } from '@jbox-web/datatables-factory'
22

33
class UsersDatatable extends DatatableBase
44

app/frontend/packs/application.coffee

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ require 'popper.js'
1212
require 'bootstrap'
1313

1414
# Load Rails UJS
15-
import {} from 'jquery-ujs'
15+
import Rails from '@rails/ujs'
16+
Rails.start()
1617

17-
# Load Turbolinks
18-
import Turbolinks from 'turbolinks'
19-
Turbolinks.start()
18+
# Load Turbo(links)
19+
import "@hotwired/turbo-rails"
2020

2121
# Load Select2
2222
require 'select2/dist/js/select2.full.js'
@@ -42,13 +42,13 @@ $.extend $.fn.dataTable.defaults,
4242
order: []
4343

4444
# Load DatatablesFactory
45-
import { DatatableBase } from '@jbox-web/datatables-factory/src/index.coffee'
45+
import { DatatableBase } from '@jbox-web/datatables-factory'
4646

4747
# Close context_menu when click outside
4848
$(document).on('click', DatatableBase.clean_context_menu)
4949

5050
# Load datatables
51-
$(document).on('turbolinks:load', DatatableBase.load_datatables)
51+
$(document).on('turbo:load', DatatableBase.load_datatables)
5252

5353
# Load application JS
5454
import { MyApp, Datatables } from 'my_app/index.coffee'

app/helpers/common/font_awesome_helper.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ module FontAwesomeHelper
3333
# # => <li><i class="fa fa-check fa-li"></i> Bulleted list item</li>
3434
def fa_icon(names = 'flag', original_options = {})
3535
options = original_options.deep_dup
36-
classes = [(options.delete(:icon_style) { 'fas' } || 'fas')]
36+
classes = [options.delete(:icon_style) { 'fa-solid' } || 'fa-solid']
3737
classes.concat Private.icon_names(names)
3838
classes.concat Array(options.delete(:class))
3939
text = options.delete(:text)

babel.config.js

Lines changed: 10 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
module.exports = function(api) {
1+
const { moduleExists } = require('shakapacker')
2+
3+
module.exports = function config(api) {
24
var validEnv = ['development', 'test', 'production']
35
var currentEnv = api.env()
46
var isDevelopmentEnv = api.env('development')
@@ -28,45 +30,21 @@ module.exports = function(api) {
2830
(isProductionEnv || isDevelopmentEnv) && [
2931
'@babel/preset-env',
3032
{
31-
forceAllTransforms: true,
3233
useBuiltIns: 'entry',
33-
corejs: 3,
34-
modules: false,
34+
corejs: '3.8',
35+
modules: 'auto',
36+
bugfixes: true,
37+
loose: true,
3538
exclude: ['transform-typeof-symbol']
3639
}
3740
]
3841
].filter(Boolean),
3942
plugins: [
4043
'babel-plugin-macros',
41-
'@babel/plugin-syntax-dynamic-import',
42-
isTestEnv && 'babel-plugin-dynamic-import-node',
43-
'@babel/plugin-transform-destructuring',
44-
[
45-
'@babel/plugin-proposal-class-properties',
46-
{
47-
loose: true
48-
}
49-
],
50-
[
51-
'@babel/plugin-proposal-object-rest-spread',
52-
{
53-
useBuiltIns: true
54-
}
55-
],
56-
[
57-
'@babel/plugin-transform-runtime',
58-
{
59-
helpers: false
60-
}
61-
],
62-
[
63-
'@babel/plugin-transform-regenerator',
64-
{
65-
async: false
66-
}
67-
],
44+
['@babel/plugin-proposal-class-properties', { loose: true }],
45+
['@babel/plugin-transform-runtime', { helpers: false }],
6846
[
69-
require('babel-plugin-module-resolver').default,
47+
'babel-plugin-module-resolver',
7048
{
7149
root: [
7250
'./app/frontend/assets/javascripts',

bin/webpack renamed to bin/webpacker

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ require "pathname"
77
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
88
Pathname.new(__FILE__).realpath)
99

10+
require "rubygems"
1011
require "bundler/setup"
1112

1213
require "webpacker"

bin/webpack-dev-server renamed to bin/webpacker-dev-server

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ require "pathname"
77
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
88
Pathname.new(__FILE__).realpath)
99

10+
require "rubygems"
1011
require "bundler/setup"
1112

1213
require "webpacker"

config/webpack/development.js

Lines changed: 0 additions & 12 deletions
This file was deleted.

config/webpack/environment.js

Lines changed: 0 additions & 46 deletions
This file was deleted.

config/webpack/loaders/datatables.js

Lines changed: 0 additions & 11 deletions
This file was deleted.

config/webpack/loaders/jquery.js

Lines changed: 0 additions & 7 deletions
This file was deleted.

config/webpack/production.js

Lines changed: 0 additions & 5 deletions
This file was deleted.

config/webpack/rules/datatables.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
module.exports = {
2+
module: {
3+
rules: [
4+
{
5+
test: /datatables\.net.*/,
6+
use: [
7+
{
8+
loader: require.resolve('imports-loader'),
9+
options: {
10+
additionalCode: 'var define = false;',
11+
},
12+
},
13+
],
14+
}
15+
]
16+
}
17+
}

config/webpack/rules/jquery.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
module.exports = {
2+
module: {
3+
rules: [
4+
{
5+
test: require.resolve('jquery'),
6+
use: [
7+
{
8+
loader: require.resolve('expose-loader'),
9+
options: {
10+
exposes: ['$', 'jQuery', 'jquery'],
11+
},
12+
},
13+
],
14+
}
15+
]
16+
}
17+
}

config/webpack/test.js

Lines changed: 0 additions & 5 deletions
This file was deleted.

0 commit comments

Comments
 (0)