Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions dwds/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## 27.2.0-wip

- Add `deprecatedJsInterop` to `BuildSettings` and `CompilerOptions`. When it
is set, the expression compiler worker is started with
`--[no-]deprecated-js-interop`. This requires a Dart SDK that supports the
flag.

## 27.1.4

- Fix duplicated browser tabs taking over the original tab's DWDS connection.
Expand Down
7 changes: 7 additions & 0 deletions dwds/lib/src/loaders/strategy.dart
Original file line number Diff line number Diff line change
Expand Up @@ -236,10 +236,17 @@ class BuildSettings {
final bool isFlutterApp;
final List<String> experiments;

/// Whether the compilers allow the deprecated JS interop libraries, such as
/// `dart:html`.
///
/// If `null`, no flag is passed and the compiler default is used.
final bool? deprecatedJsInterop;

const BuildSettings({
this.appEntrypoint,
this.canaryFeatures = false,
this.isFlutterApp = true,
this.experiments = const <String>[],
this.deprecatedJsInterop,
});
}
8 changes: 4 additions & 4 deletions dwds/lib/src/services/chrome/chrome_proxy_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -186,15 +186,15 @@ final class ChromeProxyService extends ProxyService<ChromeAppInspector> {
Future<void> _updateCompilerDependencies(String entrypoint) async {
final loadStrategy = globalToolConfiguration.loadStrategy;
final moduleFormat = loadStrategy.moduleFormat;
final canaryFeatures = loadStrategy.buildSettings.canaryFeatures;
final experiments = loadStrategy.buildSettings.experiments;
final buildSettings = loadStrategy.buildSettings;

_logger.info('Initializing expression compiler for $entrypoint');

final compilerOptions = CompilerOptions(
moduleFormat: ModuleFormat.values.byName(moduleFormat),
canaryFeatures: canaryFeatures,
experiments: experiments,
canaryFeatures: buildSettings.canaryFeatures,
experiments: buildSettings.experiments,
deprecatedJsInterop: buildSettings.deprecatedJsInterop,
);

final compiler = _compiler;
Expand Down
7 changes: 7 additions & 0 deletions dwds/lib/src/services/expression_compiler.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,17 @@ class CompilerOptions {
final bool canaryFeatures;
final List<String> experiments;

/// Whether the compiler allows the deprecated JS interop libraries, such as
/// `dart:html`.
///
/// If `null`, no flag is passed and the compiler default is used.
final bool? deprecatedJsInterop;

CompilerOptions({
required this.moduleFormat,
required this.canaryFeatures,
required this.experiments,
this.deprecatedJsInterop,
});
}

Expand Down
57 changes: 42 additions & 15 deletions dwds/lib/src/services/expression_compiler_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,41 @@ import 'package:async/async.dart';
import 'package:dwds/src/services/expression_compiler.dart';
import 'package:dwds/src/utilities/sdk_configuration.dart';
import 'package:logging/logging.dart';
import 'package:meta/meta.dart';

/// Returns the arguments for the DDC expression compiler worker.
@visibleForTesting
List<String> expressionCompilerWorkerArgs({
required Uri sdkSummaryUri,
required String address,
required int port,
required CompilerOptions compilerOptions,
required bool verbose,
}) => [
'--experimental-expression-compiler',
'--dart-sdk-summary',
'$sdkSummaryUri',
'--asset-server-address',
address,
'--asset-server-port',
'$port',
'--module-format',
compilerOptions.moduleFormat.name,
if (verbose) '--verbose',
for (final experiment in compilerOptions.experiments)
'--enable-experiment=$experiment',
if (compilerOptions.canaryFeatures) '--canary',
?_deprecatedJsInteropArg(compilerOptions.deprecatedJsInterop),
Comment thread
Markzipan marked this conversation as resolved.
];

/// The `--[no-]deprecated-js-interop` argument, or `null` to use the compiler
/// default.
String? _deprecatedJsInteropArg(bool? deprecatedJsInterop) =>
switch (deprecatedJsInterop) {
null => null,
true => '--deprecated-js-interop',
false => '--no-deprecated-js-interop',
};

class _Compiler {
static final _logger = Logger('ExpressionCompilerService');
Expand Down Expand Up @@ -67,21 +102,13 @@ class _Compiler {
final workerUri = sdkConfiguration.compilerWorkerUri!;
final sdkSummaryUri = sdkConfiguration.sdkSummaryUri!;

final args = [
'--experimental-expression-compiler',
'--dart-sdk-summary',
'$sdkSummaryUri',
'--asset-server-address',
address,
'--asset-server-port',
'$port',
'--module-format',
compilerOptions.moduleFormat.name,
if (verbose) '--verbose',
for (final experiment in compilerOptions.experiments)
'--enable-experiment=$experiment',
if (compilerOptions.canaryFeatures) '--canary',
];
final args = expressionCompilerWorkerArgs(
sdkSummaryUri: sdkSummaryUri,
address: address,
port: port,
compilerOptions: compilerOptions,
verbose: verbose,
);

_logger.info('Starting...');
_logger.finest('$workerUri ${args.join(' ')}');
Expand Down
2 changes: 1 addition & 1 deletion dwds/lib/src/version.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions dwds/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
name: dwds
# Every time this changes you need to run `dart run tool/build.dart`.
version: 27.1.4
version: 27.2.0-wip

description: >-
A service that proxies between the Chrome debug protocol and the Dart VM
service protocol.
repository: https://github.com/dart-lang/webdev/tree/main/dwds
environment:
sdk: ^3.13.0-107.0.dev
sdk: ^3.14.0-286.0.dev

dependencies:
async: ^2.9.0
Expand Down
56 changes: 56 additions & 0 deletions dwds/test/services/expression_compiler_worker_args_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
// Copyright (c) 2026, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

import 'package:dwds/src/services/expression_compiler.dart';
import 'package:dwds/src/services/expression_compiler_service.dart';
import 'package:test/test.dart';

void main() {
group('expressionCompilerWorkerArgs', () {
List<String> argsFor({bool? deprecatedJsInterop}) =>
expressionCompilerWorkerArgs(
sdkSummaryUri: Uri.file('/sdk/ddc_outline.dill'),
address: 'localhost',
port: 1234,
compilerOptions: CompilerOptions(
moduleFormat: ModuleFormat.ddc,
canaryFeatures: true,
experiments: const ['records'],
deprecatedJsInterop: deprecatedJsInterop,
),
verbose: false,
);

test('passes the compiler options', () {
expect(argsFor(), [
'--experimental-expression-compiler',
'--dart-sdk-summary',
'file:///sdk/ddc_outline.dill',
'--asset-server-address',
'localhost',
'--asset-server-port',
'1234',
'--module-format',
'ddc',
'--canary',
]);
});

test('does not pass deprecated-js-interop when not configured', () {
expect(argsFor(), isNot(contains(contains('deprecated-js-interop'))));
});

test('passes --deprecated-js-interop', () {
final args = argsFor(deprecatedJsInterop: true);
expect(args, contains('--deprecated-js-interop'));
expect(args, isNot(contains('--no-deprecated-js-interop')));
});

test('passes --no-deprecated-js-interop', () {
final args = argsFor(deprecatedJsInterop: false);
expect(args, contains('--no-deprecated-js-interop'));
expect(args, isNot(contains('--deprecated-js-interop')));
});
});
}
Loading