Skip to content

Commit

Permalink
style: update file format
Browse files Browse the repository at this point in the history
  • Loading branch information
manekinekko authored and alexeagle committed Feb 5, 2019
1 parent 542e7e0 commit b7eae90
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 18 deletions.
2 changes: 1 addition & 1 deletion internal/common/collect_es6_sources.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def collect_es6_sources(ctx):
non_rerooted_files += ctx.files.srcs
for dep in ctx.attr.deps:
if hasattr(dep, "typescript"):
non_rerooted_files += dep.typescript.transitive_es6_sources.to_list()
non_rerooted_files += dep.typescript.transitive_es6_sources.to_list()

rerooted_files = []
for file in non_rerooted_files:
Expand Down
30 changes: 15 additions & 15 deletions internal/node/node.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -102,17 +102,17 @@ def _short_path_to_manifest_path(ctx, short_path):
def _nodejs_binary_impl(ctx):
node = ctx.file.node
node_modules = ctx.files.node_modules

# Using a depset will allow us to avoid flattening files and sources
# inside this loop. This should reduce the performances hits,
# inside this loop. This should reduce the performances hits,
# since we don't need to call .to_list()
sources = depset()

for d in ctx.attr.data:
if hasattr(d, "node_sources"):
sources = depset( transitive = [sources, d.node_sources] )
sources = depset(transitive = [sources, d.node_sources])
if hasattr(d, "files"):
sources = depset( transitive = [sources, d.files] )
sources = depset(transitive = [sources, d.files])

_write_loader_script(ctx)

Expand Down Expand Up @@ -152,23 +152,23 @@ def _nodejs_binary_impl(ctx):
)

runfiles = depset(
transitive = [sources + [node, ctx.outputs.loader, ctx.file._repository_args] + node_modules + ctx.files._node_runfiles]
transitive = [sources + [node, ctx.outputs.loader, ctx.file._repository_args] + node_modules + ctx.files._node_runfiles],
)

return [DefaultInfo(
executable = ctx.outputs.script,
runfiles = ctx.runfiles(
transitive_files = runfiles,
files = [
node,
ctx.outputs.loader
] + ctx.files._source_map_support_files + node_modules +
# We need this call to the list of Files.
# Calling the .to_list() method may have some perfs hits,
# so we should be running this method only once per rule.
# see: https://docs.bazel.build/versions/master/skylark/depsets.html#performance
sources.to_list(),
node,
ctx.outputs.loader,
] + ctx.files._source_map_support_files + node_modules +

# We need this call to the list of Files.
# Calling the .to_list() method may have some perfs hits,
# so we should be running this method only once per rule.
# see: https://docs.bazel.build/versions/master/skylark/depsets.html#performance
sources.to_list(),
collect_data = True,
),
)]
Expand Down
2 changes: 0 additions & 2 deletions internal/rollup/rollup_bundle.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,6 @@ def run_rollup(ctx, sources, config, output):
return map_output

def _filter_js_inputs(all_inputs):

# Note: make sure that "all_inputs" is not a depset.
# Iterating over a depset is deprecated!
return [
Expand Down Expand Up @@ -187,7 +186,6 @@ def _run_rollup(ctx, sources, config, output, map_output = None):
# These deps are identified by the NodeModuleInfo provider.
for d in ctx.attr.deps:
if NodeModuleInfo in d:

# Note: we can't avoid calling .to_list() on files
direct_inputs += _filter_js_inputs(d.files.to_list())

Expand Down

0 comments on commit b7eae90

Please sign in to comment.