-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Handle external CSS #128
Handle external CSS #128
Conversation
🦋 Changeset detectedLatest commit: 2cb7239 The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 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 |
packages/core/src/entries/package.ts
Outdated
.map((bundle) => bundle.output) | ||
.flat() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.map((bundle) => bundle.output) | |
.flat() | |
.flatMap((bundle) => bundle.output) |
const keysDiff = arrayDiff(Object.keys(expected), Object.keys(actual)); | ||
const valuesDiff = arrayDiff( | ||
Object.values(expected).map((value) => JSON.stringify(value)), | ||
Object.values(actual).map((value) => JSON.stringify(value)), | ||
); | ||
return keysDiff.length > 0 || valuesDiff.length > 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this check if the correct value is matched up with the correct key? i.e. would it catch if two keys switched their values?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It doesn't catch that, but it would be a silly thing to do and IMO not worth covering that case.
What would the code to handle that case look like?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, like the deepStrictEqual
that used to be there
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
diffPackageJson
doesn't know that updatePackageJsonExports
injects extra CSS exports after the build is finished, so the diff must be a little more forgiving than before.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for (const entry of exports) { | ||
packageExports[makeRelative(entry)] = makeRelative(entry); | ||
} | ||
packageExports[lastKey] = lastExport; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it important that the CSS exports go last?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They go before the entry for package.json
, second to last. Having a predetermined order ensures there's no diff between runs.
@@ -158,23 +158,6 @@ describe('diffPackageJson', () => { | |||
expectSnapshots({ diffs, packageJson, expectedPackageJson }); | |||
}); | |||
|
|||
test('exports out of order', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the CSS last-ness is important, could we maybe update this test to check that it is going last?
See changeset and the
with-styles
fixture for details.