rules_closure icon indicating copy to clipboard operation
rules_closure copied to clipboard

Configurable source mapping

Open jart opened this issue 8 years ago • 5 comments

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.

jart avatar Mar 23 '16 19:03 jart

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?

robfig avatar Mar 25 '19 14:03 robfig

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?

robfig avatar Mar 27 '19 01:03 robfig

Looks ok to me. Is this going to be anything beyond creating a facade for --source_map_location_mapping flag?

gkdn avatar Mar 28 '19 22:03 gkdn

Nope, that's it. Should be pretty straightforward

robfig avatar Mar 29 '19 13:03 robfig

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

robfig avatar Jul 05 '19 20:07 robfig