Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Sign upTop-level-await, new WASM modules and async modules based on import await and import async #9177
Conversation
This comment has been minimized.
This comment has been minimized.
For maintainers only:
|
This comment has been minimized.
This comment has been minimized.
So I added WASM-ESM-integration based on WASM being async modules according to the proposal here: https://github.com/WebAssembly/esm-integration/tree/master/proposals/esm-integration Here are a few examples:
There are a few functional changes compared to the old wasm implementation:
Implementation-wise:
A note on wasm-bindgen: It will break for two reasons:
|
This comment has been minimized.
This comment has been minimized.
Wow @sokra that's an awesome update! Thanks for the work. From a Wasm viewpoint it's mostly lgtm, apart from:
This should still be disallowed, as it will throw when called from JS. A proposal exists already for that: https://github.com/WebAssembly/JS-BigInt-integration. Do you think this can still land this week? |
This comment has been minimized.
This comment has been minimized.
Before this change we throw a build error when using i64-signatures, but as this will be soonish supported, I feel a build error is to much. Using an i64-signature might not even be an error, as somebody could have a browser with BigInt support. |
This comment has been minimized.
This comment has been minimized.
Not sure. I actually wait for some feedback from @littledan about the Unrelated from this: I want to move this and other things behind experiments: {
mjs: true,
topLevelAwait: true,
asyncWasm: true,
// ...
} |
This comment has been minimized.
This comment has been minimized.
Opt in sounds important to do before landing this. I am excited to see the Webpack leading with experimentation here. However, the current TC39 proposal is based on |
This comment has been minimized.
This comment has been minimized.
I could also implement this, but it's a bit more involved since the async-or-not status of a module no longer only depends on itself, but on all dependencies too. So async status need to be inferred in a separate step after building the module graph. (That's also what I'm criticizing on the proposal. This is confusing for the developer too) |
This comment has been minimized.
This comment has been minimized.
That's very true, I agree.
Would that allow Webpack to iterate faster, aka break code? |
This comment has been minimized.
This comment has been minimized.
I would use relaxed SemVer for |
…p-level-await
This comment has been minimized.
This comment has been minimized.
MylesBorins
commented
Jun 5, 2019
Hey All, We put together a small doc as an explainer for why the champions of Thank you for thanking the time to work on this alternative approach, it really helped us improve the algorithm for https://gist.github.com/MylesBorins/ae97abab4a4144411c12240bb09dc7dd How the current specification works
Concerns with
|
This comment has been minimized.
This comment has been minimized.
@MylesBorins Here is my answer to this: https://gist.github.com/sokra/34d2afe7555eb9a687e2c7566e9a9646 I'm currently in progress of implementing the original top-level-await proposal in this PR in addition to I'm currently pushing towards One thing I have a bit trouble with is understanding the exact behavior of async cycles. I would love to hear some plaintext explanation about that. |
This comment has been minimized.
This comment has been minimized.
To clarify, cycles of modules which have static |
This comment has been minimized.
This comment has been minimized.
// entry.js
import x from "a";
import y from "b";
console.log(x);
console.log(y);
// a.js
import { hello, world } from "b";
export default hello + world;
await 1;
export function f() {
return "hello";
}
// b.js
import value, { f } from "a";
export const hello = f();
await 1;
export const world = "world";
export default (() => { try { value } catch(e) { return e; } })(); So am I correct that this example prints:
|
This comment has been minimized.
This comment has been minimized.
So both proposals are now supported on opt-in:
|
This comment has been minimized.
This comment has been minimized.
Thank you for your pull request! The most important CI builds succeeded, we’ll review the pull request soon. |
a71342b
into
next
This comment has been minimized.
This comment has been minimized.
So this landed in 5.0.0-alpha.15 |
sokra commentedMay 22, 2019
•
edited
import await
supportimport
async supportexports await from
supportexports from
async supportsee example: https://github.com/webpack/webpack/tree/feature/top-level-await/examples/top-level-await
cc @littledan @jhnns @lukastaegert @TheLarkInn
based on https://gist.github.com/sokra/33f3db1b2714e9a6720f890842c47ae6
What kind of change does this PR introduce?
feature
Did you add tests for your changes?
yes
Does this PR introduce a breaking change?
yes, wasm is now opt-in by default
What needs to be documented once your changes are merged?
New experiments:
experiments.importAwait
->import/export await
is enabledexperiments.importAsync
->import/export
allows to use async module tooexperiments.topLevelAwait
-> allows to useawait
on top-levelexperiments.asyncWebAssembly
-> WebAssembly Modules are async modulesexperiments.syncWebAssembly
-> The webpack 4 WebAssembly Modules implementation (outdated)