pkg/dart2wasm/docs/standalone.md
By default, dart2wasm generates WebAssembly modules meant to run on platforms
with JavaScript support (mainly, browsers).
Both the SDK and application code can rely on dart:js_interop libraries to
access external JavaScript APIs.
For WebAssembly targets without a JavaScript engine (like wasmtime or similar
runtimes), dart2wasm supports a standalone target too. This target is enabled
with the --standalone compiler flag, and makes dart:js_interop unavailable.
Even in standalone mode, the SDK needs host imports for functionality like
timers, stack traces, regular expressions, dart:math or number formatting.
These imports are referenced in this file.
Note that these imports are not stable, and might change in future Dart
versions.
Additional definitions can be imported via imports and exports.
There are two plausible ways to run standalone modules:
dart2WasmStandaloneHtml in pkg/test_runner/lib/src/browser.dart)
might help as a starting point.wasm-merge from Binaryen to link two modules into a module with fewer
or no dependencies. Implementing Dart imports by delegating to WASI
definitions would allow running these modules without custom native imports,
for example.Examples for both options are discussed in the tracking issue.