@@ -5,17 +5,17 @@ description: Learn how to compile your Dart web app to WebAssembly.
5
5
6
6
The Dart team is excited to add
7
7
[ WebAssembly] ( https://webassembly.org/ ) as a compilation target when building
8
- Dart and [ Flutter] ( {{site.flutter}}/wasm ) applications for the web.
8
+ Dart and [ Flutter] [ ] applications for the web.
9
9
10
10
Development of WebAssembly support remains ongoing,
11
11
which will potentially result in frequent changes.
12
12
Revisit this page for the latest updates.
13
13
14
14
::: note
15
- ** Support for Wasm is now in beta !**
15
+ ** Support for Wasm is now in stable !**
16
16
17
17
WebAssembly support for Dart web is available on the Dart
18
- * beta * and * main * [ channels ] ( /get-dart#release-channels ) .
18
+ * stable * [ channel ] ( /get-dart#release-channels ) .
19
19
:::
20
20
21
21
## WebAssembly support
@@ -37,11 +37,11 @@ restrictions:
37
37
## Compiling your web app to Wasm {:#compiling-to-wasm}
38
38
39
39
We've landed support in the ` dart ` CLI for invoking the
40
- ` dart2wasm ` compiler in the Dart and Flutter ` main ` channels :
40
+ Wasm compiler in Dart and [ Flutter] [ ] :
41
41
42
42
``` console
43
43
$ dart help compile wasm
44
- Compile Dart to a WebAssembly/WasmGC module (EXPERIMENTAL) .
44
+ Compile Dart to a WebAssembly/WasmGC module.
45
45
46
46
Usage: dart compile wasm [arguments] <dart entry point>
47
47
-h, --help Print this usage information.
@@ -54,7 +54,10 @@ Usage: dart compile wasm [arguments] <dart entry point>
54
54
For example: dart compile wasm -Da=1,b=2 main.dart
55
55
```
56
56
57
- To try Wasm today from the ` main ` channel:
57
+ Wasm compilation is available in stable, but still in preview.
58
+ While we continue optimizing tooling to improve developer experience,
59
+ you can try compiling Dart to Wasm today
60
+ by following the temporary steps outlined here:
58
61
59
62
1 . Start with a web app: ` dart create -t web mywebapp `
60
63
@@ -64,10 +67,22 @@ To try Wasm today from the `main` channel:
64
67
65
68
1 . Compile with Wasm: ` mywebapp$ dart compile wasm web/main.dart `
66
69
70
+ 1 . Create a new directory for the built web app: ` mkdir site `
71
+
72
+ 1 . Copy over Dart code: ` cp web/main.* site/ `
73
+
74
+ 1 . Copy over the web files: ` cp web/index.html web/styles.css site/ `
75
+
76
+ 1 . Create a JS bootstrap file to load the Wasm code:
77
+
78
+ Add a new file ` site/main.dart.js ` and fill it with the contents of
79
+ this [ ` main.dart.js ` sample] ( https://gist.github.com/mit-mit/0fcb1247a9444b0cadf611aa5fc6f32e ) .
80
+
67
81
1 . Serve the output: ` dart pub global run ` [ ` dhttpd ` ]
68
82
69
83
You can also check out this small example [ here] ( https://github.com/mit-mit/sandbox ) .
70
84
85
+ [ Flutter ] : {{site.flutter}}/wasm
71
86
[ `package:web` ] : {{site.pub-pkg}}/web
72
87
[ ` dart:js_interop ` ] : {{site.dart.api}}/{{site.dart.sdk.channel}}/dart-js_interop
73
88
[ migrated ] : /interop/js-interop/package-web/
0 commit comments