The original Google Closure map is not associated with the source in Chrome

I use Google Closure to create a miniature JS / source map and cannot get the source map to connect the source to the mini script in the Sources window in Chrome.

Code taken from Google Closure Compiler Documentation

My source is this (hello.js):

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

My compiler run command:

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

This succeeds and creates:

Minified source (hello.min.js):

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

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

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

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

Can anyone see what I'm doing wrong? I would really appreciate any help.

thanks

+4
source share
3 answers

You need to make sure that you do not have an antivirus product or a firewall blocking the request for the source map file.

+1
source

Also note that the new comment pragma is now

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

instead of the old

 //@ sourceMappingURL=hello.min.js.map 
+1
source

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

0
source

Source: https://habr.com/ru/post/1481406/


All Articles