Skip to content

Commit

Permalink
Don't generate empty deps = [] in generated build files
Browse files Browse the repository at this point in the history
  • Loading branch information
gregmagolan committed Apr 9, 2019
1 parent 0c02f16 commit 1dcc4f2
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 15 deletions.
17 changes: 11 additions & 6 deletions internal/npm_install/generate_build_file.js
Original file line number Diff line number Diff line change
Expand Up @@ -707,6 +707,16 @@ function printPackage(pkg) {
],`;
}

let depsStarlark = '';
if (pkgDeps.length) {
depsStarlark = `
# flattened list of direct and transitive dependencies hoisted to root by the package manager
deps = [
${
pkgDeps.map(dep => `"//node_modules/${dep._dir}:${dep._name}__files",`).join('\n ')}
],`;
}

let result = `load("@build_bazel_rules_nodejs//:defs.bzl", "nodejs_binary")
load("@build_bazel_rules_nodejs//internal/npm_install:node_module_library.bzl", "node_module_library")
Expand All @@ -718,12 +728,7 @@ node_module_library(
# ${pkg._dir} package contents (and contents of nested node_modules)
srcs = [
":${pkg._name}__files",
],
# flattened list of direct and transitive dependencies hoisted to root by the package manager
deps = [
${
pkgDeps.map(dep => `"//node_modules/${dep._dir}:${dep._name}__files",`).join('\n ')}
],
],${depsStarlark}
)
# ${pkg._name}__files target is used as dep for other package targets to prevent
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 1dcc4f2

Please sign in to comment.