thanpolas / grunt-closure-tools

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

Specifying builder source files in arguments #57

Closed probins closed 10 years ago

probins commented 10 years ago

With closureBuilder, as well as (or instead of) specifying source directories in --root params, I can also specify individual source files as arguments. This ability seems to be missing in the Grunt task.

thanpolas commented 10 years ago

i doubt that. Which closureBuilder option are you referring to? Share some examples.

Did you read the docs for all the available options for the builder task?

probins commented 10 years ago

see --help:

"Paths to files can be expressed as individual arguments to the tool (intended for use with find and xargs). As a convenience, --root can be used to specify all JS files below a directory.

usage: closurebuilder.py [options] [file1.js file2.js ...]"

thanpolas commented 10 years ago

Indeed i see that's missing.

Do you require it? What is the use case? How do you imagine this being implemented in the config?

probins commented 10 years ago

my main use case is where you have a directory with several source files, and you only want to build one of them. The workaround at the moment is to put each source in a separate directory and use --root=dir, but this is not optimal.

thanpolas commented 10 years ago

is there a particular reason the closureCompiler task will not work for you?

probins commented 10 years ago

compiler only has limited ability to create a dependency tree. My source requires files from Closure library and from other 3rd-party code, so I create a build with the full dependencies with closureBuilder, and then pass that to the compiler

thanpolas commented 10 years ago

right...

so what i'd suggest for you is to work with namespaces. Make sure each bootstrap file has its own unique namespace, direct closureBulder to scan you entire dir tree and set the starting point to the specific namespace that you want to build. See options. namespaces

thanpolas commented 10 years ago

It's been some time since i last did significant work on this so i tend to forget, i just noticed in the docs this example:

             * E.g. for
             *   files: [
             *      {src: 'lib/a.js', dest: 'build/a.min.js'},
             *      {src: 'lib/b.js', dest: 'build/b.min.js'},
             *    ],

Which i think is what you were originally looking for?

probins commented 10 years ago

er, that example is for source maps

thanpolas commented 10 years ago

yes but it's derived from an actual way to define files. Did you try it?


Thanasis Polychronakis

http://thanpol.as/

On Wed, Feb 19, 2014 at 1:49 PM, Peter Robins notifications@github.comwrote:

er, that example is for source maps

— Reply to this email directly or view it on GitHubhttps://github.com/thanpolas/grunt-closure-tools/issues/57#issuecomment-35490557 .

probins commented 10 years ago

yes but it's derived from an actual way to define files.

for the compiler. You define individual source files for the compiler, but if you try putting a file path in the src option for builder, you get a 'not a directory' error.

However, I think you are right when you say I can define a namespace together with my source directory to get what I want without the need for using the arguments array. So I will close this now; if I find I still have issues, I'll reopen.