Remove internal copy of jekyll-terser (#2945)

# Summary

since https://github.com/RobertoJBeltran/jekyll-terser/pull/1 has been
merged, I'm removing the internal copy jekyll-terser and switching to
https://github.com/RobertoJBeltran/jekyll-terser instead. also,
refactored `Gemfile` a bit.
This commit is contained in:
Maruan 2025-01-09 07:34:44 -05:00 committed by GitHub
parent 1da2e64e73
commit f233233e19
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 57 additions and 154 deletions

21
Gemfile
View File

@ -1,7 +1,9 @@
source 'https://rubygems.org'
gem 'jekyll'
# Core plugins that directly affect site building
group :jekyll_plugins do
gem 'classifier-reborn'
gem 'jekyll'
gem 'jekyll-archives'
gem 'jekyll-email-protect'
gem 'jekyll-feed'
@ -15,17 +17,22 @@ group :jekyll_plugins do
gem 'jekyll-scholar'
gem 'jekyll-sitemap'
gem 'jekyll-tabs'
gem 'jekyll-terser', :git => "https://github.com/RobertoJBeltran/jekyll-terser.git"
gem 'jekyll-toc'
gem 'jekyll-twitter-plugin'
gem 'jemoji'
gem 'terser'
gem 'unicode_utils'
gem 'webrick'
gem 'classifier-reborn' # used for content categorization during the build
end
# Gems for development or external data fetching (outside :jekyll_plugins)
group :other_plugins do
gem 'css_parser'
gem 'feedjira'
gem 'httparty'
gem 'observer' # used by jekyll-scholar
gem 'ostruct' # used by jekyll-twitter-plugin
gem 'observer' # used by jekyll-scholar
gem 'ostruct' # used by jekyll-twitter-plugin
gem 'terser' # used by jekyll-terser
# gem 'unicode_utils' -- should be already installed by jekyll
# gem 'webrick' -- should be already installed by jekyll
end

View File

@ -1,3 +1,11 @@
GIT
remote: https://github.com/RobertoJBeltran/jekyll-terser.git
revision: 2f737004fe4732b92021c84e4de71e6a8585ff01
specs:
jekyll-terser (0.2.2)
jekyll (>= 0.10.0)
terser (>= 1.0.0)
GEM
remote: https://rubygems.org/
specs:
@ -32,7 +40,7 @@ GEM
matrix (~> 0.4)
colorator (1.1.0)
concurrent-ruby (1.3.4)
connection_pool (2.4.1)
connection_pool (2.5.0)
crass (1.0.6)
csl (1.6.0)
namae (~> 1.0)
@ -59,8 +67,6 @@ GEM
ffi (1.17.1-arm-linux-gnu)
ffi (1.17.1-arm-linux-musl)
ffi (1.17.1-arm64-darwin)
ffi (1.17.1-x86-linux-gnu)
ffi (1.17.1-x86-linux-musl)
ffi (1.17.1-x86_64-darwin)
ffi (1.17.1-x86_64-linux-gnu)
ffi (1.17.1-x86_64-linux-musl)
@ -75,9 +81,6 @@ GEM
google-protobuf (4.29.2-arm64-darwin)
bigdecimal
rake (>= 13)
google-protobuf (4.29.2-x86-linux)
bigdecimal
rake (>= 13)
google-protobuf (4.29.2-x86_64-darwin)
bigdecimal
rake (>= 13)
@ -167,21 +170,17 @@ GEM
rb-fsevent (~> 0.10, >= 0.10.3)
rb-inotify (~> 0.9, >= 0.9.10)
logger (1.6.4)
loofah (2.23.1)
loofah (2.24.0)
crass (~> 1.0.2)
nokogiri (>= 1.12.0)
matrix (0.4.2)
mercenary (0.4.0)
mini_mime (1.1.5)
mini_portile2 (2.8.8)
minitest (5.25.4)
multi_xml (0.7.1)
bigdecimal (~> 3.1)
namae (1.2.0)
racc (~> 1.7)
nokogiri (1.18.1)
mini_portile2 (~> 2.8.2)
racc (~> 1.4)
nokogiri (1.18.1-aarch64-linux-gnu)
racc (~> 1.4)
nokogiri (1.18.1-aarch64-linux-musl)
@ -211,26 +210,22 @@ GEM
rexml (3.4.0)
rouge (4.5.1)
safe_yaml (1.0.5)
sass-embedded (1.83.0-aarch64-linux-gnu)
google-protobuf (~> 4.28)
sass-embedded (1.83.0-aarch64-linux-musl)
google-protobuf (~> 4.28)
sass-embedded (1.83.0-arm-linux-gnueabihf)
google-protobuf (~> 4.28)
sass-embedded (1.83.0-arm-linux-musleabihf)
google-protobuf (~> 4.28)
sass-embedded (1.83.0-arm64-darwin)
google-protobuf (~> 4.28)
sass-embedded (1.83.0-x86-linux-gnu)
google-protobuf (~> 4.28)
sass-embedded (1.83.0-x86-linux-musl)
google-protobuf (~> 4.28)
sass-embedded (1.83.0-x86_64-darwin)
google-protobuf (~> 4.28)
sass-embedded (1.83.0-x86_64-linux-gnu)
google-protobuf (~> 4.28)
sass-embedded (1.83.0-x86_64-linux-musl)
google-protobuf (~> 4.28)
sass-embedded (1.83.1-aarch64-linux-gnu)
google-protobuf (~> 4.29)
sass-embedded (1.83.1-aarch64-linux-musl)
google-protobuf (~> 4.29)
sass-embedded (1.83.1-arm-linux-gnueabihf)
google-protobuf (~> 4.29)
sass-embedded (1.83.1-arm-linux-musleabihf)
google-protobuf (~> 4.29)
sass-embedded (1.83.1-arm64-darwin)
google-protobuf (~> 4.29)
sass-embedded (1.83.1-x86_64-darwin)
google-protobuf (~> 4.29)
sass-embedded (1.83.1-x86_64-linux-gnu)
google-protobuf (~> 4.29)
sass-embedded (1.83.1-x86_64-linux-musl)
google-protobuf (~> 4.29)
sax-machine (1.3.2)
securerandom (0.4.1)
terminal-table (3.0.2)
@ -242,7 +237,6 @@ GEM
uglifier (4.2.1)
execjs (>= 0.3.0, < 3)
unicode-display_width (2.6.0)
unicode_utils (1.4.0)
uri (1.0.2)
webrick (1.9.1)
@ -250,15 +244,11 @@ PLATFORMS
aarch64-linux
aarch64-linux-gnu
aarch64-linux-musl
arm-linux
arm-linux-gnu
arm-linux-gnueabihf
arm-linux-musl
arm-linux-musleabihf
arm64-darwin
x86-linux
x86-linux-gnu
x86-linux-musl
x86_64-darwin
x86_64-linux
x86_64-linux-gnu
@ -283,14 +273,13 @@ DEPENDENCIES
jekyll-scholar
jekyll-sitemap
jekyll-tabs
jekyll-terser!
jekyll-toc
jekyll-twitter-plugin
jemoji
observer
ostruct
terser
unicode_utils
webrick
BUNDLED WITH
2.6.2

View File

@ -221,10 +221,10 @@ plugins:
- jekyll/scholar
- jekyll-sitemap
- jekyll-tabs
- jekyll-terser
- jekyll-toc
- jekyll-twitter-plugin
- jemoji
- terser
# Sitemap settings
defaults:
@ -633,6 +633,7 @@ third_party_libraries:
jekyll_get_json:
- data: resume
json: assets/json/resume.json # it can also be an url
jsonresume:
- basics
- work

View File

@ -1,102 +0,0 @@
# based on https://github.com/RobertoJBeltran/jekyll-terser
# it should be changed to use `jekyll-terser` gem after https://github.com/RobertoJBeltran/jekyll-terser/pull/1 is merged
require 'terser'
module Jekyll
module Terser
class JSFile < Jekyll::StaticFile
@@mtimes = {}
# Initialize a new JSFile.
# +site+ is the Site
# +base+ is the String path to the <source>
# +dir+ is the String path between <source> and the file
# +name+ is the String filename of the file
# +terser+ is the Terser instance
def initialize(site, base, dir, name, terser = nil)
super(site, base, dir, name)
@site = site
@base = base
@dir = dir
@name = name
if terser.nil?
if site.config["terser"].nil?
options = {}
else
options = site.config["terser"]
end
@terser = ::Terser.new(options.transform_keys(&:to_sym))
else
@terser = terser
end
end
# Obtain destination path.
# +dest+ is the String path to the destination dir
#
# Returns destination file path.
def destination(dest)
File.join(dest, @dir, @name)
end
# Process the .js file
# +dest+ is the String path to the destination dir
#
# Returns false if the file was not modified since last time (no-op).
def write(dest)
dest_path = destination(dest)
return false if File.exist? dest_path and !modified?
@@mtimes[path] = mtime
FileUtils.mkdir_p(File.dirname(dest_path))
begin
content = File.read(path)
content = @terser.compile(content)
File.open(dest_path, 'w') do |f|
f.write(content)
end
rescue => e
STDERR.puts "Terser Exception: #{e.message}"
end
true
end
end
class TerserGenerator < Jekyll::Generator
safe true
# Initialize options from site config.
def initialize(config = {})
# check if options is not empty
if config["terser"].nil?
@options = {}
else
@options = config["terser"]
end
@terser = ::Terser.new(@options.transform_keys(&:to_sym))
end
# Jekyll will have already added the *.js files as Jekyll::StaticFile
# objects to the static_files array. Here we replace those with a
# JSFile object.
def generate(site)
site.static_files.clone.each do |sf|
# do not process already minified files
if sf.kind_of?(Jekyll::StaticFile) && sf.path =~ /\.js$/ && !sf.path.end_with?(".min.js")
puts "Terser: Minifying #{sf.path}"
site.static_files.delete(sf)
name = File.basename(sf.path)
destination = File.dirname(sf.path).sub(site.source, '')
js_file = JSFile.new(site, site.source, destination, name, @terser)
site.static_files << js_file
end
end
end
end
end
end

20
package-lock.json generated
View File

@ -1,5 +1,5 @@
{
"name": "main",
"name": "al-folio",
"lockfileVersion": 3,
"requires": true,
"packages": {
@ -10,10 +10,11 @@
}
},
"node_modules/@shopify/liquid-html-parser": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/@shopify/liquid-html-parser/-/liquid-html-parser-2.0.0.tgz",
"integrity": "sha512-1jqA50g2/WFTnnBnaiaNVammkJLIkt+z2QU2stFN2ljnYR28ln3q0VqlXqGNS0uRojEFaVNYrJl95IzAmjP5bQ==",
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/@shopify/liquid-html-parser/-/liquid-html-parser-2.2.0.tgz",
"integrity": "sha512-hD0XV+Re9BC3yMOshHCwU94LagW7LQTWPdtpU0IE/pMbco+ke7Hir1Ad7eloHAgzR+6iw4LzDEFuHFpKZWmGKw==",
"dev": true,
"license": "MIT",
"dependencies": {
"line-column": "^1.0.2",
"ohm-js": "^16.3.0"
@ -24,6 +25,7 @@
"resolved": "https://registry.npmjs.org/@shopify/prettier-plugin-liquid/-/prettier-plugin-liquid-1.4.0.tgz",
"integrity": "sha512-Fd0QiPi0bpSapUG0plri1+bLew9j//Q0MFKkBjkIG4RTJC76dycVysf5Dy7JvbvIjSJ4YFxaT0PBW5v9O7JItQ==",
"dev": true,
"license": "MIT",
"dependencies": {
"@shopify/liquid-html-parser": "^2.0.0",
"html-styles": "^1.0.0"
@ -36,19 +38,22 @@
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/html-styles/-/html-styles-1.0.0.tgz",
"integrity": "sha512-cDl5dcj73oI4Hy0DSUNh54CAwslNLJRCCoO+RNkVo+sBrjA/0+7E/xzvj3zH/GxbbBLGJhE0hBe1eg+0FINC6w==",
"dev": true
"dev": true,
"license": "MIT"
},
"node_modules/isarray": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz",
"integrity": "sha512-VLghIWNM6ELQzo7zwmcg0NmTVyWKYjvIeM83yjp0wRDTmUnrM678fQbcKBo6n2CJEF0szoG//ytg+TKla89ALQ==",
"dev": true
"dev": true,
"license": "MIT"
},
"node_modules/isobject": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/isobject/-/isobject-2.1.0.tgz",
"integrity": "sha512-+OUdGJlgjOBZDfxnDjYYG6zp487z0JGNQq3cYQYg5f5hKR+syHMsaztzGeml/4kGG55CSpKSpWTY+jYGgsHLgA==",
"dev": true,
"license": "MIT",
"dependencies": {
"isarray": "1.0.0"
},
@ -61,6 +66,7 @@
"resolved": "https://registry.npmjs.org/line-column/-/line-column-1.0.2.tgz",
"integrity": "sha512-Ktrjk5noGYlHsVnYWh62FLVs4hTb8A3e+vucNZMgPeAOITdshMSgv4cCZQeRDjm7+goqmo6+liZwTXo+U3sVww==",
"dev": true,
"license": "MIT",
"dependencies": {
"isarray": "^1.0.0",
"isobject": "^2.0.0"
@ -71,6 +77,7 @@
"resolved": "https://registry.npmjs.org/ohm-js/-/ohm-js-16.6.0.tgz",
"integrity": "sha512-X9P4koSGa7swgVQ0gt71UCYtkAQGOjciJPJAz74kDxWt8nXbH5HrDOQG6qBDH7SR40ktNv4x61BwpTDE9q4lRA==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=0.12.1"
}
@ -80,6 +87,7 @@
"resolved": "https://registry.npmjs.org/prettier/-/prettier-3.1.1.tgz",
"integrity": "sha512-22UbSzg8luF4UuZtzgiUOfcGM8s4tjBv6dJRT7j275NXsy2jb4aJa4NNveul5x4eqlF1wuhuR2RElK71RvmVaw==",
"dev": true,
"license": "MIT",
"bin": {
"prettier": "bin/prettier.cjs"
},