Repository navigation
fix(extractor): report Emotion code left at runtime as located errors - #904
Merged
Merged
Conversation
- `Section.withComponent(make())` on a styled component the file defines is a located build error: the component compiles to a plain function, so the kept call threw when the module loaded - an `@emotion/react` import with no Devup UI equivalent (`ThemeContext`, `withEmotionCache`, default or namespace) is a located error naming the export instead of an eprintln warning that kept the package - `@emotion/css/create-instance` loaded by an import, re-export, `require()` or `import()` is a located error while `@emotion/css` is aliased - Emotion's `cx` composes classes `css()` gives by their styles, so `cx(blue, red)` is red (last wins) instead of following stylesheet order - docs: limitations and migration overview match the new behavior Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2 of 3 tasks
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
Emotion code that the build can't compile now fails with a located build error instead of silently staying at runtime (#682). Emotion's
cxalso composes known classes in argument order.Section.withComponent(make())on a styled component the file defines is a located error.Sectioncompiles to a plain function, so keeping the call made the module throw when it loaded.other.withComponent(...)on an unknown object is still left alone. The retarget test drops theKeptline, and a new rstest covers the error with the exact message and location. Themake()filter inretained_render_assertions::retargetis gone.@emotion/reactimport with no Devup UI equivalent (ThemeContext,withEmotionCache, a default import,import * as E) is a located error that names the export. Before this it was aneprintln!warning, and@emotion/reactstayed a runtime dependency. Type-only imports still pass.@emotion/css/create-instanceis a located error while@emotion/cssis aliased. This covers every way it can be loaded:import,export … from,export *,require(),import x = require()andimport(). The newmodule_loadshelper finds these (the vanilla-extract PR adds the same file).cx(blue, red)came out as"a-b a-a", so stylesheet order decided and blue won.cxnow composes its arguments likecss()composition when at least one argument is a classcss()gave. Class maps are lowered to conditions, socx(blue, on && red, 'ext', { picked: true })merges with later wins. A template literal, a computed class-map key, or a class map nested inside an array or condition still uses the old join path.limitationsno longer listswithComponent(make())under "cascade decides" ormergeas not compiled, and it lists the new errors. Themigration/overviewpage no longer says the package can always be dropped.New build errors:
`withComponent()` cannot use `make()` at build time: …`@emotion/react` has no Devup UI equivalent of `ThemeContext` …`@emotion/css/create-instance` creates an Emotion instance at runtime …Refs #689
Refs #690
Test plan
cargo test -p extractor --lib -- emotion import_alias css_prop styled module_loads cx(3451 passed)emotion_cx_merges_known_styles_in_order,emotion_runtime_imports_are_located_errors. One existing snapshot changed:emotion_cx_takes_class_names, where only the class order insidebdiffers.cargo clippy -p extractor --all-targets -- -D warnings,cargo fmt --all🤖 Generated with Claude Code