From 7eb3087c174eb4c7bdde3be21175203bc9656f2c Mon Sep 17 00:00:00 2001 From: Jacob MacDonald Date: Tue, 2 Aug 2022 13:53:34 -0700 Subject: [PATCH] Use a standalone process to compile DDC dart_sdk.js files (#3348) Fixes #3332 --- .../test/disable_sound_null_safety_test.dart | 1 - .../test/null_assertions_test.dart | 1 - _test_null_safety/test/opted_out_test.dart | 1 - build_web_compilers/CHANGELOG.md | 4 ++++ .../lib/src/sdk_js_compile_builder.dart | 20 ++++++++----------- build_web_compilers/pubspec.yaml | 2 +- 6 files changed, 13 insertions(+), 16 deletions(-) diff --git a/_test_null_safety/test/disable_sound_null_safety_test.dart b/_test_null_safety/test/disable_sound_null_safety_test.dart index de6a149d2..f9c00c5b6 100644 --- a/_test_null_safety/test/disable_sound_null_safety_test.dart +++ b/_test_null_safety/test/disable_sound_null_safety_test.dart @@ -4,7 +4,6 @@ // Disabling sound null safety is only supported on the web right now. @TestOn('browser') -@Skip('https://github.com/dart-lang/build/issues/3332') import 'package:test/test.dart'; const weakMode = [] is List; diff --git a/_test_null_safety/test/null_assertions_test.dart b/_test_null_safety/test/null_assertions_test.dart index 14a3e27d7..f5781ed90 100644 --- a/_test_null_safety/test/null_assertions_test.dart +++ b/_test_null_safety/test/null_assertions_test.dart @@ -6,7 +6,6 @@ // @dart=2.9 // Null assertions are only supported on the web right now. -@Skip('https://github.com/dart-lang/build/issues/3332') @TestOn('browser') import 'package:test/test.dart'; diff --git a/_test_null_safety/test/opted_out_test.dart b/_test_null_safety/test/opted_out_test.dart index dfee3fce4..d173f9bf1 100644 --- a/_test_null_safety/test/opted_out_test.dart +++ b/_test_null_safety/test/opted_out_test.dart @@ -3,7 +3,6 @@ // BSD-style license that can be found in the LICENSE file. // // @dart=2.7 -@Skip('https://github.com/dart-lang/build/issues/3332') import 'package:test/test.dart'; import 'common/message.dart'; diff --git a/build_web_compilers/CHANGELOG.md b/build_web_compilers/CHANGELOG.md index 7963142ec..2b22c21ad 100644 --- a/build_web_compilers/CHANGELOG.md +++ b/build_web_compilers/CHANGELOG.md @@ -1,3 +1,7 @@ +## 3.2.5 + +- Use a standalone process to compile the ddc sdk.js file. + ## 3.2.4 - Use `dart compile js` instead of running dart2js from its sdk snapshot. diff --git a/build_web_compilers/lib/src/sdk_js_compile_builder.dart b/build_web_compilers/lib/src/sdk_js_compile_builder.dart index 89c315f01..125ff89ce 100644 --- a/build_web_compilers/lib/src/sdk_js_compile_builder.dart +++ b/build_web_compilers/lib/src/sdk_js_compile_builder.dart @@ -82,8 +82,12 @@ Future _createDevCompilerModule( var scratchSpace = await buildStep.fetchResource(scratchSpaceResource); var jsOutputFile = scratchSpace.fileFor(jsOutputId); - var request = WorkRequest() - ..arguments.addAll([ + ProcessResult result; + try { + // Use standalone process instead of the worker due to + // https://github.com/dart-lang/sdk/issues/49441 + result = await Process.run(p.join(sdkDir, 'bin', 'dart'), [ + p.join(sdkDir, 'bin', 'snapshots', 'dartdevc.dart.snapshot'), '--multi-root-scheme=org-dartlang-sdk', '--modules=amd', '--module-name=dart_sdk', @@ -92,22 +96,14 @@ Future _createDevCompilerModule( jsOutputFile.path, p.url.join(dartSdk, sdkKernelPath), ]); - - var driverResource = dartdevkDriverResource; - var driver = await buildStep.fetchResource(driverResource); - WorkResponse response; - try { - response = await driver.doWork(request, - trackWork: (response) => - buildStep.trackStage('Compile', () => response, isExternal: true)); } catch (e) { throw DartDevcCompilationException(jsOutputId, e.toString()); } - var message = response.output + var message = '${result.stdout}${result.stderr}' .replaceAll('${scratchSpace.tempDir.path}/', '') .replaceAll('org-dartlang-sdk:///', ''); - if (response.exitCode != EXIT_CODE_OK || + if (result.exitCode != EXIT_CODE_OK || !jsOutputFile.existsSync() || message.contains('Error:')) { throw DartDevcCompilationException(jsOutputId, message); diff --git a/build_web_compilers/pubspec.yaml b/build_web_compilers/pubspec.yaml index 8f43622f1..356716ac5 100644 --- a/build_web_compilers/pubspec.yaml +++ b/build_web_compilers/pubspec.yaml @@ -1,5 +1,5 @@ name: build_web_compilers -version: 3.2.4 +version: 3.2.5 description: Builder implementations wrapping Dart compilers. repository: https://github.com/dart-lang/build/tree/master/build_web_compilers