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

Why ChunkExtractor is required? #992

Open
vadim-ch opened this issue Jan 4, 2024 · 3 comments
Open

Why ChunkExtractor is required? #992

vadim-ch opened this issue Jan 4, 2024 · 3 comments

Comments

@vadim-ch
Copy link

vadim-ch commented Jan 4, 2024

Hi there!
createLoadable function includes a condition that checks props.__chunkExtractor
https://github.com/gregberge/loadable-components/blob/main/packages/component/src/createLoadable.js#L149
What if i don't want to use ChunkExtractor at all? To be more correctly, i can't add ChunkExtractor, because i use ReactJs.NET on my server.

@theKashey
Copy link
Collaborator

Without chunk extractor active Loadable will not be able to properly hydrate App as it will not know which chunks are required to be loaded first.

I am not sure how exactly ReactJs.NET works and why you cannot use ChunkExtractor and it's more about webpack rather than platform, but if you still can use Babel try a sibling solution - https://github.com/theKashey/react-imported-component, which does not use anything except Babel

@vadim-ch
Copy link
Author

vadim-ch commented Jan 5, 2024

As far as I understand, ChunkExtractor is executed during request processing in node.js. It receives loadableStats.json as chunks information. And then a ChunkExtractor instance is passed to the client components using React Context.
So. In this case, the source of truth is loadableStats.json and i can make required scripts by myself based on loadableStats.json. It seems to me that ChunkExtractor is only a helper to create script tags.
Am i wrong?

@theKashey
Copy link
Collaborator

Correct, it's only a bearer of mapping between import and chunk. This information is generated by a webpack plugin, but can be generated in any other way.

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

2 participants