Skip to content
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

Merged
merged 8 commits into from
Jul 28, 2023
Merged

Handle external CSS #128

merged 8 commits into from
Jul 28, 2023

Conversation

mrm007
Copy link
Collaborator

@mrm007 mrm007 commented Jul 26, 2023

See changeset and the with-styles fixture for details.

@mrm007 mrm007 requested a review from a team as a code owner July 26, 2023 07:54
@changeset-bot
Copy link

changeset-bot bot commented Jul 26, 2023

🦋 Changeset detected

Latest commit: 2cb7239

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@crackle/core Minor
@crackle/cli Patch

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

@mrm007 mrm007 temporarily deployed to snapshot July 26, 2023 08:06 — with GitHub Actions Inactive
@mrm007 mrm007 temporarily deployed to snapshot July 27, 2023 00:17 — with GitHub Actions Inactive
Base automatically changed from deps to master July 28, 2023 00:15
Comment on lines 85 to 86
.map((bundle) => bundle.output)
.flat()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
.map((bundle) => bundle.output)
.flat()
.flatMap((bundle) => bundle.output)

Comment on lines 51 to 56
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;

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?

Copy link
Collaborator Author

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?

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

Copy link
Collaborator Author

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.

Copy link
Collaborator Author

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;

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?

Copy link
Collaborator Author

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', () => {

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?

@mrm007 mrm007 merged commit 433a30f into master Jul 28, 2023
@mrm007 mrm007 deleted the css-exports branch July 28, 2023 03:50
@seek-oss-ci seek-oss-ci mentioned this pull request Jul 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants