rsnext/packages/next/build
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
..
analysis [edge] serialize custom config to middleware-manifest (#40881) 2022-09-27 10:30:15 -07:00
babel Remove webpack4 types (#39631) 2022-08-16 09:55:37 +00:00
jest Set __NEXT_NEW_LINK_BEHAVIOR in Jest tests when newNextLinkBehavior is true (#40702) 2022-09-21 22:36:59 -07:00
output Remove webpack4 types (#39631) 2022-08-16 09:55:37 +00:00
polyfills Fix global process testing for the process polyfill (#33220) 2022-01-13 16:44:55 +00:00
swc Add local font loader (#40801) 2022-09-22 12:49:02 -07:00
webpack Fix unused CSS module imports are tracked on the server (#40996) 2022-09-28 17:06:10 +02:00
compiler.ts Remove webpack4 types (#39631) 2022-08-16 09:55:37 +00:00
cssnano-simple.js Pre-compile more dependencies (#32627) 2021-12-20 14:01:35 +01:00
entries.ts edge-ssr: bundle next/dist as ESM for better tree-shaking (#40251) (#40980) 2022-09-28 12:29:22 +02:00
generate-build-id.ts Fix generateBuildId type that can be async function (#28040) 2021-08-12 22:26:44 +00:00
index.ts feat(experimental): option to polyfill fetch using undici in Node.js <18 (#40318) 2022-09-27 13:37:28 -07:00
is-writeable.ts Use fs.promises instead of promisify (#12026) 2020-05-02 00:10:19 -04:00
load-jsconfig.ts Add handling for auto installing TypeScript deps and HMRing tsconfig (#39838) 2022-08-23 13:16:47 -05:00
spinner.ts [Feature] Progress bar for static build (#15297) 2020-08-04 09:58:23 +02:00
utils.ts Update return shape of generateStaticParams (#40965) 2022-09-27 13:51:07 -07:00
webpack-config.ts Fix wrong code condition used when bundling the server (#40987) 2022-09-28 16:19:40 +02:00
worker.ts Add handling for static generation in app (#40561) 2022-09-19 18:05:28 +00:00
write-build-id.ts Move code shared between server/client to "shared" folder (#26734) 2021-06-30 11:43:31 +02:00