WebUI: Move "/strings.m.js" path mapping outside of ts_library().
ts_library() should be WebUI-agnostic as much as possible and WebUI-specific concepts should be dealt with in higher WebUI-aware layers like build_webui(), build_webui_tests() or webui_ts_library(). Bug: 397737230 Change-Id: I970fd62886bac82685bc36e618c4fdc5f7d5a5e0 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6289211 Reviewed-by: Rebekah Potter <rbpotter@chromium.org> Commit-Queue: Demetrios Papadopoulos <dpapad@chromium.org> Cr-Commit-Position: refs/heads/main@{#1424245}
This commit is contained in:
ash/webui/media_app_ui
tools/typescript
ui/webui/resources/tools
@ -170,7 +170,9 @@ ts_library("test_build_ts") {
|
||||
root_dir = ts_root_dir
|
||||
testonly = true
|
||||
in_files = media_app_test_ts
|
||||
definitions = media_app_definitions_staged + media_app_test_definitions_staged
|
||||
definitions =
|
||||
media_app_definitions_staged + media_app_test_definitions_staged +
|
||||
[ "//tools/typescript/definitions/strings.d.ts" ]
|
||||
deps = [
|
||||
":build_ts",
|
||||
"//chrome/test/data/webui:build_ts",
|
||||
|
@ -194,6 +194,14 @@ def main(argv):
|
||||
target_path = getTargetPath(args.gen_dir, args.root_gen_dir)
|
||||
is_ash_target = isInAshFolder(target_path)
|
||||
path_mappings = collections.defaultdict(list)
|
||||
|
||||
# First, add a path mapping for '/strings.m.js', which is not tied to
|
||||
# `raw_deps` and is used extensively throughout WebUI.
|
||||
path_mappings['/strings.m.js'].append(
|
||||
f'{args.root_src_dir}/tools/typescript/definitions/strings.d.ts'.replace(
|
||||
'\\', '/'))
|
||||
|
||||
# Then add path mappings that can be derived from `raw_deps`.
|
||||
for dep in args.raw_deps:
|
||||
dependencyType = 'Browser-only' if is_ash_target else 'Ash-only'
|
||||
assert _is_dependency_allowed(is_ash_target, dep, target_path), \
|
||||
|
@ -1,4 +1,7 @@
|
||||
{
|
||||
"/strings.m.js": [
|
||||
"../../../../../tests/tools/typescript/definitions/strings.d.ts"
|
||||
],
|
||||
"//resources/js/*": [
|
||||
"./../../../../ui/webui/resources/tsc/js/*"
|
||||
],
|
||||
|
@ -1,4 +1,7 @@
|
||||
{
|
||||
"/strings.m.js": [
|
||||
"../../../../../tests/tools/typescript/definitions/strings.d.ts"
|
||||
],
|
||||
"//resources/js/*": [
|
||||
"./../../../../ui/webui/resources/tsc/js/*"
|
||||
],
|
||||
|
@ -1,4 +1,7 @@
|
||||
{
|
||||
"/strings.m.js": [
|
||||
"../../../../../tests/tools/typescript/definitions/strings.d.ts"
|
||||
],
|
||||
"chrome://resources/js/*": [
|
||||
"./../../../../ui/webui/resources/tsc/js/*"
|
||||
],
|
||||
|
@ -1,4 +1,7 @@
|
||||
{
|
||||
"/strings.m.js": [
|
||||
"../../../../../tests/tools/typescript/definitions/strings.d.ts"
|
||||
],
|
||||
"//resources/js/*": [
|
||||
"./../../../../ui/webui/resources/tsc/js/*"
|
||||
],
|
||||
|
@ -93,18 +93,15 @@ template("ts_library") {
|
||||
args += [ "--manifest_excludes" ] + manifest_excludes
|
||||
}
|
||||
|
||||
definitions = [ rebase_path("//tools/typescript/definitions/strings.d.ts",
|
||||
target_gen_dir) ]
|
||||
|
||||
if (defined(invoker.definitions)) {
|
||||
inputs += invoker.definitions
|
||||
definitions = []
|
||||
foreach(_definition, invoker.definitions) {
|
||||
definitions += [ rebase_path(_definition, target_gen_dir) ]
|
||||
}
|
||||
args += [ "--definitions" ] + definitions
|
||||
}
|
||||
|
||||
args += [ "--definitions" ] + definitions
|
||||
|
||||
if (defined(deps)) {
|
||||
args += [ "--deps" ]
|
||||
foreach(dep, deps) {
|
||||
@ -151,13 +148,6 @@ template("ts_library") {
|
||||
path_mappings = [
|
||||
"/tools/typescript/definitions/*|" +
|
||||
rebase_path("//tools/typescript/definitions/*", target_gen_dir),
|
||||
|
||||
# Path mapping for resolving "import '/strings.m.js';" imports extensively
|
||||
# used across WebUIs.
|
||||
"/strings.m.js|" +
|
||||
rebase_path("//tools/typescript/definitions/strings.d.ts",
|
||||
target_gen_dir),
|
||||
|
||||
# NOTE: path_mappings corresponding to files generated by
|
||||
# other ts_library() deps are automatically inferred from |deps| in
|
||||
# path_mappings.py. Don't add any such mappings here.
|
||||
|
@ -13,7 +13,6 @@ template("webui_ts_library") {
|
||||
"out_dir",
|
||||
"composite",
|
||||
"in_files",
|
||||
"definitions",
|
||||
"tsconfig_base",
|
||||
"path_mappings",
|
||||
"manifest_excludes",
|
||||
@ -45,5 +44,10 @@ template("webui_ts_library") {
|
||||
if (defined(invoker.extra_deps)) {
|
||||
extra_deps += invoker.extra_deps
|
||||
}
|
||||
|
||||
definitions = [ "//tools/typescript/definitions/strings.d.ts" ]
|
||||
if (defined(invoker.definitions)) {
|
||||
definitions += invoker.definitions
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -422,8 +422,9 @@ template("build_webui") {
|
||||
deps = invoker.ts_deps
|
||||
}
|
||||
|
||||
definitions = [ "//tools/typescript/definitions/strings.d.ts" ]
|
||||
if (defined(invoker.ts_definitions)) {
|
||||
definitions = invoker.ts_definitions
|
||||
definitions += invoker.ts_definitions
|
||||
}
|
||||
|
||||
if (defined(invoker.ts_path_mappings)) {
|
||||
|
Reference in New Issue
Block a user