Skip to content

How to serve output of flutter build web --wasm. #158571

@ebala96

Description

@ebala96

Steps to reproduce

I am taking a wasm build of my application by running flutter build web --wasm and trying to serve this using my dart server.
Since this creates dual-compatible output for both dart2js and wasm, it picks the js bundle by default.

I also tried the following config in my index.html file.
config : {"compileTarget":"dart2wasm","renderer":"skwasm","mainWasmPath":"main.dart.wasm","jsSupportRuntimePath":"main.dart.mjs"} inside _flutter.loader.load

This throws an error FlutterLoader could not find a build compatible with configuration and environment.

Actual results

Looking for a way to set the config to pick wasm file when I serve the output of flutter build web --wasm.

Flutter Doctor output

Doctor output
[✓] Flutter (Channel stable, 3.24.4, on Ubuntu 22.04.5 LTS 5.15.0-117-generic, locale en_US.UTF-8)
    • Flutter version 3.24.4 on channel stable at /usr/local/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 603104015d (3 weeks ago), 2024-10-24 08:01:25 -0700
    • Engine revision db49896cf2
    • Dart version 3.5.4
    • DevTools version 2.37.3

[✗] Android toolchain - develop for Android devices
    ✗ Unable to locate Android SDK.
      Install Android Studio from: https://developer.android.com/studio/index.html
      On first launch it will assist you in installing the Android SDK components.
      (or visit https://flutter.dev/to/linux-android-setup for detailed instructions).
      If the Android SDK has been installed to a custom location, please use
      `flutter config --android-sdk` to update to that location.


[✓] Chrome - develop for the web
    • CHROME_EXECUTABLE = /chrome

[✓] Linux toolchain - develop for Linux desktop
    • Ubuntu clang version 14.0.0-1ubuntu1.1
    • cmake version 3.22.1
    • ninja version 1.10.1
    • pkg-config version 0.29.2

[!] Android Studio (not installed)
    • Android Studio not found; download from https://developer.android.com/studio/index.html
      (or visit https://flutter.dev/to/linux-android-setup for detailed instructions).

[✓] Connected device (2 available)
    • Linux (desktop) • linux  • linux-x64      • Ubuntu 22.04.5 LTS 5.15.0-117-generic
    • Chrome (web)    • chrome • web-javascript • Chromium 122.0.6177.0

[✓] Network resources
    • All expected network resources are available.

! Doctor found issues in 2 categories.

Metadata

Metadata

Assignees

No one assigned

    Labels

    in triagePresently being triaged by the triage teamwaiting for customer responseThe Flutter team cannot make further progress on this issue until the original reporter responds

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions