thanpolas / grunt-closure-tools

Google Closure Tools for grunt
MIT License
95 stars 22 forks source link

New option in `compilerOpts` that allow direct control of the gcc command options. #39

Closed vogdb closed 11 years ago

vogdb commented 11 years ago

Right now there is a lot of the gcc options which are not covered by this plugin. For example --module, --transform_amd_modules, --module_output_path_prefix options. Because there are so many of them I suggest that instead of adding the correspond option for each of them to add only one new option that will allow direct adding of the gcc options to the generating gcc command. Let's call this new option manualControl. Then example usage of it will be:

  ,delete: {
     TEMPcompilerOpts:{
       manualControl:'--module first:2 second:1:first --module_output_path_prefix="dist"'
     }
    ,src: ['plugins/ZoomButtons/*.js']
    ,dest: 'dist/canvas-interaction-zoom-buttons.min.js'
  }

Will generate the next cmd:

java -jar node_modules/superstartup-closure-compiler/build/compiler.jar --js plugins/ZoomButtons/ZoomButtons.js --js_output_file=dist/canvas-interaction-zoom-buttons.min.js --module first:2 second:1:first --module_output_path_prefix="dist"

What do you think about this option?

thanpolas commented 11 years ago

Please read the docs more carefully.

All and every GCC option is supported. You just have to add it under the compilerOpts key.

vogdb commented 11 years ago

Sorry, missed this. Also --module option confused me. Because I had to have a lot of them I couldn't figure out how do it. Obviously I couldn't write something like this:

compilerOpts: {
    module: 'first:2'
    module: 'second:1:first'
}

Now I figured out how to make multiple modules in the generated cmd.

compilerOpts: {
    module: 'first:2 --module second:1:first'
}

IMO this is kind of a hack but it is working.

thanpolas commented 11 years ago

@vogdb at that point i typically decouple everything and make the configuration a bit more dynamic... e.g.

var modules = [];
modules.push('first:2');
modules.push('second:1:first');
/* ... */
var useModules = modules.join(' --module ');

compilerOpts: {
    module: useModules
}

you can be creative with that...

vogdb commented 11 years ago

Thanks! Will keep this in mind.