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

Fixes for CSS transformer #7869

Merged
merged 7 commits into from
Mar 30, 2022
Merged

Fixes for CSS transformer #7869

merged 7 commits into from
Mar 30, 2022

Conversation

devongovett
Copy link
Member

@devongovett devongovett commented Mar 26, 2022

Fixes #7858. Fixes #7859. Fixes #7865. Fixes #5985.

  • Ensures we don't remove unused symbols in the CSS optimizer after the packager already did that (for CSS modules processed by postcss)
  • Only adds dependencies to the JS asset of a CSS module, rather than both the JS and CSS. This avoids an issue where a dependency in CSS resolves to a JS asset, which breaks bundling. In order to make this work, I also needed to solve an issue in both bundlers, where dependencies in the JS part of a CSS module were included after the sibling CSS rather than before. This is solved by queuing assets to be added to sibling CSS bundles during post-order traversal rather than adding them during pre-order.
  • Sets the environment before adding dependencies rather than after. Replacing the environment also affects an asset's id, which is used in dependencies. If they don't match this breaks things downstream in the bundle graph when transforming for multiple environments, causing errors like "Error: Does not have node" when importing assets and using module/nomodule pattern #5985.
  • Uses postcss-modules to handle :export syntax in legacy CSS modules.

@parcel-benchmark
Copy link

parcel-benchmark commented Mar 26, 2022

Benchmark Results

Kitchen Sink 🚨

Timings

Description Time Difference
Cold FAILED -0.00ms
Cached FAILED -0.00ms

Cold Bundles

No bundles found, this is probably a failed build...

Cached Bundles

No bundles found, this is probably a failed build...

React HackerNews ✅

Timings

Description Time Difference
Cold 12.23s +82.00ms
Cached 543.00ms -2.00ms

Cold Bundles

No bundle changes detected.

Cached Bundles

No bundle changes detected.

AtlasKit Editor 🚨

Timings

Description Time Difference
Cold FAILED -0.00ms
Cached FAILED -0.00ms

Cold Bundles

No bundles found, this is probably a failed build...

Cached Bundles

No bundles found, this is probably a failed build...

Three.js ✅

Timings

Description Time Difference
Cold 8.65s +31.00ms
Cached 337.00ms -7.00ms

Cold Bundles

No bundle changes detected.

Cached Bundles

No bundle changes detected.

Click here to view a detailed benchmark overview.

@mischnic
Copy link
Member

The first issue you mentioned is probably the wrong one?

@mischnic
Copy link
Member

Looks good, apart from the bundlers - I have absolutely no clue how they work at this point.

If they don't match this breaks things downstream in the bundle graph when transforming for multiple environments, causing errors like

Ideally we'd somehow prevent this from happening in the first place. And if that's not possible, maybe throw an error if you do setEnvironment before addDependency so that this doesn't go unnoticed.

@devongovett
Copy link
Member Author

Ideally we'd somehow prevent this from happening in the first place

Yeah... setEnvironment is really a hack. Ideally we'd replace it with something better, but not sure what.

@devongovett devongovett merged commit 18daf9f into v2 Mar 30, 2022
@devongovett devongovett deleted the css-fixes2 branch March 30, 2022 00:11
@aminomancer
Copy link

Are you sure #7858 was fixed? I'm still experiencing the same issue on 2.8.3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants