Skip to content

Commit

Permalink
Fix for --incompatible_depset_is_not_iterable
Browse files Browse the repository at this point in the history
We used a depset for a collection which is only used within the context of a single target: the files[] block in the generated tsconfig. As documented on https://docs.bazel.build/versions/master/skylark/depsets.html:
"If you don’t need the merge operation, consider using another type, such as list or dict."

The problem is exposed by --incompatible_depset_is_not_iterable which fails at the spot where we iterated the depset of files, showing that it should have been a list.

Also clean up a warning about the deprecated load of jasmine_node_test

See bazel-contrib#443

Closes bazel-contrib#451

PiperOrigin-RevId: 249758830
  • Loading branch information
alexeagle committed May 24, 2019
1 parent 8e6dfa1 commit 52d9dc9
Show file tree
Hide file tree
Showing 6 changed files with 578 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@

# gazelle:exclude worker_protocol.proto

load("@build_bazel_rules_nodejs//:defs.bzl", "jasmine_node_test", "nodejs_binary")
load("@build_bazel_rules_nodejs//:defs.bzl", "nodejs_binary")
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
load("@npm_bazel_jasmine//:index.bzl", "jasmine_node_test")
load("@npm_bazel_typescript//:defs.bzl", "ts_library")

package(default_visibility = ["//visibility:public"])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ def compile_ts(
if "TYPESCRIPT_PERF_TRACE_TARGET" in ctx.var:
perf_trace = str(ctx.label) == ctx.var["TYPESCRIPT_PERF_TRACE_TARGET"]

compilation_inputs = depset(srcs_files, transitive = [input_declarations])
compilation_inputs = dep_declarations.transitive.to_list() + srcs_files
tsickle_externs_path = tsickle_externs[0] if tsickle_externs else None

# Calculate allowed dependencies for strict deps enforcement.
Expand Down Expand Up @@ -344,7 +344,7 @@ def compile_ts(
replay_params = None

if has_sources:
inputs = depset([ctx.outputs.tsconfig], transitive = [compilation_inputs])
inputs = compilation_inputs + [ctx.outputs.tsconfig]
replay_params = compile_action(
ctx,
inputs,
Expand Down Expand Up @@ -388,10 +388,9 @@ def compile_ts(
ctx.actions.write(output = tsconfig_json_es5, content = json_marshal(
tsconfig_es5,
))
inputs = depset([tsconfig_json_es5], transitive = [compilation_inputs])
devmode_compile_action(
ctx,
inputs,
compilation_inputs + [tsconfig_json_es5],
outputs,
tsconfig_json_es5,
node_profile_args,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ def create_tsconfig(
Returns:
A nested dict that corresponds to a tsconfig.json structure
"""
if (type(files) != type([])):
fail("expected files argument to be a list, got " + type(files))

outdir_path = out_dir if out_dir != None else ctx.configuration.bin_dir.path

# Callers can choose the filename for the tsconfig, but it must always live
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ def rules_typescript_dev_dependencies():
_maybe(
http_archive,
name = "build_bazel_rules_nodejs",
urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/0.29.0/rules_nodejs-0.29.0.tar.gz"],
sha256 = "1db950bbd27fb2581866e307c0130983471d4c3cd49c46063a2503ca7b6770a4",
sha256 = "73325a155c16bfbde29fb2ffcaf59d9d5a1c13b06ada386d3edd5a9d82bda702",
urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/0.29.1/rules_nodejs-0.29.1.tar.gz"],
)

# For protocol buffers
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,10 @@
"homepage": "https://github.com/bazelbuild/rules_typescript",
"license": "Apache-2.0",
"devDependencies": {
"protobufjs": "6.8.8",
"semver": "5.6.0",
"source-map-support": "0.5.9",
"tsutils": "2.27.2",
"@bazel/bazel": "0.25.1",
"@bazel/buildifier": "^0.20.0",
"@bazel/ibazel": "^0.2.0",
"@bazel/jasmine": "^0.29.0",
"@bazel/typescript": "0.29.0",
"@types/jasmine": "^2.8.2",
"@types/long": "^4.0.0",
Expand All @@ -28,11 +25,15 @@
"karma-requirejs": "1.1.0",
"karma-sauce-launcher": "2.0.2",
"karma-sourcemap-loader": "0.3.7",
"protobufjs": "6.8.8",
"protractor": "^5.2.0",
"requirejs": "2.3.5",
"semver": "5.6.0",
"shelljs": "^0.8.2",
"source-map-support": "0.5.9",
"tmp": "0.0.33",
"tsickle": "0.33.1",
"tsutils": "2.27.2",
"typescript": "~3.1.6",
"which": "~1.0.5"
},
Expand Down
Loading

0 comments on commit 52d9dc9

Please sign in to comment.