Add react-strict-dom/postcss-plugin#282
Closed
javascripter wants to merge 1 commit into
Closed
Conversation
af8ece6 to
0fb8332
Compare
0fb8332 to
0e13940
Compare
javascripter
commented
Mar 12, 2025
| @@ -0,0 +1,182 @@ | |||
| /** | |||
Contributor
Author
There was a problem hiding this comment.
Unchanged from @stylexjs/postcss-plugin
| // Determines if the source code should be transformed based on the presence of StyleX/RSD imports. | ||
| function shouldTransform(sourceCode) { | ||
| return ( | ||
| sourceCode.includes('stylex') || sourceCode.includes('react-strict-dom') |
Contributor
Author
There was a problem hiding this comment.
Added react-strict-dom check
| */ | ||
|
|
||
| const babel = require('@babel/core'); | ||
| const reactStrictBabelPreset = require('react-strict-dom/babel-preset'); |
Contributor
Author
There was a problem hiding this comment.
Replaced StyleX Plugin with RSD Babel Preset to match behaviors exactly as described in docs
| filename: id, | ||
| caller: { | ||
| name: 'react-strict-dom/postcss-plugin', | ||
| platform: 'web', |
Contributor
Author
There was a problem hiding this comment.
platform: 'web' is necessary for RSD Preset to process source code with StyleX
| function bundle({ useCSSLayers }) { | ||
| const rules = Array.from(styleXRulesMap.values()).flat(); | ||
|
|
||
| const css = reactStrictBabelPreset.generateStyles(rules); |
Contributor
Author
There was a problem hiding this comment.
Uses RSD Babel Preset here as well
| }) => { | ||
| include = [ | ||
| // Include the React Strict DOM package's source files by default | ||
| require.resolve('react-strict-dom'), |
Contributor
Author
There was a problem hiding this comment.
Include react-strict-dom by default, same as postcss-react-strict-dom
2 tasks
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.
Update
Continuing on #308
Why
#281 (comment)
Based on the discussion, I'm moving postcss-react-strict-dom to the official repo to make it easier for maintainers to make changes.
How
packages/react-strict-dom/postcss/plugin.jsreact-strict-dom/postcss-pluginin package.jsonapps/examplesto use the official plugin and removed postcss-react-strict-dom dependencyI initially tried to re-export the postcss plugin as described here, but found that I needed to make modifications to the internals of the plugin, so I copied the source code from StyleX repository and made necessary modifications to make it work with RSD instead.
(Changes from StyleX PostCSS Plugin will be in PR comments)
Test Plan
cd apps/example && npm run dev:webboth from the original repo and this branch and compare side-by-side to make sure output matchesLeft is original, right is this branch