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

SSR Loadable example #19

Closed
wants to merge 122 commits into from

Conversation

7rulnik
Copy link
Contributor

@7rulnik 7rulnik commented May 4, 2020

I tried to lunch it but no luck.

With target async-node I'm getting TypeError: Cannot read property 'call' of undefined on the server side. But node it works.

There are some problems with rehydration, but I believe it's because of wrong stats.
I think it's a good idea to try async-node in a different project without module federation.

UPD: changed target to async-node in this example https://github.com/gregberge/loadable-components/tree/master/examples/server-side-rendering and everything is alright.

mizx and others added 30 commits March 5, 2020 20:02
* feat: implementation of server-side rendering

* docs: update README.md
# Conflicts:
#	comprehensive-demo/app-01/package.json
#	comprehensive-demo/app-01/public/index.html
#	comprehensive-demo/app-01/src/bootstrap.jsx
#	comprehensive-demo/app-01/src/index.jsx
#	comprehensive-demo/app-02/package.json
#	comprehensive-demo/app-02/src/bootstrap.jsx
#	comprehensive-demo/app-02/src/index.js
#	comprehensive-demo/app-03/webpack.config.js
@7rulnik
Copy link
Contributor Author

7rulnik commented May 11, 2020

Yep, the remote is here. It works with bootstrap import in the host and normal entry in remote so I will leave it like that. Why is it good to use bootstrap though?

With this setup I'm getting 2 chunks via jsonp:

image

197 contains website1/src/bootstrap.js
522 contains website2/src/components/SomeComponent.js

So they are necessary parts. Main question: how to predict that these chunks will be needed on client?

Loadable uses namedChunkGroups and assets from stats. This is stats file for website1 (see comment):

"namedChunkGroups": {
    "main": {
      "name": "main",
      "chunks": [
        179
      ],
      "assets": [
        "main.1d6d0191b0eb01a2689e.js"
        /* I belive there should be 197.dd5598a4dea5d61081a6.js*/
      ],
      "auxiliaryAssets": [
        "main.1d6d0191b0eb01a2689e.js.map"
      ],
      "children": {},
      "childAssets": {},
      "isOverSizeLimit": false
    },
    "Async": {
      "name": "Async",
      "chunks": [
        648
      ],
      "assets": [
        "Async.708b8060e1f55bbe4db0.js"
      ],
      "auxiliaryAssets": [
        "Async.708b8060e1f55bbe4db0.js.map"
      ],
      "children": {},
      "childAssets": {},
      "isOverSizeLimit": false
    }
  }

@ScriptedAlchemy
Copy link
Member

You’d need to federate the loadable stats as well so the host is aware

@7rulnik
Copy link
Contributor Author

7rulnik commented May 12, 2020

@ScriptedAlchemy
Copy link
Member

I’ll take a look :)

@7rulnik
Copy link
Contributor Author

7rulnik commented May 16, 2020

BTW I figured out why async-node breaks with loadable components. It works with chunks in sync way.
https://github.com/gregberge/loadable-components/blob/338bf555adc68986b12c8dd4e304875425119ca2/packages/component/src/createLoadable.js#L75

@theKashey any ideas about how we can solve it?

@theKashey
Copy link
Contributor

Hey guys, long time no see 😁
This - gregberge/loadable-components#568 - might help with the problem. @7rulnik - could you please try it.

Meanwhile - loadable overrides webpack's jsonp_callback for living, and is it working for already bundled remote as well?

@7rulnik
Copy link
Contributor Author

7rulnik commented May 17, 2020

@theKashey I tried but got the same error.
jsonp_callback works fine, yes.

I want to check the example in loadable repo. Maybe I was wrong and the problem exists there too.

@7rulnik
Copy link
Contributor Author

7rulnik commented May 17, 2020

I can confirm that example in loadable repo fails too. I believe it's better to track in loadable repo so I will file the issue and will add the example

Copy link

@dylanjeffers dylanjeffers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks awesome. Question on the merged stats file. It seems like website1 is referencing website2's stats directly from source, is that correct?

@7rulnik
Copy link
Contributor Author

7rulnik commented May 18, 2020

@SapienTech you can import/fetch it from any source, for example from S3

@prateekr1
Copy link

@7rulnik there is already a issue filed in loadable repo for this issue

gregberge/loadable-components#558

I can confirm that example in loadable repo fails too. I believe it's better to track in loadable repo so I will file the issue and will add the example

👍

@theKashey
Copy link
Contributor

server-side-rendering? It fails due to moment-js "default export" transformation, which is a bit different case.

@7rulnik
Copy link
Contributor Author

7rulnik commented May 18, 2020

@theKashey I tried without moment too. Same error.

@theKashey
Copy link
Contributor

Ok, but we are talking about the same example. I was running it with changes in the PR I've mentioned above just a few days ago, and it was working (except loadable.lib).

@prateekr1
Copy link

@7rulnik

I can confirm that example in loadable repo fails too. I believe it's better to track in loadable repo so I will file the issue and will add the example

can you specify steps to reproduce it in example of loadable repo.

@7rulnik
Copy link
Contributor Author

7rulnik commented May 24, 2020

I created PR with repro failing with async-node target so let's track this problem in loadable-components repo.

gregberge/loadable-components#575

@theKashey
Copy link
Contributor

@7rulnik - I'll borrow your example for imported-component as well.

@ScriptedAlchemy
Copy link
Member

Async node uses fs+vm vs node which uses require

@7rulnik
Copy link
Contributor Author

7rulnik commented Jun 24, 2020

@ScriptedAlchemy so we need these assets in webpack stats or in separate federation stats. I want to contribute it, but maybe you could point me where I should start?

@theKashey
Copy link
Contributor

@7rulnik - please check this PR - gregberge/loadable-components#573 - might be it changes something in a way you need it.

@7rulnik
Copy link
Contributor Author

7rulnik commented Jun 25, 2020

Why did you close it? @ScriptedAlchemy

@ScriptedAlchemy
Copy link
Member

Rewrite git history

@ScriptedAlchemy
Copy link
Member

can you branch off master, then merge this back into a new branch that's fresh from baster

newvladimirov pushed a commit to newvladimirov/module-federation-examples that referenced this pull request Jul 17, 2020
* feat: use mock s3 to stream federated code

* refactor: use SSR demo as base app
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

Successfully merging this pull request may close these issues.

None yet

9 participants