Unable to get Compiler to generate source map

141 views
Skip to first unread message

Wills Bithrey

unread,
Jun 8, 2017, 12:35:17 PM6/8/17
to Closure Compiler Discuss
Hi,

I'm trying to get Closure Compiler to generate a sourcemap with my build, but no sourcemap file is output. I'm using the official gulp plugin from the closure-compiler-npm module (we are on version 20170423.0.0) and tried setting create_source_map: true, and create_source_map: './example-map', (as per this documentation). My Compiler flags object looks something like this:


{
    entry_point: './path/to/my/main-module.js',
    js_output_file: 'js/app.js',
    generate_exports: true,
    hide_warnings_for: [
        'static/src/closure/goog/base.js',
        'node_modules/lodash-es/'
    ],
    create_source_map: './example-map',
    formatting: 'PRETTY_PRINT',
    module_resolution: 'NODE',
    process_common_js_modules: false,
    warning_level: 'DEFAULT'
}

Everything else works fine, except the Compiler just seems to ignore my requests for a sourcemap.

Any ideas?

Many thanks,

Wills


Chad Killingsworth

unread,
Jun 8, 2017, 1:02:05 PM6/8/17
to Closure Compiler Discuss
Can you try?
create_source_map: 'example.map'

It's possible the compiler doesn't like the path characters. You can also use a variable '%outname%.map'

Chad Killingsworth

Wills Bithrey

unread,
Jun 9, 2017, 4:01:33 AM6/9/17
to Closure Compiler Discuss
Hi Chad,

Thanks for the suggestion. Unfortunately that didn't seem to help. I suspected that maybe the map was being generated but not output to the same directory as the bundle, however I don't see "example.map" anywhere in my project directory.

I hacked in some logging to google-closure-compiler/lib/node/closure-compiler.js to try and help the debugging so that I could check that create_source_map was definitely getting passed to the compiler:


























Now when running my build, I get the following log in my console (i've redacted some project specific names/paths)

java -jar /Users/<username>/Development/<project_name>/node_modules/google-closure-compiler/compiler.jar --compilation_level=SIMPLE --language_in=ECMASCRIPT6 --language_out=ECMASCRIPT3 --dependency_mode=STRICT --module_resolution=NODE --warning_level=DEFAULT --generate_exports=true --create_source_map=example.map --process_common_js_modules=false --entry_point=./static/src/js/main.app.js --js_output_file=js/main.app.js --json_streams BOTH

As you can see the --create_source_map=example.map flag is passed as expected. 

Do you think it's possible that the sourcemap support is incompatible with one of the other flags I'm using, e.g. --module_resolution=NODE?

Thanks for your assistance,

Wills.

Wills Bithrey

unread,
Jun 13, 2017, 4:53:29 AM6/13/17
to Closure Compiler Discuss
Sorry to bump this, however do you have any other inkling on what might be causing this? 

I've created a reduced test case (make sure to use the sourcemaps branch if you clone it) that has the same problem as my "real" project. When I run gulp build in this test case I get the built JS output in dist/js/output.min.js but no sourcemap.

My Java version can be seen below, in case that's helpful.

$ java -version:

java version "1.7.0_51"
Java(TM) SE Runtime Environment (build 1.7.0_51-b13)
Java HotSpot(TM) 64-Bit Server VM (build 24.51-b03, mixed mode)

Many thanks,

Regards,

Wills

Wills Bithrey

unread,
Nov 28, 2017, 4:11:28 AM11/28/17
to Closure Compiler Discuss
This still seems to be happening with the 20171112.0.0 release of the google-closure-compiler package on NPM.


On Thursday, 8 June 2017 17:35:17 UTC+1, Wills Bithrey wrote:

Chad Killingsworth

unread,
Nov 28, 2017, 7:05:28 AM11/28/17
to Closure Compiler Discuss
I posed on the issue you filed (I finally had enough information to answer). Gulp usage assumes the gulp sourcemaps plugin:  https://www.npmjs.com/package/gulp-sourcemaps

Chad

Wills Bithrey

unread,
Nov 29, 2017, 2:41:10 AM11/29/17
to closure-comp...@googlegroups.com
Indeed, thanks so much Chad. Apologies for not getting you all the info sooner.

Thanks again


--
Wills Bithrey
p.ota.to

--

---
You received this message because you are subscribed to the Google Groups "Closure Compiler Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to closure-compiler-discuss+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/closure-compiler-discuss/098fb2ce-c5b2-4c2d-a5d9-84b302699637%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages