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

Chunks for indirect imports are missing from the client manifest #80

Open
quentinmit opened this issue Jun 3, 2024 · 0 comments
Open

Comments

@quentinmit
Copy link

quentinmit commented Jun 3, 2024

The client manifest generation looks only at the direct imports of client components when determining which chunks to list:

for (const connection of moduleGraph.getOutgoingConnections(
module,
)) {
for (const chunk of chunkGraph.getModuleChunksIterable(
connection.module,
)) {
chunksSet.add(chunk);
}
}

As a result, it misses chunks that are only referenced indirectly via import chains. e.g.

// a.ts
"use client";
import B from "./b";
export default function A() {
  return (<B />);
}
// b.ts
import C from "c";
export default function B() {
  return (<C />);
}
// node_modules/c/index.ts
export default function C() {
  return (<p>Hello world</p>);
}

will, with the default webpack config that places vendored code into a separate chunk, be missing the vendors*.js file in the client manifest. But if a.ts is changed to directly import c, the client manifest will contain the correct vendors chunk.

I tried to figure out the correct webpack API to find recursive dependencies for a module, but I didn't see one. In the webpack --stats verbose output, webpack uses the term "chunk group" to refer to clientN.js and its dependencies, but maybe there is a reason you were walking the module graph instead of the chunk graph. It looks like chunkGraph.getChunkEntryDependentChunksIterable might give the full set of chunks?

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

No branches or pull requests

1 participant