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

Add example for async-node target #575

Merged
merged 1 commit into from
Oct 14, 2020

Conversation

7rulnik
Copy link
Contributor

@7rulnik 7rulnik commented May 24, 2020

Summary

Webpack 5 introduces new target async-node. It uses fs and vm to load chunks asynchronously.

More details you can find in webpack sources. Take a look on NodeTemplatePlugin and StartupChunkDependenciesPlugin.

Seems that we should wait promise from ctor.requireAsync, but for now we can't do it because it's inside of constructor. And even more: is it possible at all to wait for it without suspense on server? If it's so we just can go through namedChunkGroups from stats and call __webpack_require__.f.readFileVm or __webpack_require__.e, but not sure that it will help

Note that this branch already contains fix from #568

Test plan

  1. cd examples/server-side-rendering-async-node
  2. yarn
  3. yarn build
  4. yarn start
  5. Open page and see TypeError: e[t] is not a function in console

@7rulnik
Copy link
Contributor Author

7rulnik commented May 24, 2020

As I can see with async-node we also have the problem with mini-css-extract-plugin. It tries to load CSS in an async way, but it works only in a browser. @evilebottnawi is it a known issue? But as I understand we should not use it in server config. Right?

@theKashey theKashey self-assigned this May 24, 2020
@alexander-akait
Copy link

@7rulnik known issue

But as I understand we should not use it in server config. Right?

You can use it 😄

@theKashey
Copy link
Collaborator

Look like async node will not be able to work for now.

As long as we need everything to be resolved before render, and solution before was bound to the ability to resolve all we need during the render - that's not gonna work anymore.
So the only way forward node-async is calling all possible imports and awaiting for them.

That has two problems:

  • is there any reason to use node-async and EVERYTHING would be resolved in any way?
  • with full dynamic import it's not always known what you might import - that information is not exposed, however known for babel plugin.

So, question - what is the reason to use node-async?

@7rulnik
Copy link
Contributor Author

7rulnik commented Jun 7, 2020

Not sure, but maybe module federations is the reason for it? As for now, we have the issue module-federation/module-federation-examples#48 so we need restart server to fetch new modules. Not sure that node-async with some enhancement will help there. Maybe @ScriptedAlchemy have some thoughts?

@stale
Copy link

stale bot commented Aug 6, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Aug 6, 2020
@theKashey
Copy link
Collaborator

Not stale

@stale
Copy link

stale bot commented Oct 6, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Oct 6, 2020
@stale stale bot closed this Oct 13, 2020
@theKashey theKashey reopened this Oct 14, 2020
@stale stale bot removed the wontfix label Oct 14, 2020
@theKashey theKashey changed the base branch from async-558 to master October 14, 2020 00:59
@theKashey theKashey marked this pull request as ready for review October 14, 2020 00:59
@theKashey
Copy link
Collaborator

I am adding webpack5 related examples and gonna build a few integation tests on top of them.
Let's start with this one.

@theKashey theKashey merged commit 63fd151 into gregberge:master Oct 14, 2020
@ScriptedAlchemy
Copy link

Omg yay!

@ScriptedAlchemy
Copy link

Once you have this running again. I'll extend the MF api so we can pass chunks along with the remote for cross container lookups. We would need to be able to merge additional context into your chunk extractor, from the remotes build stats. Then I'll have the container expose get, init, and chunkMap.

@7rulnik 7rulnik deleted the webpack-async-node branch October 14, 2020 08:19
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.

4 participants