Share Tailwind v3/v4 plugin code in shared_tailwind
QU
1d ago+269+269+012345678901234567890123456789-233-233-012345678901234567890123456789
Type of change
Internal refactor, no behavior change.
tailwind_v3.py and tailwind_v4.py carried identical copies of compile_config, add_tailwind_to_css_file, _index_of_element_that_has, pre_compile, get_frontend_development_dependencies and four of their six Constants. AGENTS.md asks to extract duplicated code into parameterized helpers, so these now live once in shared_tailwind:
TailwindConstantsholds the shared constants. Each version'sConstantssubclasses it and addsVERSIONandROOT_STYLE_CONTENT.TailwindPluginimplementspre_compileand the dependency list. A version plugin supplies only its root style, its postcss rewrite and its packages.- The v4 plugin pinned
tailwindcss@4.3.0and@tailwindcss/postcss@4.3.0as two literals that were always bumped together. Both now come from one version string.
Verification:
- Generated output is byte-identical to main for both versions: config, root style with and without Radix, postcss and css rewrites, dependency lists.
- Module-level names (
compile_config,compile_root_style,add_tailwind_to_css_file,add_tailwind_to_postcss_config,Constants) stay importable fromtailwind_v3andtailwind_v4. - Adds a test that each plugin wires its own root-style and postcss tasks and pins its packages to a single version.
- ruff, pyright, ty and the pre-commit hooks pass.
Includes a misc news fragment for reflex-base.
- Have you written new tests for your core changes, as applicable?
- Have you successfully ran tests with your changes locally?