Skip to content

Dynamic imports and SSR #46

@cbilotta

Description

@cbilotta

With the 1.5 Meteor update, we will be able to split code dynamically.
We can use react-loadable to load components on-demand.

However, how would we go about sending the needed , dynamically imported components on SSR ?

The server will synchronously import components and render the complete HTML correctly.

Once sent to the client, the javascript will mount, provoking a re-render. Since the client doesn't have the components that were loaded synchronously by the server, it will fall into the "component is not loaded" case and display the loading indicator for the component, after the user has already seen this component properly rendered.

How can we avoid this ? I guess the solution is obviously to simply put the required modules for the page in the head, but how do we go about doing that ?

Do we have a way to serve the compiled modules via webhooks ?

Maybe MDG already though of this, but I couldn't find any information, except this interesting conversation with Ben : https://medium.com/@faceyspacey/u-shouldnt-see-loading-briefly-3289d1b3d4ce

In the meantime, we can probably apply the mecanism from #47 to solve this issue.

We would basically prevent re-rendering of the component that needs a dynamically imported module until meteor has properly fetched this module.

Also see : https://github.com/thejameskyle/react-loadable/blob/master/README.md#flushserversiderequirepaths--flushwebpackrequireweakids

However, this would need to be implemented by Meteor itself (at least a hook or something) and I have no idea if that is done, or is planned.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions