source-mapsgoogle-closure

Google Closure Source Map Not Connecting Source In Chrome


I'm using Google Closure to generate minified JS/source map and can't get the source map to connect the source to the minified script in the "Sources" window in Chrome.

Code taken from the Google Closure compiler documentation

My source is this (hello.js):

// A simple function.
function hello(longName) {
alert('Hello, ' + longName);
}
hello('New User');

My compiler execution command is:

java -jar compiler.jar --js hello.js --js_output_file hello.min.js --create_source_map hello.min.js.map

This executes successfully and produces:

Minified source (hello.min.js):

function hello(a){alert("Hello, "+a)}hello("New User");

I add the following line to the end of hello.min.js as recommended in this article

//@ sourceMappingURL=hello.min.js.map

Everything, source map included, is in the same directory and source maps are enabled in Chrome. The index.html page simply includes hello.min.js in the body tag.

Can anyone see what I'm doing incorrectly? I'd really appreciate any help.


Solution

  • You will want to verify that you don't have an antivirus/security product or firewall blocking the request for the source map file.