From 16c375c5ab66acb5fc7db9627ef96c667de3a7a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Thu, 4 Apr 2024 09:08:45 -0700 Subject: [PATCH] Remove support of importing non-standard extensions from relative path or load paths (#87) --- lib/sassc/embedded.rb | 32 ++++---------------------------- test/patches/sassc-rails.diff | 4 ++++ 2 files changed, 8 insertions(+), 28 deletions(-) diff --git a/lib/sassc/embedded.rb b/lib/sassc/embedded.rb index 3ac34fd..92c4163 100644 --- a/lib/sassc/embedded.rb +++ b/lib/sassc/embedded.rb @@ -235,15 +235,6 @@ def resolve_path(path, from_import) return exactly_one(try_path(path)) end - unless ext.empty? - if from_import - result = exactly_one(try_path("#{without_ext(path)}.import#{ext}")) - return warn_deprecation_ext(result) unless result.nil? - end - result = exactly_one(try_path(path)) - return warn_deprecation_ext(result) unless result.nil? - end - if from_import result = exactly_one(try_path_with_ext("#{path}.import")) return result unless result.nil? @@ -300,21 +291,6 @@ def without_ext(path) ext = File.extname(path) path.delete_suffix(ext) end - - def warn_deprecation_ext(path) - basename = File.basename(path) - warn <<~WARNING - Deprecation Warning: Importing files with extensions other than `.scss`, `.sass`, `.css` from relative path or load paths without custom SassC::Importer is deprecated. - - Recommandation: Rename #{basename} to #{basename}.scss - - More info: https://github.com/sass-contrib/sassc-embedded-shim-ruby/pull/86 - - #{path} - #{' ' * (path.length - basename.length)}#{'^' * basename.length} - WARNING - path - end end end @@ -342,10 +318,10 @@ def canonicalize(url, context) # Temporarily disable FileImporter optimization # https://github.com/sass/dart-sass/issues/2208 # - # if ['.sass', '.scss', '.css'].include?(File.extname(URL.file_url_to_path(canonical_url))) - # @canonical_urls[url] = canonical_url - # return nil - # end + # @canonical_urls[url] = canonical_url + # return nil + @canonical_urls[url] = canonical_url + return end @parent_urls.push(canonical_url) canonical_url diff --git a/test/patches/sassc-rails.diff b/test/patches/sassc-rails.diff index 4e1642f..3f6ca69 100644 --- a/test/patches/sassc-rails.diff +++ b/test/patches/sassc-rails.diff @@ -125,6 +125,10 @@ index 38349f7..34a4eb9 100644 + spec.add_dependency 'sprockets', '~> 4.2' + spec.add_dependency 'sprockets-rails', '~> 3.4' end +diff --git a/test/dummy/app/assets/stylesheets/partials/_explicit_extension_import.foo b/test/dummy/app/assets/stylesheets/partials/_explicit_extension_import.foo.scss +similarity index 100% +rename from test/dummy/app/assets/stylesheets/partials/_explicit_extension_import.foo +rename to test/dummy/app/assets/stylesheets/partials/_explicit_extension_import.foo.scss diff --git a/test/sassc_rails_test.rb b/test/sassc_rails_test.rb index a15110d..452a251 100644 --- a/test/sassc_rails_test.rb