dart-lang / build

A build system for Dart written in Dart
https://pub.dev/packages/build
BSD 3-Clause "New" or "Revised" License
791 stars 211 forks source link

[build_web_compilers] wasm compilation bug with non-root entrypoint #3751

Closed schultek closed 2 months ago

schultek commented 2 months ago

Description

Having a Dart web project with an entrypoint that is in a subfolder (e.g. '/web/app/main.dart') instead of the root ('/web/main.dart') fails with the new wasm compiler.

The issue is that the main.dart.js always fetches the .wasm file as if it would exist in the root:

Bildschirmfoto 2024-09-14 um 14 06 13

Which results in:

Bildschirmfoto 2024-09-14 um 14 07 04

Steps to reproduce

  1. Create new web project with dart create -t web test
  2. Update depencency to build_web_compilers: ^4.1.0-beta.0
  3. Add build.yaml with
    global_options:
    build_web_compilers:entrypoint:
    options:
      compiler: dart2wasm
  4. Move web/main.dart to web/app/main.dart and adjust the script path in index.html accordingly
  5. Run dart run build_runner serve and open localhost:8080

Context:

Tagging:

@kevmoo since this could also be a general wasm compilation issue @simolus3 since you worked on this