Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove support of importing non-standard extensions from relative path or load paths #87

Merged
merged 1 commit into from
Apr 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 4 additions & 28 deletions lib/sassc/embedded.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions test/patches/sassc-rails.diff
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down