rules_closure
rules_closure copied to clipboard
Configurable source mapping
We do some cool stuff to configure the --source_map_location_mapping
flag. The only configuring it does at the moment, is getting rid of the weird bazel-specific directory names.
However we should also allow the user to specify his own path mappings. For example, he might want java/com/google/foo/js/...
to be represented as /assets/js/...
in the sourcemap file.
Therefore an argument should be added to closure_js_binary
and closure_js_deps
that accepts a string map of bazel directories to web server paths.
Hi @jart , Would you accept a pull request adding this feature, and if so could you confirm exactly how you'd like it to look? I'm looking to migrate our codebase from plovr to rules_closure, but we use this to rewrite all paths to be under a handler that serves them:
"location-mapping": {
"": "/input/%s/"
}
(In this case, %s
is replaced by the JS bundle ID; it just allows us to share the configuration among many plovr configs. I suppose it is not necessary for rules_closure since there are other ways to accomplish the sharing.)
How do you envision that configuration looking for rules_closure?
source_map_location_mapping = {
# /js/common/foo.js => /input/js/common/foo.js
"/": "/input/",
# /java/com/google/foo/js/foo.js => /assets/js/foo.js
"/java/com/google/foo/js/": "/assets/js/"
}
In the above examples, it's basically a string replacement that takes care to join path segments with one slash.
How does that sound?
Looks like @jart hasn't been active for a while. @laurentlb or @dslomov want to weigh in on what you'd like a pull request to look like?
Looks ok to me. Is this going to be anything beyond creating a facade for --source_map_location_mapping flag?
Nope, that's it. Should be pretty straightforward
Looking more into the sourcemap situation, it appears that the sourcemaps produced by default already include the full set of source code in them. Therefore, I don't believe that location mapping is necessary at all. Is that accurate?
Related: #399