Skip to content

Commit d71014f

Browse files
szuendDevtools-frontend LUCI CQ
authored andcommitted
[build] Add 'devtools_foundation_module'
A 'foundation module' is a ts_library targeted to both the browser and Node.js. As such, it only supports shared EcmaScript APIs. The CL switches over the sole existing unit test running on node. Drive-by: Python treats the empty array as falsy. This CL also fixes ts_library.py to add the DOM libs only if no --es-libs argument was passed. But not if an empty array was passed explicitly. [email protected] Bug: 451502260 Change-Id: I107651c12ba2d60f6c0bd1e949d0a3572f1ccb83 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/7079170 Reviewed-by: Alex Rudenko <[email protected]> Auto-Submit: Simon Zünd <[email protected]> Commit-Queue: Alex Rudenko <[email protected]>
1 parent 35f9514 commit d71014f

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed

front_end/models/ai_assistance/data_formatters/BUILD.gn

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# Use of this source code is governed by a BSD-style license that can be
33
# found in the LICENSE file.
44

5+
import("../../../../scripts/build/ninja/devtools_module.gni")
56
import("../../../../scripts/build/typescript/typescript.gni")
67

78
ts_library("unittests") {
@@ -29,7 +30,7 @@ ts_library("unittests") {
2930
]
3031
}
3132

32-
ts_library("foundation_unittests") {
33+
devtools_foundation_module("foundation_unittests") {
3334
testonly = true
3435

3536
sources = [ "PerformanceTraceFormatterBounds.test.ts" ]

scripts/build/ninja/devtools_module.gni

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import("../../../scripts/build/typescript/typescript.gni")
66

77
template("devtools_base_module") {
88
ts_library(target_name) {
9-
forward_variables_from(invoker, "*", ["visibility"])
9+
forward_variables_from(invoker, "*", [ "visibility" ])
1010

1111
reset_timestamps = true
1212

@@ -20,6 +20,17 @@ template("devtools_module") {
2020
}
2121
}
2222

23+
# A module that can run in any runtime we support. As such, it must only use
24+
# features and APIs shared across all supported runtimes.
25+
template("devtools_foundation_module") {
26+
devtools_base_module(target_name) {
27+
forward_variables_from(invoker, "*")
28+
29+
es_target = "es2023"
30+
es_libs = []
31+
}
32+
}
33+
2334
template("devtools_ui_module") {
2435
devtools_base_module(target_name) {
2536
forward_variables_from(invoker, "*")
@@ -34,6 +45,7 @@ template("devtools_ui_module") {
3445

3546
foreach(module,
3647
[
48+
"devtools_foundation_module",
3749
"devtools_module",
3850
"devtools_ui_module",
3951
]) {

scripts/build/typescript/ts_library.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,8 @@ def get_relative_path_from_output_directory(file_to_resolve):
290290
tsconfig['compilerOptions']['outDir'] = '.'
291291
tsconfig['compilerOptions']['tsBuildInfoFile'] = tsbuildinfo_name
292292
tsconfig['compilerOptions']['target'] = opts.es_target
293-
tsconfig['compilerOptions']['lib'] = (opts.es_libs or ['dom', 'dom.iterable']) + [
293+
es_libs = ['dom', 'dom.iterable'] if opts.es_libs is None else opts.es_libs
294+
tsconfig['compilerOptions']['lib'] = es_libs + [
294295
'ES2023', 'ES2024.Promise', 'ESNext.Iterator', 'ESNext.Collection',
295296
'ESNext.Array'
296297
]

0 commit comments

Comments
 (0)