Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 6c462c4

Browse files
authoredAug 23, 2022
fix: make catch-all node_modules target name configurable in yarn_install and npm_install (#3538)
1 parent dccbb63 commit 6c462c4

File tree

4 files changed

+41
-9
lines changed

4 files changed

+41
-9
lines changed
 

‎docs/Built-ins.md

Lines changed: 27 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎internal/npm_install/generate_build_file.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ let config: any = {
6565
strict_visibility: true,
6666
workspace_rerooted_path: '',
6767
workspace: '',
68+
all_node_modules_target_name: 'node_modules',
6869
};
6970

7071
function generateBuildFileHeader(visibility = PUBLIC_VISIBILITY): string {
@@ -314,7 +315,7 @@ ${exportsStarlark}])
314315
# there are many files in target.
315316
# See https://github.com/bazelbuild/bazel/issues/5153.
316317
js_library(
317-
name = "node_modules",
318+
name = "${config.all_node_modules_target_name}",
318319
package_name = "${LEGACY_NODE_MODULES_PACKAGE_NAME}",
319320
package_path = "${config.package_path}",${pkgFilesStarlark}${depsStarlark}
320321
)

‎internal/npm_install/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ let config = {
2323
strict_visibility: true,
2424
workspace_rerooted_path: '',
2525
workspace: '',
26+
all_node_modules_target_name: 'node_modules',
2627
};
2728
function generateBuildFileHeader(visibility = PUBLIC_VISIBILITY) {
2829
return `# Generated file from ${config.rule_type} rule.
@@ -208,7 +209,7 @@ ${exportsStarlark}])
208209
# there are many files in target.
209210
# See https://github.com/bazelbuild/bazel/issues/5153.
210211
js_library(
211-
name = "node_modules",
212+
name = "${config.all_node_modules_target_name}",
212213
package_name = "${LEGACY_NODE_MODULES_PACKAGE_NAME}",
213214
package_path = "${config.package_path}",${pkgFilesStarlark}${depsStarlark}
214215
)

‎internal/npm_install/npm_install.bzl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,15 @@ Using managed_directories will mean that
359359
default = 3600,
360360
doc = """Maximum duration of the package manager execution in seconds.""",
361361
),
362+
"all_node_modules_target_name": attr.string(
363+
default = "node_modules",
364+
doc = """The name used for the generated all node_modules js_library target.
365+
366+
This can be used to name the all node_modules target something other than `//:node_modules`,
367+
such as `//:node_modules_all`, so you can use the `//:node_modules` label to reference the
368+
`node_modules` source directory in `manual_build_file_contents` for custom use cases.
369+
""",
370+
),
362371
"generate_build_files_concurrency_limit": attr.int(
363372
default = 64,
364373
doc = """Limit the maximum concurrency of npm package processing when generating
@@ -486,6 +495,7 @@ def _create_build_files(repository_ctx, rule_type, node, lock_file, generate_loc
486495
workspace = repository_ctx.attr.name,
487496
workspace_rerooted_package_json_dir = paths.normalize(paths.join(_WORKSPACE_REROOTED_PATH, package_json_dir)),
488497
workspace_rerooted_path = _WORKSPACE_REROOTED_PATH,
498+
all_node_modules_target_name = repository_ctx.attr.all_node_modules_target_name,
489499
),
490500
)
491501
repository_ctx.file("generate_config.json", generate_config_json)

0 commit comments

Comments
 (0)
Please sign in to comment.