Skip to content

Commit 89c6136

Browse files
committed
Drop base64 gem from dependency
This following warning is shown in test. ``` /Users/ryunosuke.sato/src/github.com/lautis/uglifier/spec/spec_helper.rb:3: warning: base64 was loaded from the standard library, but will no longer be part of the default gems starting from Ruby 3.4.0. You can add base64 to your Gemfile or gemspec to silence this warning. ``` Instead of adding base64 to dependency, the usage of `Base64#strict_encode64` and `Base64#strict_decode64` have replaced with `Array#pack` and `String#unpack1`.
1 parent 0947f7c commit 89c6136

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

lib/uglifier.rb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# encoding: UTF-8
22

33
require "json"
4-
require "base64"
54
require "execjs"
65
require "uglifier/version"
76

@@ -160,7 +159,7 @@ def initialize(options = {})
160159
def compile(source)
161160
if @options[:source_map]
162161
compiled, source_map = run_uglifyjs(source, true)
163-
source_map_uri = Base64.strict_encode64(source_map)
162+
source_map_uri = [source_map].pack('m0')
164163
source_map_mime = "application/json;charset=utf-8;base64"
165164
compiled + "\n//# sourceMappingURL=data:#{source_map_mime},#{source_map_uri}"
166165
else
@@ -512,7 +511,7 @@ def input_source_map(source, generate_map)
512511
source_map_options = @options[:source_map].is_a?(Hash) ? @options[:source_map] : {}
513512
sanitize_map_root(source_map_options.fetch(:input_source_map) do
514513
url = extract_source_mapping_url(source)
515-
Base64.strict_decode64(url.split(",", 2)[-1]) if url && url.start_with?("data:")
514+
url.split(",", 2)[-1].unpack1('m0') if url && url.start_with?("data:")
516515
end)
517516
rescue ArgumentError, JSON::ParserError
518517
nil

0 commit comments

Comments
 (0)