Skip to content

Commit 4d49fb1

Browse files
szuendDevtools-frontend LUCI CQ
authored andcommitted
[build] Allow ts_library users to pass in additional 'libs'
We want `devtools_modules` to be able to specify different 'target' and 'libs' so the UI can use esnext whereas foundtion is restricted to es2023 and no DOM. [email protected] Bug: 451542954 Change-Id: I496dd569272d7ae4af6e35fe8d8b096b382f0780 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/7044328 Reviewed-by: Alex Rudenko <[email protected]> Commit-Queue: Simon Zünd <[email protected]>
1 parent a8c19ac commit 4d49fb1

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

scripts/build/typescript/ts_library.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,7 @@ def main():
215215
parser.add_argument('--use-esbuild', action='store_true')
216216
parser.add_argument('--tsconfig-only', action='store_true')
217217
parser.add_argument('--es-target', required=False)
218+
parser.add_argument('--es-libs', nargs='*', required=False)
218219
# Restrict supported features to the ones supported by Node 22.
219220
parser.set_defaults(test_only=False,
220221
no_emit=False,
@@ -290,7 +291,7 @@ def get_relative_path_from_output_directory(file_to_resolve):
290291
tsconfig['compilerOptions']['outDir'] = '.'
291292
tsconfig['compilerOptions']['tsBuildInfoFile'] = tsbuildinfo_name
292293
tsconfig['compilerOptions']['target'] = opts.es_target
293-
tsconfig['compilerOptions']['lib'] = [
294+
tsconfig['compilerOptions']['lib'] = (opts.es_libs or []) + [
294295
'ES2023', 'ES2024.Promise', 'ESNext.Iterator', 'ESNext.Collection',
295296
'ESNext.Array'
296297
] + (opts.is_web_worker and ['webworker', 'webworker.iterable']

scripts/build/typescript/typescript.gni

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,14 @@ template("ts_library") {
8484
defined(sources) || defined(deps) || defined(invoker.sourceslist),
8585
"You must either specify an array of 'sources' or 'deps' or a 'sourceslist' for $target_name")
8686

87+
if (defined(invoker.es_target)) {
88+
args += [ "--es-target", invoker.es_target ]
89+
}
90+
91+
if (defined(invoker.es_libs)) {
92+
args += [ "--es-libs" ] + invoker.es_libs
93+
}
94+
8795
_test_only = defined(invoker.testonly) && invoker.testonly
8896
_no_emit = defined(invoker.no_emit) && invoker.no_emit
8997
_tsconfig_only = defined(invoker.tsconfigonly) && invoker.tsconfigonly

0 commit comments

Comments
 (0)