From 3e3df5fb6fa7ac2b8aeb7469a8b9569cca997cdc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Mon, 1 Jan 2024 21:23:01 -0800 Subject: [PATCH] Avoid using `Sprockets::Utils.module_include` in `SasscProcessor` if possible --- lib/sprockets/sassc_processor.rb | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/sprockets/sassc_processor.rb b/lib/sprockets/sassc_processor.rb index 372d3d0a5..334072b2d 100644 --- a/lib/sprockets/sassc_processor.rb +++ b/lib/sprockets/sassc_processor.rb @@ -44,6 +44,7 @@ def initialize(options = {}, &block) @sass_config = options[:sass_config] || {} @include_module_functions = Gem::Version.new(Autoload::SassC::VERSION) < Gem::Version.new('2.3.0') @functions = Module.new do + include Autoload::SassC::Script::Functions unless @include_module_functions include Functions include options[:functions] if options[:functions] class_eval(&block) if block_given? @@ -54,17 +55,15 @@ def call(input) context = input[:environment].context_class.new(input) options = engine_options(input, context) - options[:functions] = @functions engine = Autoload::SassC::Engine.new(input[:data], options) css = if @include_module_functions - Utils.module_include(Autoload::SassC::Script::Functions, @functions) do - engine.render - end - else - engine.render - end - css = css.sub(/^\n^\/\*# sourceMappingURL=.*\*\/$/m, '') + Utils.module_include(Autoload::SassC::Script::Functions, @functions) do + engine.render + end + else + engine.render + end.sub(/^\n^\/\*# sourceMappingURL=.*\*\/$/m, '') begin map = SourceMapUtils.format_source_map(JSON.parse(engine.source_map), input) @@ -282,6 +281,7 @@ def engine_options(input, context) filename: input[:filename], syntax: self.class.syntax, load_paths: input[:environment].paths, + functions: @functions, importer: @importer_class, source_map_contents: false, source_map_file: "#{input[:filename]}.map",