From 143c6df41b454eb0f94337f2b73862c89d5b815a Mon Sep 17 00:00:00 2001 From: Mark Zhou Date: Wed, 11 May 2022 22:31:45 +0000 Subject: [PATCH] [ddc] Stubbing package:dart2js_runtime_metrics This allows the package to be discoverable across web backends Change-Id: I7d870a7232543d3b719d47de1424017d7f578434 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/244261 Commit-Queue: Mark Zhou Reviewed-by: Nicholas Shahan --- pkg/dev_compiler/lib/src/kernel/target.dart | 4 +++- .../js_dev_runtime/private/runtime_metrics.dart | 10 ++++++++++ sdk/lib/libraries.json | 3 +++ sdk/lib/libraries.yaml | 3 +++ 4 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 sdk/lib/_internal/js_dev_runtime/private/runtime_metrics.dart diff --git a/pkg/dev_compiler/lib/src/kernel/target.dart b/pkg/dev_compiler/lib/src/kernel/target.dart index 2fb1100500d..bce2385c954 100644 --- a/pkg/dev_compiler/lib/src/kernel/target.dart +++ b/pkg/dev_compiler/lib/src/kernel/target.dart @@ -133,7 +133,9 @@ class DevCompilerTarget extends Target { @override bool allowPlatformPrivateLibraryAccess(Uri importer, Uri imported) => super.allowPlatformPrivateLibraryAccess(importer, imported) || - _allowedTestLibrary(importer); + _allowedTestLibrary(importer) || + (importer.isScheme('package') && + importer.path.startsWith('dart2js_runtime_metrics/')); @override bool get nativeExtensionExpectsString => false; diff --git a/sdk/lib/_internal/js_dev_runtime/private/runtime_metrics.dart b/sdk/lib/_internal/js_dev_runtime/private/runtime_metrics.dart new file mode 100644 index 00000000000..c4a79a0c954 --- /dev/null +++ b/sdk/lib/_internal/js_dev_runtime/private/runtime_metrics.dart @@ -0,0 +1,10 @@ +// Copyright (c) 2022, 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. + +// This file is a stub to allow dart:_dart2js_runtime_metrics to be discovered +// across web contexts. + +get runtimeMetrics => throw UnimplementedError(); + +get startupMetrics => throw UnimplementedError(); diff --git a/sdk/lib/libraries.json b/sdk/lib/libraries.json index 6c26f221cd4..b72ab821a32 100644 --- a/sdk/lib/libraries.json +++ b/sdk/lib/libraries.json @@ -433,6 +433,9 @@ "_native_typed_data": { "uri": "_internal/js_dev_runtime/private/native_typed_data.dart" }, + "_dart2js_runtime_metrics": { + "uri": "_internal/js_dev_runtime/private/runtime_metrics.dart" + }, "async": { "uri": "async/async.dart", "patches": "_internal/js_dev_runtime/patch/async_patch.dart" diff --git a/sdk/lib/libraries.yaml b/sdk/lib/libraries.yaml index 2b056323eef..92231cb4e61 100644 --- a/sdk/lib/libraries.yaml +++ b/sdk/lib/libraries.yaml @@ -399,6 +399,9 @@ dartdevc: _native_typed_data: uri: "_internal/js_dev_runtime/private/native_typed_data.dart" + _dart2js_runtime_metrics: + uri: "_internal/js_dev_runtime/private/runtime_metrics.dart" + async: uri: "async/async.dart" patches: "_internal/js_dev_runtime/patch/async_patch.dart"