Skip to content

Commit 6d4e575

Browse files
jfirebaughjbedard
authored andcommitted
fix: source_map = True, allow_js = True outputs source maps for JS inputs
1 parent 21a44d5 commit 6d4e575

File tree

6 files changed

+12
-7
lines changed

6 files changed

+12
-7
lines changed

examples/jsx/expected_outputs.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ examples/jsx/out/b.d.ts
44
examples/jsx/out/b.d.ts.map
55
examples/jsx/out/a.jsx
66
examples/jsx/out/a.jsx.map
7-
examples/jsx/out/b.jsx
7+
examples/jsx/out/b.jsx
8+
examples/jsx/out/b.jsx.map

examples/module_ext/expected_outputs.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ examples/module_ext/out/d.d.cts.map
99
examples/module_ext/out/a.mjs
1010
examples/module_ext/out/a.mjs.map
1111
examples/module_ext/out/b.mjs
12+
examples/module_ext/out/b.mjs.map
1213
examples/module_ext/out/c.cjs
1314
examples/module_ext/out/c.cjs.map
14-
examples/module_ext/out/d.cjs
15+
examples/module_ext/out/d.cjs
16+
examples/module_ext/out/d.cjs.map

ts/defs.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ def ts_project(
354354
tsc_map_outs = []
355355
if emit_tsc_js:
356356
tsc_js_outs = _lib.calculate_js_outs(srcs, out_dir, root_dir, allow_js, resolve_json_module, preserve_jsx, emit_declaration_only)
357-
tsc_map_outs = _lib.calculate_map_outs(srcs, out_dir, root_dir, source_map, preserve_jsx, emit_declaration_only)
357+
tsc_map_outs = _lib.calculate_map_outs(srcs, out_dir, root_dir, source_map, allow_js, preserve_jsx, emit_declaration_only)
358358

359359
# Custom typing transpiler
360360
if emit_transpiler_dts:

ts/private/ts_lib.bzl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ def _calculate_js_outs(srcs, out_dir, root_dir, allow_js, resolve_json_module, p
269269

270270
return _to_js_out_paths(srcs, out_dir, root_dir, allow_js, resolve_json_module, exts, ".js")
271271

272-
def _calculate_map_outs(srcs, out_dir, root_dir, source_map, preserve_jsx, emit_declaration_only):
272+
def _calculate_map_outs(srcs, out_dir, root_dir, source_map, allow_js, preserve_jsx, emit_declaration_only):
273273
if not source_map or emit_declaration_only:
274274
return []
275275

@@ -281,8 +281,10 @@ def _calculate_map_outs(srcs, out_dir, root_dir, source_map, preserve_jsx, emit_
281281
}
282282
if preserve_jsx:
283283
exts[".tsx"] = ".jsx.map"
284+
if allow_js:
285+
exts[".jsx"] = ".jsx.map"
284286

285-
return _to_js_out_paths(srcs, out_dir, root_dir, False, False, exts, ".js.map")
287+
return _to_js_out_paths(srcs, out_dir, root_dir, allow_js, False, exts, ".js.map")
286288

287289
def _calculate_typings_outs(srcs, typings_out_dir, root_dir, declaration, composite, allow_js):
288290
if not (declaration or composite):

ts/private/ts_project.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def _ts_project_impl(ctx):
6868
map_outs = []
6969
if not ctx.attr.no_emit and ctx.attr.transpile != 0:
7070
js_outs = _lib.declare_outputs(ctx, _lib.calculate_js_outs(srcs, ctx.attr.out_dir, ctx.attr.root_dir, ctx.attr.allow_js, ctx.attr.resolve_json_module, ctx.attr.preserve_jsx, ctx.attr.emit_declaration_only))
71-
map_outs = _lib.declare_outputs(ctx, _lib.calculate_map_outs(srcs, ctx.attr.out_dir, ctx.attr.root_dir, ctx.attr.source_map, ctx.attr.preserve_jsx, ctx.attr.emit_declaration_only))
71+
map_outs = _lib.declare_outputs(ctx, _lib.calculate_map_outs(srcs, ctx.attr.out_dir, ctx.attr.root_dir, ctx.attr.source_map, ctx.attr.allow_js, ctx.attr.preserve_jsx, ctx.attr.emit_declaration_only))
7272

7373
# dts+map file outputs
7474
typings_outs = []

ts/test/mock_transpiler.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,6 @@ def mock(name, srcs, source_map = False, **kwargs):
5454
# Calculate pre-declared outputs so they can be referenced as targets.
5555
# This is an optional transpiler feature aligning with the default tsc transpiler.
5656
js_outs = lib.calculate_js_outs(srcs, ".", ".", False, False, False, False),
57-
map_outs = lib.calculate_map_outs(srcs, ".", ".", True, False, False) if source_map else [],
57+
map_outs = lib.calculate_map_outs(srcs, ".", ".", True, False, False, False) if source_map else [],
5858
**kwargs
5959
)

0 commit comments

Comments
 (0)