Skip to content

Commit f19fe35

Browse files
committed
Fix typescript test example
1 parent 8065459 commit f19fe35

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

node/internal/node_module.bzl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,8 @@ def _node_module_impl(ctx):
177177
executables = executables,
178178
package_json = package_json,
179179
files = depset(outputs),
180+
sources = depset(files),
181+
sourcemap = sourcemap,
180182
transitive_deps = _get_transitive_modules(ctx.attr.deps, "transitive_deps"),
181183
)]
182184

node/internal/providers.bzl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ NodeModuleInfo = provider(
2222
"sha1": "the module sha1 (string)",
2323
"package_json": "the package.json file (File)",
2424
"files": "the complete set of files in the module",
25+
"sources": "the set of source files in the module",
26+
"sourcemap": "the sourcemap file",
2527
"executables": "the set of executable targets",
2628
"transitive_deps": "the set of transitive node module dependencies",
2729
},

tests/typescript/ts_module.bzl

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
load("@org_pubref_rules_node//node/internl:node_module.bzl", "node_module", "NodeModuleInfo")
1+
load("@org_pubref_rules_node//node:internal/providers.bzl", "NodeModuleInfo")
2+
load("@org_pubref_rules_node//node:rules.bzl", "node_module")
23

34
# Note: this is not by any means production quality support for
45
# typescript. It's more of an experiment to exercise the
@@ -8,12 +9,12 @@ def _build_node_module(ctx, compilation_dir, node_module):
89
"""Copy the given node_module into the specified compilation dir"""
910

1011
outputs = []
11-
for src in node_module.sources:
12+
for src in node_module.sources.to_list():
1213
relpath = node_module.sourcemap[src.path]
1314
dst = ctx.actions.declare_file("%s/node_modules/%s/%s" % (compilation_dir, node_module.name, relpath))
1415
outputs.append(dst)
1516

16-
ctx.action(
17+
ctx.actions.run_shell(
1718
mnemonic = "CopyNodeModuleForTs",
1819
inputs = [src],
1920
outputs = [dst],
@@ -71,13 +72,13 @@ def _ts_module_impl(ctx):
7172
# for the compilation)
7273
node_modules = []
7374
for dep in ctx.attr.deps:
74-
node_modules += _build_node_module(ctx, compilation_dir, dep.node_module)
75+
node_modules += _build_node_module(ctx, compilation_dir, dep[NodeModuleInfo])
7576

7677
# Copy the source files into the compilation dir.
7778
srcs = []
7879
for src in ctx.files.srcs:
7980
copied_src = ctx.actions.declare_file("%s/%s" % (compilation_dir, src.short_path))
80-
ctx.action(
81+
ctx.actions.run_shell(
8182
inputs = [src],
8283
outputs = [copied_src],
8384
command = "cp %s %s" % (src.path, copied_src.path),
@@ -112,7 +113,7 @@ def _ts_module_impl(ctx):
112113
arguments += ["--sourceMap"]
113114

114115
# Run the compilation
115-
ctx.action(
116+
ctx.actions.run(
116117
mnemonic = "TypescriptCompile",
117118
inputs = inputs + node_modules + [tsconfig],
118119
outputs = outputs,

0 commit comments

Comments
 (0)