Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ThoughtWorksInc/sbt-scala-js-map
A Sbt plugin that configures source mapping for Scala.js projects hosted on Github
https://github.com/ThoughtWorksInc/sbt-scala-js-map
sbt-plugin scala-js source-map
Last synced: about 1 month ago
JSON representation
A Sbt plugin that configures source mapping for Scala.js projects hosted on Github
- Host: GitHub
- URL: https://github.com/ThoughtWorksInc/sbt-scala-js-map
- Owner: ThoughtWorksInc
- License: apache-2.0
- Created: 2016-04-12T18:38:07.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2024-06-16T00:09:12.000Z (6 months ago)
- Last Synced: 2024-06-20T06:22:26.033Z (6 months ago)
- Topics: sbt-plugin, scala-js, source-map
- Language: Scala
- Homepage:
- Size: 589 KB
- Stars: 36
- Watchers: 12
- Forks: 3
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-ccamel - ThoughtWorksInc/sbt-scala-js-map - A Sbt plugin that configures source mapping for Scala.js projects hosted on Github (Scala)
README
[![Build Status](https://travis-ci.org/ThoughtWorksInc/sbt-scala-js-map.svg)](https://travis-ci.org/ThoughtWorksInc/sbt-scala-js-map)
[![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.thoughtworks.sbt-scala-js-map/sbt-scala-js-map/badge.svg)](https://repo1.maven.org/maven2/com/thoughtworks/sbt-scala-js-map/)**sbt-scala-js-map** is a Sbt plugin that configures source mapping for Scala.js projects hosted on Github.
## Motivation
I have some Scala.js libraries hosted on Github ([Binding.scala](https://github.com/ThoughtWorksInc/Binding.scala) and some private libraries). Then, other Scala.js applications would depend on these libraries. When I debug the Scala.js application in a browser, I want to see the Scala source files of the original libraries.
However, by default, the generated `*.js.map` files maps the generated JavaScript to the absolute Scala source path where the original library compiled. For me, the path is on a Travis CI worker, like `/home/travis/build/ThoughtWorksInc/.../Binding.scala`. The path obviously does not exist on my local computer that debugs the application. Too bad.
This sbt plugin detects if a library is hosted on Github repository and let source map point to https://raw.githubusercontent.com/ instead of a local file path.
### Showcase
Browse http://todomvc.com/examples/binding-scala/ then open the inspector of your browser. You will be able to debug the Scala.js code in your browser now.
![Debugging Scala.js](https://github.com/ThoughtWorksInc/sbt-scala-js-map/raw/master/README.png)
### Alternative options
An alternative option is specifying Scala.js's relative source mappings flag.
However, this approach enforce library users cloning the library's source files into their local file system before debugging their applications.
On the other hand, libraries published with this plugin enable the library users to view the source (of correct revision), automatically.
## Usage
### Step 1: Add the dependencies in your Scala.js library's `project/plugins.sbt`
``` sbt
addSbtPlugin("com.thoughtworks.sbt-scala-js-map" % "sbt-scala-js-map" % "latest.release")
```Note that sbt-scala-js-map 2.x requires sbt 0.13.x, sbt-api-mappings 3.x requires sbt 1.x.
### Step 2: Publish your Scala.js library
Execute the release command if you have setup [sbt-release](https://github.com/sbt/sbt-release) correctly。
```
sbt release
```### Step 3: Debug it!
Now switch your Scala.js application to the newly published Scala.js library, build it, browse your web page, and open the debugger in your browser. You will see the Scala source files hosted under https://raw.githubusercontent.com/ and you can set break points at code lines in these Scala files.