Skip to content

Add dart2wasm --dry-run option #60050

Open
@yjbanov

Description

@yjbanov

Because we see clear performance benefits across nearly every kind of Flutter Web app, let's encourage the ecosystem towards WebAssembly. One way to do this is by analyzing the Dart code that's compiled into the app, and reporting incompatibilities with WebAssembly.

Proposal

Add a new --dry-run option to dart2wasm. When specified, the compiler runs just enough of its pipeline to tell if it's able to compile the code cleanly.

If the code is compiled cleanly, the compiler exits with no output and exit code 0.

If the code fails to compile, the compiler exits with exit code 1 and output a report to stdout explaining where the incompatibilities are.

To maximize the benefit of the report, it should be:

  • Easily human-readable. Let's keep the level of detail in the report itself low.
    • If more detail is useful, let's assign a unique code to each kind of incompatibility and have the CLI tool link to website docs.
  • Incompatibilities in the app code should be grouped together and easy to find in the code.
  • Incompatibilities in packages should be grouped by package, so it's easy to copy & paste the list of incompatibilities from the report into a GitHub issue.

Sample report:

Found incompatibilities with WebAssembly.

Incompatibilities in the application:

lib/main.dart 2:1 - 'dart:html' unsupported (error 1234)
lib/src/foo.dart 3:1 - 'dart:js' unsupported (error 2345)

Incompatibilities in 'package:foo':

package:foo/src/bar.dart 23:45 - 'package:js' unsupported (error 3456)
package:foo/src/baz.dart 67:89 - 'package:js_util' unsupported (error 4567)

Incompatibilities in 'package:qux':

package:qux/src/bar.dart 23:45 - 'package:js' unsupported (error 3456)
package:qux/src/baz.dart 67:89 - 'package:js_util' unsupported (error 4567)

The Flutter CLI tool can enhance this report further by turning error codes into links.

Metadata

Metadata

Assignees

Labels

area-dart2wasmIssues for the dart2wasm compiler.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions