Git Product home page Git Product logo

scalajs-friendly-source-map-loader's Introduction

npm

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 <cwd>/.scala-js-sources. Webpack already caches source maps so this cache mostly helps with cold starts.

As a drop-in replacement:

...
            {
                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:

...
            {
                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.

scalajs-friendly-source-map-loader's People

Contributors

aappddeevv avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

scalajs-friendly-source-map-loader's Issues

URL that fails to resolve results in webpack:///undefined

A non-file and non-http URL that cannot be resolved (such as an invalid relative path) results in a source of webpack:///undefined.

The result in the callback to resolve is undefined and so it passes to the next callback { source: undefined, content: "" }.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.