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

Support for multiple loadable components on same page #311

Closed
debugpai opened this issue Apr 17, 2019 · 2 comments · Fixed by #317
Closed

Support for multiple loadable components on same page #311

debugpai opened this issue Apr 17, 2019 · 2 comments · Fixed by #317

Comments

@debugpai
Copy link
Contributor

Hello everyone,
First of all I would like to thank you for such a great library.

We have a requirement where we would like to build a component service. The user can make a request for a particular component and the server returns the html and assets required to render it.

In the server we run extractor.collectChunks and return the things needed for a particular component. I wanted to know if we can have multiple chunks collected in this way from the same server be used on the client. Some problems that I am anticipating:

  • extractor.getScriptTags() returns a script tag with id="__LOADABLE_REQUIRED_CHUNKS__. This looks like it won't scale for multiple components on the same page
  • In @loadable/component we have this code which checks if that script tag is loaded before hydrating the component

I wanted to know if my assumptions are right that multiple components on same page are not supported by loadable. If yes then I wanted to know if you would be interesting in including this feature in loadable. I would be willing to help implement this feature in that case (with some guidance of course).

@gregberge
Copy link
Owner

Hello @debugpai, by multiple components you mean multiple React applications on the same page? If you are talking about that that, yes I think it is not supported right now. You could probably do it by yourself but you have to use internal methods for that and don't use the webpack plugin. See https://github.com/smooth-code/loadable-components/blob/master/packages/server/src/ChunkExtractor.js#L318.

We could add support for that in the core of Loadable Components, but for now, you should try to implement it by yourself, test it and then submit a PR.

Thanks!

@debugpai
Copy link
Contributor Author

Hey @neoziro. I have created a PR #317 to add support for multiple react applications. Please go through it and tell me if it needs any further changes.

gregberge pushed a commit that referenced this issue Apr 23, 2019
fivethreeo pushed a commit to fivethreeo/loadable-components that referenced this issue Nov 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants