Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

ClosureBuilder root option problem. #14

Closed
awsick opened this Issue · 10 comments

2 participants

@awsick

When i try this tools i get this problem (bug).
In my grunt config i got setup for watch coffee scripts. After compile coffee file grunt runs closureBuilder.
When closureBuilder runs for first time all is ok.
But when this task runs for second time root option is empty so i get OSError: [Errno 2] No such file or directory: ''
Thx for answer.

@thanpolas
Owner

Can you please provide a sample of your grunt file and the complete error message you get?

You might want to check out saucer which is a bootstrap library that incorporates coffee script + closure tools and has a well defined flow.

@awsick
closureBuilder: {
            dev: {
                closureLibraryPath: 'libs/Closure/', // path to closure library
                builder: ['bin/build/closurebuilder.py'], // filepath to builder
                root: ['libs/Closure','doc_root/javascript/dev/'],
                namespace: 'refresh',
                inputs: ['doc_root/javascript/dev/*.js'],
                output_mode: '',
                compile: true, // boolean
                compiler: 'libs/Closure/compiler/compiler.jar', // the location of the compiler.jar
                output_file: 'doc_root/javascript/d.js',
                compiler_options: {
                    compilation_level: 'ADVANCED_OPTIMIZATIONS',
                    // externs: ['path/to/file.js', '/source/**/*.js'],
                    debug: true,
                    define: ["'goog.DEBUG=true'"],
                    warning_level: 'verbose',
                    jscomp_off: ['checkTypes', 'fileoverviewTags'],
                    summary_detail_level: 3,
                    //output_wrapper: '(function(){%output%}).call(this);'
                }
            }
}

here is it
i will try saucer.

@thanpolas
Owner

Thanks for the paste, can you please give me the full error message so i can see which file / lineno is breaking?

@awsick

https://gist.github.com/4267295

first part is successfull after first edit of coffee script file

second part is fail / error after second edit of coffee script file

@thanpolas
Owner

aha, i see now... uhmmm so how can the --root parameter be empty? This parameter is supposed to be read from your grunt file...

And from what i read in the code, there's a special validation going on that checks if the --root param is defined, if it isn't a proper error is raised... (not the one we are seeing here)...

I can't tell where this is coming from... can you help me a bit more please?

Does the builder operation run from the grunt watch automatically ?

what more can you tell me about your flow?

@awsick

my workflow is this -> watch *.coffee scripts.
On change make concat to one .coffee -> compile to tmp.js -> then this tmp.js set to inputs on builder task.
All this tasks are fired automatically.
when i change

var root = data.root;
  if (!root) {
    grunt.log.error('ERROR'.red + ' :: ' + 'root'.red + ' property is required');
    return false;
  }

to

var root = data.root;
  if (!root || root == '') {
    grunt.log.error('ERROR'.red + ' :: ' + 'root'.red + ' property is required');
    return false;
  }

validation thow error.

dont know if this flow is good for your task.
the most wired thing about this is only root parametr is missing :/
you can contact me on gtalk: awsick@gmail.com

@thanpolas
Owner

hmmm can you please try this:

var root = data.root;
  if (!root || root.trim() == '') {
    grunt.log.error('ERROR'.red + ' :: ' + 'root'.red + ' property is required');
    return false;
  }

can you also be more specific about how exactly this is implemented:

compile to tmp.js -> then this tmp.js set to inputs on builder task

I didn't see any variables in the closurebuilder grunt conf that you pasted... Do you mangle at all with the root param?

@awsick

trim can be done there because if root is array i get

TypeError: Object libs/Closure,doc_root/javascript/dev/ has no method 'trim'

Detailed flow:

doc_root/javascript/coffee/front.coffee is coffee source

goog.provide('refresh.front')
goog.require('goog.dom')
goog.require('goog.dom.query')
foo = 'bar'

for testing its like this.

when this file is changed i run few task

 frontconcat: {
                files: 'doc_root/javascript/coffee/*.coffee',
                tasks: 'concat:front coffee:app coffee:simple closureBuilder:dev closureBuilder:prod'
            }

coffee:simple task make this

 simple: {
                src: ['doc_root/javascript/coffee/*.coffee', 'libs/Coffee/*.coffee'],
                dest: 'doc_root/javascript/dev/'
            }

after this run closureBuiler:dev
this taks looks to doc_root/javascript/dev/*.js and try to build and compile all this js to one file doc_root/javascript/d.js
in this case doc_root/javascript/dev/front.js is

goog.provide('refresh.front');

goog.require('goog.dom');

goog.require('goog.dom.query');

foo = 'baddssfdssssddddddsd';
  dev: {
                closureLibraryPath: 'libs/Closure/', // path to closure library
                builder: ['bin/build/closurebuilder.py'], // filepath to builder
                root: ['libs/Closure','doc_root/javascript/dev/'],
                namespace: 'refresh',
                inputs: ['doc_root/javascript/dev/*.js'],
                output_mode: '',
                compile: true, // boolean
                compiler: 'refresh/Closure/compiler/compiler.jar', // the location of the compiler.jar
                output_file: 'doc_root/javascript/d.js',
                compiler_options: {
                    compilation_level: 'ADVANCED_OPTIMIZATIONS',
                    // externs: ['path/to/file.js', '/source/**/*.js'],
                    debug: true,
                    define: ["'goog.DEBUG=true'"],
                    warning_level: 'verbose',
                    jscomp_off: ['checkTypes', 'fileoverviewTags'],
                    summary_detail_level: 3,
                    //output_wrapper: '(function(){%output%}).call(this);'
                }
            }

all works like a charm only problem is and i dont know why >root< parameter is missing after second call.

@thanpolas
Owner

Ok, the problem is that when the builder is run from a grunt watch task, the root param gets reset.

Investigate / fix:
1. More validations of the root param (is array, are array elements proper strings)
2. Where root param gets reset

@thanpolas
Owner

Issue solved

@thanpolas thanpolas closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.