Repository navigation
docs(extractor): explain why exported styled components keep selector markers - #907
Merged
Merged
Conversation
Since #736 every exported styled component carries an `a--N` marker class, which looked like a regression of #730 limiting markers to selected components. It is needed: an importer selects or extends the component by the marker it computes from the export, and the defining module is built without knowing its importers, so only emitting the class up front works. Document this on `markers_of` and in the limitations page. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests.
🚀 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.
Summary
The audit flagged a decision (b) regression. Since #736 (70dac33), every styled component the file exports has an
a--Nmarker class. Inextractor__tests__emotion_component_selectors.snap,Parenthas one even though no selector names it, while #730 had limited markers to components a selector references.This PR leaves the behavior as it is and explains why. Removing these markers would break selectors that work today:
markers_of(name, exported, selected)gives an exported component one marker per export name,css::component_marker(export, index, filename). A module that imports it computes that same marker from the export when it selects the component (${Child} { ... },[Child]) or extends it (styled(Child)). Theimported_components_are_selected_by_the_class_their_module_givessnapshots cover this.So a marker on an exported component can't wait until something references it. Components a file keeps to itself still get a marker only when a selector in the file names it, which is #730's behavior. The other marked class in that snapshot,
Wide, carriesChild's marker because it extendsChild. That is Emotion's semantics, not an extra marker.Changes:
markers_ofrecording the reason.limitationspage: a "Known limitations" entry describing the marker on exported components.Refs #690
Test plan
cargo fmt --all -- --check(comment and docs only; no code path changes)🤖 Generated with Claude Code