From 42b751aa6960750c2aa15a2a97edbd20f182f03a Mon Sep 17 00:00:00 2001 From: David Zbarsky Date: Sat, 6 Jan 2024 02:02:50 -0500 Subject: [PATCH] perf: only emit aspect_rules_js_metadata when required (#1420) --- js/private/test/image/structure/digests.sum | 2 +- js/private/test/image/structure/node_modules_structure.mf | 1 - npm/private/npm_import.bzl | 6 ++++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/js/private/test/image/structure/digests.sum b/js/private/test/image/structure/digests.sum index 944a4146a..d58089740 100644 --- a/js/private/test/image/structure/digests.sum +++ b/js/private/test/image/structure/digests.sum @@ -1,2 +1,2 @@ 9546c440ffbbe36177f305a1aec4bf89fa08eea5926fe828c8e9edd8e08a16a7 -d26b897f8c3e3c3464f5acfd50ad56793f82f1f362e2bc2a78bc6a77204561cc +ea187b7d895f6fecc13eb08ff07bc9a1765a39cd082d4cfbb65739d0e66dcf95 diff --git a/js/private/test/image/structure/node_modules_structure.mf b/js/private/test/image/structure/node_modules_structure.mf index 051afb70f..60eea8e3a 100644 --- a/js/private/test/image/structure/node_modules_structure.mf +++ b/js/private/test/image/structure/node_modules_structure.mf @@ -23,7 +23,6 @@ app/js/private/test/image/structure/bin.runfiles/aspect_rules_js/node_modules/.a app/js/private/test/image/structure/bin.runfiles/aspect_rules_js/node_modules/.aspect_rules_js/acorn@8.8.2/node_modules/acorn/CHANGELOG.md app/js/private/test/image/structure/bin.runfiles/aspect_rules_js/node_modules/.aspect_rules_js/acorn@8.8.2/node_modules/acorn/LICENSE app/js/private/test/image/structure/bin.runfiles/aspect_rules_js/node_modules/.aspect_rules_js/acorn@8.8.2/node_modules/acorn/README.md -app/js/private/test/image/structure/bin.runfiles/aspect_rules_js/node_modules/.aspect_rules_js/acorn@8.8.2/node_modules/acorn/aspect_rules_js_metadata.json app/js/private/test/image/structure/bin.runfiles/aspect_rules_js/node_modules/.aspect_rules_js/acorn@8.8.2/node_modules/acorn/bin app/js/private/test/image/structure/bin.runfiles/aspect_rules_js/node_modules/.aspect_rules_js/acorn@8.8.2/node_modules/acorn/bin/acorn app/js/private/test/image/structure/bin.runfiles/aspect_rules_js/node_modules/.aspect_rules_js/acorn@8.8.2/node_modules/acorn/dist diff --git a/npm/private/npm_import.bzl b/npm/private/npm_import.bzl index 2247a99af..d20a4395d 100644 --- a/npm/private/npm_import.bzl +++ b/npm/private/npm_import.bzl @@ -598,8 +598,10 @@ bin = bin_factory("node_modules") if rctx.attr.custom_postinstall: rules_js_metadata["scripts"] = {} rules_js_metadata["scripts"]["custom_postinstall"] = rctx.attr.custom_postinstall - rules_js_json_path = paths.join(_EXTRACT_TO_DIRNAME, "aspect_rules_js_metadata.json") - rctx.file(rules_js_json_path, json.encode_indent(rules_js_metadata, indent = " ")) + + if rules_js_metadata: + rules_js_json_path = paths.join(_EXTRACT_TO_DIRNAME, "aspect_rules_js_metadata.json") + rctx.file(rules_js_json_path, json.encode_indent(rules_js_metadata, indent = " ")) for filename, contents in rctx_files.items(): rctx.file(filename, "\n".join(contents))