-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
ModernJS async boundary #3279
base: master
Are you sure you want to change the base?
ModernJS async boundary #3279
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Workflow status is failure ❌ |
Workflow status is failure ❌ |
@@ -1 +1,12 @@ | |||
import('./bootstrap.js'); | |||
const promises = [] | |||
__webpack_require__.f.remotes('main',promises); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hardcoded to main as proof of concept, in reality this would be part of codegen, injected into all entrypoint modules, each passing their own chunkID to the handlers.
effectively making startup asynchronous.
You can also export require(bootstrap) back out, however - the entrypoint will always export a promise. If webpack is handling this entrpoint loading, then async modules will resolve their inner promises. If not, your entrypoint will always export Promise.resolve(module.exports).
In most cases this should not be a problem, as the act of loading an entrypoint is async in ietslf so much should not experience an issue.
The other option involves replacing entrypoint startup code with a promise based export
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not required if we use the AsyncBoundaryPlugin from modernjs example
Workflow status is cancelled ❗ |
…sync-boundary # Conflicts: # basic-host-remote/app1/modern.config.js # basic-host-remote/app2/modern.config.js
Workflow status is failure ❌ |
Workflow status is failure ❌ |
Workflow status is failure ❌ |
)}, promiseTrack);`, | ||
`var __webpack_exports__ = Promise.all(promiseTrack).then(function() {`, | ||
source.source(), | ||
'return __webpack_exports__;', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
entrypoints will always return a promise to webpack, if entrypoint is externally required (like commonjs)
then it will module.exports = new Promise(moduleExports)
No description provided.