Skip to content

Commit

Permalink
Include frameworks in main-app (#41465)
Browse files Browse the repository at this point in the history
There is no need to have a separate `framework` chunk for React and React DOM, as they're already included in the `main-app` entry. With this PR, React and React DOM will be included in `main-app` directly and app is no longer depending on the `framework` chunk.

## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] 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)
  • Loading branch information
shuding committed Oct 17, 2022
1 parent 7be2ef0 commit a75b323
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions packages/next/build/webpack-config.ts
Expand Up @@ -1338,10 +1338,25 @@ export default async function getBaseWebpackConfig(
// and all other chunk depend on them so there is no
// duplication that need to be pulled out.
chunks: (chunk: any) =>
!/^(polyfills|main|pages\/_app)$/.test(chunk.name),
!/^(polyfills|main|main-app|pages\/_app)$/.test(chunk.name),
cacheGroups: {
framework: {
chunks: 'all',
chunks: (chunk) => {
const name = chunk.name

// Skip app directory and include shared modules in main-app.
if (
name &&
hasAppDir &&
(name === 'main-app' ||
name === 'app-internals' ||
name.startsWith('app/'))
) {
return false
}

return true
},
name: 'framework',
test(module: any) {
const resource = module.nameForCondition?.()
Expand Down

0 comments on commit a75b323

Please sign in to comment.