user2394200
user2394200

Reputation: 43

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.

Upvotes: 4

Views: 675

Answers (3)

rodrigo-silveira
rodrigo-silveira

Reputation: 13088

Also, note that the new comment pragma is now

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

instead of the old

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

Upvotes: 1

John
John

Reputation: 5468

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

Upvotes: 1

John
John

Reputation: 5468

Be sure to enable source map loading in the developer tools.

Upvotes: 0

Related Questions