Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/aappddeevv/scalajs-friendly-source-map-loader
Drop in replacement for webpack's source-map-loader that understands file:// and http[s]:// sources in scala.js generated source map files.
https://github.com/aappddeevv/scalajs-friendly-source-map-loader
loaders scala scalajs webpack
Last synced: 10 days ago
JSON representation
Drop in replacement for webpack's source-map-loader that understands file:// and http[s]:// sources in scala.js generated source map files.
- Host: GitHub
- URL: https://github.com/aappddeevv/scalajs-friendly-source-map-loader
- Owner: aappddeevv
- Created: 2018-04-18T15:01:01.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2020-05-11T12:17:25.000Z (over 4 years ago)
- Last Synced: 2024-04-30T00:03:28.674Z (6 months ago)
- Topics: loaders, scala, scalajs, webpack
- Language: JavaScript
- Size: 7.81 KB
- Stars: 9
- Watchers: 2
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
![npm](https://img.shields.io/npm/v/scalajs-friendly-source-map-loader)
Drop in replacement for source-map-loader but this loader understands `file://`
and `http[s]://` prefixes in source map files like the kind you find in scala.js
generated source maps. It is often recommended that scala.js resources
use the `-P:scalajs:mapSourceURI` option to set their source maps to
github resources since there is no stable mechanism to include them in jars.Including scala sources increases the map size so use `bundleHttp: false` to not
bundle them. They are bundled by default. Warnings that "file://" resources
cannot be found can be turned off using `skipFileURLWarnings` which is true by
default. If you depend on other scala.js libraries, they may have `file://`
links embedded that cause warnings. If you work offline and do not have access
to http resources, then set your
`bundleHttp` option using a nodejs environment variable: `bundleHttp:
process.env.OFFLINE` and set the environment variable `OFFLINE="true"` before
you run webpack. Note that "true" is in quotes to make at a string environment
variable.Fetched resources are cached. The default cache directory is `/.scala-js-sources`.
Webpack already caches source maps so this cache mostly helps with
cold starts.As a drop-in replacement:
```javascript
...
{
test: /\.js$/,
// use loader defaults
use: ["scalajs-friendly-source-map-loader"],
// set options explicitly
use: [
{
loader: "scalajs-friendly-source-map-loader",
options: {
skipFileURLWarnings: true, // or false, default is true
bundleHttp: true // or false, default is true,
cachePath: ".scala-js-sources", // cache dir name, exclude in .gitignore
noisyCache: false, // whether http cache changes are output
useCache: true, // false => remove any http cache processing
}
}],
enforce: "pre",
},
```To use in your loaders *only* for your scalajs output:
```javascript
...
{
test: /\.js$/,
use: [
{
loader: "scalajs-friendly-source-map-loader"
options: {
bundleHttp: false // or use the short version above
},
}],
enforce: "pre",
include: [scalapath],
},
{
test: /\.js$/,
use: ["source-map-loader"],
enforce: "pre",
// does not handle scala.js issued https: remote resources
exclude: [/node_modules/, scalapath],
},
...
```Loaders are used right to left so the normal source-map-loader will run first
but *ignore* the scala.js output leaving the scala js file to the friendly
loader. `scalapath` is a resolved path to your scala.js compiler output file.