Skip to content

Commit

Permalink
fix: Sourcemap links are not generated (#154)
Browse files Browse the repository at this point in the history
* fix: Sourcemap links are not generated

* cleanups

---------

Co-authored-by: Alex Eagle <alex@aspect.dev>
  • Loading branch information
realtimetodie and alexeagle committed Feb 5, 2023
1 parent 6dd510c commit 15455a3
Show file tree
Hide file tree
Showing 16 changed files with 26 additions and 23 deletions.
2 changes: 1 addition & 1 deletion MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ bazel_dep(name = "bazel_skylib", version = "1.3.0")
bazel_dep(name = "platforms", version = "0.0.4")

swc = use_extension("@aspect_rules_swc//swc:extensions.bzl", "swc")
swc.toolchain(name = "swc", swc_version = "v1.3.25")
swc.toolchain(name = "swc", swc_version = "v1.3.31")
use_repo(swc, "swc_toolchains")

register_toolchains("@swc_toolchains//:all")
8 changes: 4 additions & 4 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ swc_register_toolchains(
name = "swc",
# Demonstrates how users can choose ANY swc version, not just the ones we mirrored
integrity_hashes = {
"darwin-arm64": "sha384-4TRcW8Nb2g/3zQ0T4aS+NSjMbUaIHaGxofkA67CcAQZbeK1uDmjXFh5uJw69ZV07",
"darwin-x64": "sha384-uh5Pt06OgF/bhQaq09/SO0hNa9x/isZ3O9R+3uwseSdbL7OentceFHZ/zTr9Y+xL",
"linux-arm64-gnu": "sha384-2uYEohzUAAalEGiD0iEPEDWlR1BCM4q+DhsnIe5saa8B2+igdLzsQrbREimhu5TJ",
"linux-x64-gnu": "sha384-c46sYs/jCA4OjV7LeWT201dYQDTO76V6sZzdtOiGt+3Gls9n6QG+K4hkpIE+wy0k",
"darwin-arm64": "sha384-tSMDc6MG2llNW0PoEaWayHSia7YXDWVV+ceaiAl3Ew1xGA3lmfC2wTuKzaJU+16o",
"darwin-x64": "sha384-e9/dVt6KQTPVyH3y2Oy8J+Bz5XVI0hiK6fwknNsq/yTY+hftJ+SDqDW2YMkfCa3C",
"linux-arm64-gnu": "sha384-cipAIuV6Sa33feJMftOL56t3yEqr0/E6feFWkBnbIAtlSFsUEcv7LY+M7zLdn7Or",
"linux-x64-gnu": "sha384-s9hTnWi9jZM2MZJNnCn7Pg19vfSLnf8kCCYAgBN4UM4NFlN8+BpfGHG+jzq6BkaA",
},
swc_version_from = "//:package.json",
)
Expand Down
2 changes: 1 addition & 1 deletion examples/filegroup/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ swc(
name = "compile",
srcs = ["srcs"],
source_maps = "true",
# We don't have to specify this. When .swcrc is present, it's used automatically.
# We don't have to specify this. When a .swcrc configuration file is present in the current directory, it's used automatically.
# swcrc = ".swcrc",
)

Expand Down
1 change: 0 additions & 1 deletion examples/filegroup/a.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
export const a: string = "a";
//# sourceMappingURL=a.js.map
1 change: 0 additions & 1 deletion examples/filegroup/b.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
export const b: string = "b";
//# sourceMappingURL=b.js.map
3 changes: 2 additions & 1 deletion examples/paths/.swcrc
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@
},
"module": {
"type": "commonjs"
}
},
"sourceMaps": true
}
2 changes: 1 addition & 1 deletion examples/paths/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ load("@aspect_bazel_lib//lib:testing.bzl", "assert_json_matches")
load("@aspect_bazel_lib//lib:write_source_files.bzl", "write_source_files")
load("@aspect_rules_swc//swc:defs.bzl", "swc")

# Note: .swcrc will be automatically found in the current folder
# Note: The .swcrc configuration file will be automatically used, if it is present in the current directory
swc(name = "compile")

# Verify that the "paths" entry is agreed between swc and TS language service (in the editor)
Expand Down
2 changes: 1 addition & 1 deletion examples/paths/expected.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ Object.defineProperty(exports, "__esModule", {
value: true
});
const _moduleA = require("./modules/moduleA");
(0, _moduleA.moduleA)(); //# sourceMappingURL=index.js.map
(0, _moduleA.moduleA)();
2 changes: 0 additions & 2 deletions examples/paths/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { moduleA } from "@modules/moduleA";

moduleA();

//# sourceMappingURL=index.js.map
2 changes: 2 additions & 0 deletions examples/rc/src/expected.js

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

2 changes: 1 addition & 1 deletion examples/rc/src/expected.js.map

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"// this file only used for WORKSPACE to infer our version of swc": "",
"devDependencies": {
"@swc/core": "1.3.25"
"@swc/core": "1.3.31"
}
}
2 changes: 1 addition & 1 deletion swc/defs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def swc(name, srcs = None, args = [], data = [], output_dir = False, swcrc = Non

if swcrc == None:
if file_exists(to_label(":.swcrc")):
swcrc = ".swcrc"
swcrc = to_label(":.swcrc")
elif type(swcrc) == type(dict()):
swcrc.setdefault("sourceMaps", source_maps)
rcfile = "{}_swcrc.json".format(name)
Expand Down
6 changes: 0 additions & 6 deletions swc/private/swc.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -229,12 +229,6 @@ def _impl(ctx):
js_map_out = ctx.actions.declare_file(map_out_path)
outputs.append(js_map_out)

if ctx.attr.source_maps in ["true", "both"]:
src_args.add_all([
"--source-map-target",
js_map_out.path,
])

inputs = [src]
inputs.extend(ctx.toolchains["@aspect_rules_swc//swc:toolchain_type"].swcinfo.tool_files)

Expand Down
10 changes: 10 additions & 0 deletions swc/private/versions.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@

# Versions should be descending order so TOOL_VERSIONS[0] is the latest version.
TOOL_VERSIONS = {
"v1.3.31": {
"darwin-arm64": "sha384-tSMDc6MG2llNW0PoEaWayHSia7YXDWVV+ceaiAl3Ew1xGA3lmfC2wTuKzaJU+16o",
"darwin-x64": "sha384-e9/dVt6KQTPVyH3y2Oy8J+Bz5XVI0hiK6fwknNsq/yTY+hftJ+SDqDW2YMkfCa3C",
"linux-arm-gnueabihf": "sha384-UCCjrMSg0dX5KN2IFCPhprsqLNoT7QXZwcKfpiYjhrpvIksCFq33nY8se+G88DKz",
"linux-arm64-gnu": "sha384-cipAIuV6Sa33feJMftOL56t3yEqr0/E6feFWkBnbIAtlSFsUEcv7LY+M7zLdn7Or",
"linux-x64-gnu": "sha384-s9hTnWi9jZM2MZJNnCn7Pg19vfSLnf8kCCYAgBN4UM4NFlN8+BpfGHG+jzq6BkaA",
"win32-arm64-msvc": "sha384-XYEEKojSlsPPTPi/BAxMM99DPtfaZ6oNkC+uyC55k4pYFIsHcKoGXN7CKhjfqKwJ",
"win32-ia32-msvc": "sha384-bEFBM1JCRTqtqx2jIVjF3PVyHRk84RWsAPR1asCVhcNMzvz1VDd6Ydtq2KR4K5v1",
"win32-x64-msvc": "sha384-wz5LmUtrIr3Qfy9yKbYWX+N2CqdmDyoe7OTnOkYaMR5s1v/e4s4BVrjFjQqkwcex",
},
"v1.3.25": {
"darwin-arm64": "sha384-4TRcW8Nb2g/3zQ0T4aS+NSjMbUaIHaGxofkA67CcAQZbeK1uDmjXFh5uJw69ZV07",
"darwin-x64": "sha384-uh5Pt06OgF/bhQaq09/SO0hNa9x/isZ3O9R+3uwseSdbL7OentceFHZ/zTr9Y+xL",
Expand Down
2 changes: 1 addition & 1 deletion swc/tests/versions_test.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def _smoke_test_impl(ctx):

# TODO: assert instead that the TOOL_VERSIONS.keys()[0] is the newest version
# and version numbers down from there are descending
asserts.equals(env, "v1.3.25", TOOL_VERSIONS.keys()[0])
asserts.equals(env, "v1.3.31", TOOL_VERSIONS.keys()[0])
return unittest.end(env)

# The unittest library requires that we export the test cases as named test rules,
Expand Down

0 comments on commit 15455a3

Please sign in to comment.