rsnext/packages/next/build/webpack
Shu Ding f7069c0279
Fix unused CSS module imports are tracked on the server (#40996)
Reported by @hanneslund, when a CSS modules file gets imported in server
components, during `collectClientComponentsAndCSSForDependency` in our
client entry plugin it will always be collected no matter it is used or
not. Due to the restriction that we have to collect these imports to
create the client entry, it has to run in the `finishMake` compiler
phase and at that time, module optimization hasn't started yet.

To fix that issue, we run another pass in `afterOptimizeModules` just to
collect CSS imports for the server style manifest and we can filter out
unused modules there.

## Bug

- [ ] Related issues linked using `fixes #number`
- [x] Integration tests added
- [ ] Errors have a helpful link attached, see `contributing.md`

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the
feature request has been accepted for implementation before opening a
PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have a helpful link attached, see `contributing.md`

## Documentation / Examples

- [ ] Make sure the linting passes by running `pnpm lint`
- [ ] The "examples guidelines" are followed from [our contributing
doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md)

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2022-09-28 17:06:10 +02:00
..
config Font loader support in app (#40898) 2022-09-27 18:10:05 +00:00
loaders edge-ssr: bundle next/dist as ESM for better tree-shaking (#40251) (#40980) 2022-09-28 12:29:22 +02:00
plugins Fix unused CSS module imports are tracked on the server (#40996) 2022-09-28 17:06:10 +02:00
require-hook.ts Remove precopied styled-jsx (#39520) 2022-08-12 17:08:38 +00:00
stringify-request.ts Update loader-utils (#30743) 2021-11-02 16:13:15 +01:00