Skip to content

[build_web_compilers] Not Emitting JS Map File #4230

@tyllark

Description

@tyllark

The Dart SDK Version (dart --version)
Dart SDK version: 3.9.2 (stable) (Wed Aug 27 03:49:40 2025 -0700)

What package(s) from this repo you are using, and the version (i.e. build_runner 0.7.12)
build_web_compilers 4.2.4

What builder(s) you are using (or writing yourself). Try to give a short summary of what they do.
I have a "copy" builder that that takes the emitted files from build_web_compilers and copies them from the generated cache to my source so they can be deployed with my package.

Whether you are using Windows, MacOSX, or Linux (if applicable)
MacOSX

Whether you are using Chrome, Safari, Firefox, Edge (if applicable)
Chrome

Any other packages or constraints we should know about
No, but let me know if you need additional information

Issue Description
when using build_web_compilers for both dart2js and dart2wasm the builder Dart2JsArchiveExtractor successfully extracts the map file from the tar file to the generated cache. However the map file .dart2js.js.map does not get emitted for subsequent builders to use, which I suspect is caused by the archive file .dart.js.tar.gz having a different extension. The map file is emitted for dart2js only builds as it does not need to create the loader file with the .dart.js extension.

Locally I updated build_web_compilers to have matching extensions (.dart2js.js.tar.gz and .dart2js.js.map) and the map file was emitted properly! We should consider dynamically generating these extensions similarly to the JavaScript compiler outputs.

build.yaml

targets:
  $default:
    sources:
      exclude:
        - example/**
    builders:
      build_web_compilers:dart2js_archive_extractor:
        enabled: true
      build_web_compilers:entrypoint:
        enabled: false
  
  compile:
    auto_apply_builders: false
    builders:
      build_web_compilers:dart2js_archive_extractor:
        enabled: false
      build_web_compilers:entrypoint:
        enabled: true
        generate_for:
          - lib/src/workers/*.debug.dart
          - lib/src/workers/*.release.dart
        dev_options:
          compilers: 
            dart2js:
              args:
                - --no-minify
            dart2wasm:
              args:
                - --no-minify
        release_options:
          compilers:
            dart2js:
              args:
                - -O2
                - --define=dart.vm.product=true
            dart2wasm:
              args:
                - -O2
                - --define=dart.vm.product=true
    dependencies:
      - $default
          
  workers:
    auto_apply_builders: false
    builders:
      my_builder_package:copy_builder:
        enabled: true
        generate_for:
          - lib/src/workers/*.debug.dart.js
          - lib/src/workers/*.debug.dart2js.js
          - lib/src/workers/*.debug.dart2js.js.map ##not emitted
          - lib/src/workers/*.release.dart.js
          - lib/src/workers/*.release.dart2js.js
          - lib/src/workers/*.release.dart2js.js.map ##not emitted
          - lib/src/workers/*.debug.mjs
          - lib/src/workers/*.debug.wasm
          - lib/src/workers/*.debug.wasm.map
          - lib/src/workers/*.release.mjs
          - lib/src/workers/*.release.wasm
          - lib/src/workers/*.release.wasm.map
    dependencies:
      - my_package:compile

Metadata

Metadata

Assignees

No one assigned

    Labels

    type-bugIncorrect behavior (everything from a crash to more subtle misbehavior)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions