Source Maps API Usage

By default Source Maps are disabled. Please use this feature with care, sending the Source Maps to production will expose your original code to everyone.

Enabling Source Maps

To use Source Maps you will have to setup a new option on your Jscrambler config (sourceMaps). Source Maps will be enabled if sourceMaps resolve to any truthy value.

{
  "keys": {
    "accessKey": "YOUR_ACCESS_KEY",
    "secretKey": "YOUR_SECRET_KEY"
  },
  "applicationId": "YOUR_APPLICATION_ID",
  "filesSrc": [
    "/path/to/src.html",
    "/path/to/src.js"
  ],
  "filesDest": "/path/to/destDir/",
  "params": [
    {
      "name": "stringSplitting"
    }
  ],
  "sourceMaps": true
}

For more information about RC configuration please refer to our Github documentation.

Options

You can enable two distinct options when using Source Maps through Jscrambler's API:

Source Maps with embedded source code (default)

Source Maps will include the original source code embedded in the Source Map file.

"sourceMaps": true

Source Maps without embedded source code

If you don't want your original code to be included in the Source Map you'll have to explicitly set the sourceContent option to false. Therefore, the original file will need to be placed in the same directory as the Source Map.

"sourceMaps": {
  "sourceContent": false
}

Disabling Source Maps

If you don't want Source Maps you can both set sourceMaps flag to false or simply omit the sourceMaps property.

"sourceMaps": false

Downloading the Source Maps

For security reasons we have decided to not include the Source Maps alongside your code, so, after enabling them on your configuration file you will need to make another request in order to download them.

Using the client, the protection process sends to the stdout the protectionId which can be used to download the Source Maps executing the following commands:

1. Send application to Jscrambler and download the protected application

$ jscrambler -c your_config.json
# STDOUT: 59021864dd26ca0011dc94ed

2. Download the application Source Maps for the protection id 59021864dd26ca0011dc94ed

$ jscrambler -c your_config.json -m 59021864dd26ca0011dc94ed

Your application Source Maps will be downloaded to a folder named jscramblerSourceMaps found in the destination folder.

Please keep in mind that to load Source Maps into the Browser's Dev tools you'll have to automate this last step: Including Source Maps with your JavaScript files.

Merging other Source Maps with Jscrambler's

In order to merge Source Maps from previous compilations (e.g., Webpack bundling, TypeScript transpilation, etc) with Jscrambler's, upload the Source Maps alongside with your JavaScript source code. For instance, for Webpack upload both bundle.js and bundle.js.map to Jscrambler.

Also, make sure that Source Maps files are in the same directory as their respective source code files.

index.js
index.js.map
/lib/foo.js
/lib/foo.js.map

After that, the process is exactly the same as described in the previous sections.