Skip to content

Commit ae83526

Browse files
authored
Fixing dart2js sourcemaps not being written when both dart2js and wasm are enabled (#4265)
Fixes #4230
1 parent 7cf516e commit ae83526

File tree

5 files changed

+19
-2
lines changed

5 files changed

+19
-2
lines changed

build_web_compilers/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
## 4.3.1
2+
- Fix Dart2JS sourcemaps not being written when both wasm and js are enabled.
3+
14
## 4.3.0
25

36
- When both wasm and js builds are enabled you can now add force_js=true

build_web_compilers/lib/src/dart2js_bootstrap.dart

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,20 @@ import 'platforms.dart';
2020
import 'web_entrypoint_builder.dart';
2121

2222
/// Compiles an the primary input of [buildStep] with dart2js.
23+
///
24+
/// [onlyCompiler] indicates that Dart2JS is the only compiler enabled.
2325
Future<void> bootstrapDart2Js(
2426
BuildStep buildStep,
2527
List<String> dart2JsArgs, {
2628
required bool? nativeNullAssertions,
29+
required bool onlyCompiler,
2730
String entrypointExtension = jsEntrypointExtension,
2831
}) => _resourcePool.withResource(
2932
() => _bootstrapDart2Js(
3033
buildStep,
3134
dart2JsArgs,
3235
nativeNullAssertions: nativeNullAssertions,
36+
onlyCompiler: onlyCompiler,
3337
entrypointExtension: entrypointExtension,
3438
),
3539
);
@@ -38,6 +42,7 @@ Future<void> _bootstrapDart2Js(
3842
BuildStep buildStep,
3943
List<String> dart2JsArgs, {
4044
required bool? nativeNullAssertions,
45+
required bool onlyCompiler,
4146
required String entrypointExtension,
4247
}) async {
4348
final dartEntrypointId = buildStep.inputId;
@@ -155,7 +160,11 @@ $librariesString
155160
// these as part of the archive because they already have asset nodes.
156161
await scratchSpace.copyOutput(jsOutputId, buildStep);
157162
await fixAndCopySourceMap(
158-
dartEntrypointId.changeExtension(jsEntrypointSourceMapExtension),
163+
dartEntrypointId.changeExtension(
164+
onlyCompiler
165+
? jsEntrypointSourceMapExtension
166+
: dart2jsEntrypointSourceMapExtension,
167+
),
159168
scratchSpace,
160169
buildStep,
161170
);

build_web_compilers/lib/src/web_entrypoint_builder.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ const wasmExtension = '.wasm';
2222
const wasmSourceMapExtension = '.wasm.map';
2323
const moduleJsExtension = '.mjs';
2424
const jsEntrypointSourceMapExtension = '.dart.js.map';
25+
const dart2jsEntrypointSourceMapExtension = '.dart2js.js.map';
2526
const jsEntrypointArchiveExtension = '.dart.js.tar.gz';
2627
const digestsEntrypointExtension = '.digests';
2728
const mergedMetadataExtension = '.dart.ddc_merged_metadata';
@@ -256,6 +257,7 @@ final class EntrypointBuilderOptions {
256257
if (optionsFor(WebCompiler.Dart2Js) case final dart2js?) ...[
257258
dart2js.extension,
258259
jsEntrypointSourceMapExtension,
260+
dart2jsEntrypointSourceMapExtension,
259261
jsEntrypointArchiveExtension,
260262
],
261263
if (optionsFor(WebCompiler.Dart2Wasm) case final dart2wasm?) ...[
@@ -331,6 +333,7 @@ class WebEntrypointBuilder implements Builder {
331333
buildStep,
332334
compiler.compilerArguments,
333335
nativeNullAssertions: options.nativeNullAssertions,
336+
onlyCompiler: options.compilers.length == 1,
334337
entrypointExtension: compiler.extension,
335338
),
336339
);

build_web_compilers/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: build_web_compilers
2-
version: 4.3.0
2+
version: 4.3.1
33
description: Builder implementations wrapping the dart2js and DDC compilers.
44
repository: https://github.com/dart-lang/build/tree/master/build_web_compilers
55
resolution: workspace

build_web_compilers/test/dart2wasm_bootstrap_test.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ void main() {
9191
),
9292
'a|web/index.dart.js.tar.gz': isNotNull,
9393
'a|web/index.dart2js.js': decodedMatches(contains('Hello world!')),
94+
'a|web/index.dart2js.js.map': isNotNull,
9495
'a|web/index.mjs': isNotNull,
9596
'a|web/index.wasm.map': isNotNull,
9697
'a|web/index.wasm': isNotNull,
@@ -108,6 +109,7 @@ void main() {
108109
final expectedOutputs = Map.of(startingExpectedOutputs)..addAll({
109110
'a|web/index.dart.js.tar.gz': isNotNull,
110111
'a|web/index.dart2js.js': decodedMatches(contains('Hello world!')),
112+
'a|web/index.dart2js.js.map': isNotNull,
111113
'a|web/index.mjs': isNotNull,
112114
'a|web/index.wasm.map': isNotNull,
113115
'a|web/index.wasm': isNotNull,

0 commit comments

Comments
 (0)