Repository navigation
fix(extractor): let later StyleX keys override an include() - #975
Merged
Merged
Conversation
`{ ...stylex.include(s0.a), color: 'blue' }` prepended the included
classes to the namespace's own, so both the red and the blue class were
applied and red could win by stylesheet order. An include() written after
a key was prepended too, so its position was ignored.
Each include() now records how many keys come before it. When the
namespace and every namespace it includes are static, their keys are
merged in written order, a later key replacing the same key from before,
and the namespace gets the merged classes. Its keys are also recorded,
so stylex.props() resolves it per key instead of joining classes. A
dynamic namespace has no keys, so including one keeps prepending.
The StyleX migration page says the override now holds.
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 was referenced Nov 15, 2026
owjs3901
added a commit
that referenced
this pull request
Nov 17, 2026
#975 now lets keys written after include() override the included ones; keep this PR's legacy-include framing and state the new override rule instead of the old 'only added' caveat. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
6 tasks done
owjs3901
added a commit
that referenced
this pull request
Nov 17, 2026
visit.rs imports both main's include() key merging (StylexIncludeRef, joined_key_classes, merge_included_keys from #975) and this branch's typed_variable_rule; the two touch separate code paths and merged cleanly otherwise. The StyleX migration page keeps main's include() override rule and adds this branch's note that types.*() registers @Property in defineVars(). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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
Keys written after
...stylex.include(base.member)insidestylex.create()now override the included values. This is resolved statically at build time (#688).Problem
s0.ais{ color: 'red', margin: '1px' },{ ...stylex.include(s0.a), color: 'blue' }resulted in"margin red blue".include()was written was also ignored.{ color: 'blue', ...stylex.include(s0.a) }, by StyleX's rules the included red should win.stylex.props(s.x, other)did not merge per key (later-wins) and just concatenated classes.Changes
positiontoStylexIncludeRef. It is the number of keys written beforeinclude().merge_included_keys).':hover'all follow the same rule.stylex_keys, sostylex.props()also resolves this namespace per key.include()explanation inapps/landing/src/app/(detail)/docs/migration/stylex/page.mdx. It states that overriding is guaranteed at build time, and the dynamic namespace exception.Snapshot changes
stylex_include_basic:"fancy": "a b c"became"b a c".props(s.red, s.inc)case oftest_stylex_props_merge_keysto check the actual result.color-0-red--255matched on thes.reddefinition line, so it was effectively not a check.{ className: "margin-0-1px--255 color-0-green--255" }. Red is dropped.Overlapping PRs
types.*()explanation) andextract_style_from_stylex.rs. This PR's only change in that file is one line passingpositiontoinclude(), so the conflict is small.Test plan
test_stylex_include_later_declarations_overridefailed."margin red blue":hoverkey was not replacedtest_stylex_include_later_declarations_overrideprops(), dynamic include fallbackcargo test -p extractor --tests -j 2all passcargo clippy -p extractor --all-targets -- -D warnings,cargo fmt --allbunx prettier --single-quote --no-semi --check(mdx)요약
stylex.create()안의...stylex.include(base.member)뒤에 쓴 key가 포함된 값을 덮어쓰도록 바꿨습니다. 빌드 타임에 정적으로 해결합니다(#688).문제
s0.a가{ color: 'red', margin: '1px' }일 때{ ...stylex.include(s0.a), color: 'blue' }의 결과는"margin red blue"였습니다.include()를 쓴 위치도 무시됐습니다.{ color: 'blue', ...stylex.include(s0.a) }에서는 StyleX 기준으로 포함된 red가 이겨야 합니다.stylex.props(s.x, other)에서 key별 병합(later-wins)이 되지 않고 class만 이어 붙였습니다.변경
StylexIncludeRef에position을 추가했습니다.include()앞에 쓴 key 개수입니다.merge_included_keys).':hover'같은 조건 key 모두 같은 규칙입니다.stylex_keys에 기록합니다. 그래서stylex.props()도 이 namespace를 key 단위로 해결합니다.apps/landing/src/app/(detail)/docs/migration/stylex/page.mdx의include()설명을 바꿨습니다. 덮어쓰기가 빌드 타임에 보장된다는 것과 동적 namespace 예외를 적었습니다.스냅샷 변경
stylex_include_basic:"fancy": "a b c"가"b a c"로 바뀌었습니다.test_stylex_props_merge_keys의props(s.red, s.inc)케이스를 실제 결과로 검사하도록 고쳤습니다.color-0-red--255는s.red정의 줄에서 매칭되어 사실상 검사가 아니었습니다.{ className: "margin-0-1px--255 color-0-green--255" }를 확인합니다. red가 빠집니다.겹치는 PR
types.*()설명)과extract_style_from_stylex.rs를 건드립니다. 이 PR이 그 파일에서 바꾼 것은include()에position을 넘기는 한 줄뿐이라 충돌은 작습니다.테스트 계획
test_stylex_include_later_declarations_override가 실패했습니다."margin red blue":hoverkey가 대체되지 않음test_stylex_include_later_declarations_override7개 케이스props()를 통한 key 해결, 동적 include fallbackcargo test -p extractor --tests -j 2전체 통과cargo clippy -p extractor --all-targets -- -D warnings,cargo fmt --allbunx prettier --single-quote --no-semi --check(mdx)Refs #690
Refs #688
🤖 Generated with Claude Code