fix(processor): validate external composes references - #1168
Open
NiedziolkaMichal wants to merge 1 commit into
Open
NiedziolkaMichal wants to merge 1 commit into
NiedziolkaMichal wants to merge 1 commit into
Conversation
`composes: x from "file.css"` didn't check that `x` exists in `file.css`. The missing class was only detected when generating compositions, which crashed with `TypeError: composition is not iterable`. Fail early with the same `Invalid composes reference` error as local references. Fixes tivac#1167 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
🦋 Changeset detectedLatest commit: 2fe0ed6 The changes in this PR will be included in the next version bump. This PR includes changesets to release 7 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
✅ Deploy Preview for m-css ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
This branch has not been deployed
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.
Description
composes: x from "file.css"now fails with the same error that local composes references already use:The check goes in the external-reference branch of
plugins/composition.js, next to the existing check for local references.files[source]is always populated at that point: the dependency is processed before the file that composes from it, and a file that can't be found is already rejected earlier ("Unable to locate …").Motivation and Context
Fixes #1167. Previously a missing class in another file wasn't detected until compositions were generated, which crashed with
TypeError: composition is not iterable (cannot read property undefined). That error doesn't name the file or the class. Integrations that generate output late, like a webpackprocessAssetshook, hit it after the build has already succeeded. In webpack watch mode that error is fatal and stops rebuilds until a restart.How Has This Been Tested?
packages/processor/test/composition.test.js. It fails without the change and passes with it.node --test packages/processor/test/*.test.js: 148 passing.npm run lint: clean.composition is not iterable#1167:processor.file()now rejects withInvalid composes referenceand points at the line inb.css.Types of changes
Checklist:
The issue, commit & PR were generated with claude. This is a real problem though, affecting our users. I hope you don't mind and we will be able to merge this quickly.