-
-
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
Changes from all commits
9df3cf5
33e7ec5
6b30bf9
2e01049
8ceaca8
2fa8001
d7f30c1
acc7833
8a1dd2f
bf350aa
73b82ab
3cef347
54df9e8
346c13d
d9699c3
eeb0c86
d736cf2
1e8def2
54285f1
1a37363
1ef4a8c
08fc9b7
6dd8f88
61bbe17
e4c237c
cb15351
0c3c9f6
4c94bc2
8c25cc7
e1d7613
250f39c
a9df88f
a6c885a
2e6b943
d3bcdf0
8dc1b84
a420f80
a8b2fcf
9e5c70a
dd97d66
cfa2c2c
e587b7b
9cf819e
6805da4
5926135
cc17c3b
c110c49
7a10003
c6d6497
391df91
db8ed3d
279d86c
4411093
5f3cb5c
5b0028d
5f308e4
6ac1e2f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,33 @@ | ||
import('./bootstrap.js'); | ||
// top level await based | ||
const promises = [] | ||
__webpack_require__.f.remotes('main',promises); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. 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 commentThe reason will be displayed to describe this comment to others. Learn more. not required if we use the AsyncBoundaryPlugin from modernjs example |
||
await Promise.all(promises); | ||
console.log(promises) | ||
const thing = await new Promise((r)=>r('test')) | ||
console.log(thing); | ||
|
||
|
||
if(globalThis.neverTrue) { | ||
// dynamic import data uri | ||
import('data:text/javascript,export default 42'); | ||
} | ||
export default {} | ||
|
||
|
||
// promise based | ||
|
||
|
||
// const promises = [] | ||
// __webpack_require__.f.remotes('main',promises); | ||
|
||
// const exportedModule = Promise.all(promises).then(()=>{ | ||
// // can also be | ||
// // return require('./bootstrap') | ||
// return import(/* webpackMode: "eager" */'./bootstrap'); | ||
// }) | ||
// import(/* webpackMode: "eager" */'./bootstrap'); | ||
// if(globalThis.neverTrue) { | ||
// // dynamic import data uri | ||
// import('data:text/javascript,export default 42'); | ||
// } | ||
// export default exportedModule |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7578,7 +7578,7 @@ | |
"@module-federation/utilities" "^1.3.0" | ||
node-fetch "^2.6.0" | ||
|
||
"@module-federation/[email protected]": | ||
"@module-federation/[email protected]", "@module-federation/enhanced@^0.1.0": | ||
version "0.1.0" | ||
resolved "https://registry.yarnpkg.com/@module-federation/enhanced/-/enhanced-0.1.0.tgz#65d855e941c473e4f0cd12cc1c069ae9c8fdc6f3" | ||
integrity sha512-CymUY20htVd55Ff0G8tNeh1q3at/6xRa26Db8KcO1537aV41CFC5qRcTWd58EG9pgJhu9psyJPVaAjFXliB66g== | ||
|
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)