docs: explain how @use/@import requests are resolved - #1339
Merged
Conversation
Describe the resolution the loader performs through webpack: which candidates are tried, which parts of the `resolve` configuration apply (`alias`, `modules`, `byDependency.sass` via `dependencyType: "sass"`), which options are fixed to match Sass, how packages and the `pkg:` scheme resolve, the fallback to Sass's own resolution, and the difference between `@import` and `@use` for plain CSS files. Closes #1064 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013PtW7eezwuQP5epLFMrAky
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1339 +/- ##
=======================================
Coverage 96.62% 96.62%
=======================================
Files 2 2
Lines 1007 1007
=======================================
Hits 973 973
Misses 34 34 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1064
The README said resolution tries a relative path and then
node_modules, which left the reporter unsure whetherresolve.aliasparticipates and whetherresolve.modulesis used at all. Both do — this documents that, and the rest of what the loader actually does.What changed
Resolving import and use at-rulesbecomesResolving import, use and forward at-rulesand gains six short subsections:_index/indexfor directories, the.importfiles that apply to@importonly, and the relative-over-module preference.resolveconfiguration controls —alias,modules,byDependency.sass(requests are resolved withdependencyType: "sass"),plugins/symlinks/roots, with a config and stylesheet example. Then the options fixed to match Sass's algorithm — extensions,mainFiles,mainFields,conditionNames— including the note thatresolve.extensionstherefore does not apply, and that your ownmainFields/conditionNamesare kept after the Sass-specific ones.sass/styleexport conditions, thesass/style/mainfield fallback, and thepkg:scheme.loadPaths,SASS_PATHand any custom importer.@import "theme.css"stays a plain@importin the loader's output while@use "theme.css"inlines the file.~prefix — existing content, moved into its own subsection and updated to@use.Verification
Every claim was checked by building the case against the loader, with negative controls where a claim is about something not applying:
The alias + modules example in the README is the one from that run, so it compiles as written.
Two claims were corrected by testing rather than taken from the source comments:
_theme.scssandtheme.scssmakes Sass reportIt's not clear which file to import. The text says the order within a directory rarely matters and names the ambiguity instead.@import "theme.css"is not "never resolved by webpack": the loader leaves the@importin place, and the built-in CSS support orcss-loadermay then resolve it downstream. Confirmed by reading the loader's raw output throughasset/resource, where@import "theme.css"survives verbatim and@use "theme.css"inlines the content.Docs only — no code changes, so no changeset.
prettierandcspellpass.🤖 Generated with Claude Code
https://claude.ai/code/session_013PtW7eezwuQP5epLFMrAky
Generated by Claude Code