Resolve imports from CSS file#15010
Merged
Merged
Conversation
8c4fd84 to
691b093
Compare
When reading this, it almost looks like you made an error, but that's not the case. We will just find CSS files for you instead.
58ac51a to
ecca617
Compare
RobinMalfait
commented
Nov 15, 2024
Comment on lines
+92
to
+93
| // We don't want to process ignored files (like node_modules) | ||
| if (isIgnored(file)) continue |
Member
Author
There was a problem hiding this comment.
When you don't pass any files, then we used globby with the gitignore: true option, so I wanted to add that here as well.
I added an explicitly ignored CSS file to the integration tests to make sure we don't touch it.
| // | ||
| // We can't use the `sheet.root` directly because this will mutate the | ||
| // `sheet.root` | ||
| let processed = await postcss().use(atImport()).process(sheet.root.toString(), { from: file }) |
Contributor
There was a problem hiding this comment.
Is there a chance this would fail and we'd want to just skip it? Or should it hard crash or w/e?
Contributor
There was a problem hiding this comment.
Also shouldn't we be able to do some of this stuff in analyze() instead of using postcss-import or nah?
Member
Author
There was a problem hiding this comment.
Oh, hmm, let me try to move it. Might work indeed 🤔
This allows us to use a sync version in places where we can't use async code.
| if (sheet.file) { | ||
| stylesheetsByFile.set(sheet.file, sheet) | ||
| try { | ||
| let sheet = Stylesheet.loadSync(file) |
Contributor
There was a problem hiding this comment.
a little sad this isn't async but that's a much larger change
thecrypticace
approved these changes
Nov 15, 2024
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.
This PR adds an improvement to the upgrade tool to make sure that if you pass a single CSS file, that the upgrade tool resolves all the imports in that file and processes them as well.
Test plan:
Created a project where
index.cssimportsother.css. Anotherleave-me-alone.cssis created to proof that this file is not changed. Running the upgrade guide usingindex.cssalso migratesother.cssbut notleave-me-alone.css.Here is a video so you don't have to manually create it:
Screen.Recording.2024-11-15.at.21.36.27.mov