Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhancement: change compilation levels for certain files. #13

Open
devinrhode2 opened this issue Nov 21, 2012 · 4 comments
Open

Enhancement: change compilation levels for certain files. #13

devinrhode2 opened this issue Nov 21, 2012 · 4 comments

Comments

@devinrhode2
Copy link
Contributor

In trying to successfully use advanced compilation for a project but one of my dependencies flat out breaks when I use advanced compilation, and there's not much I can swiftly do about it. I can use advanced compilation on my stuff just fine, but need to use simple compilation for my other dependency.

Not an easy thing to do my any means, but I just wanted to write it down somewhere relevant.

@devinrhode2
Copy link
Contributor Author

Ok going to submit a PR for this... but first let's agree on an API:

I'm using advanced compilation, and only need one file compiled with the simple option, so this is the api I started writing:

grunt.initConfig({
  'closure-compiler': {
    frontend: {
      js: manifest.background.scripts,
      simple: ['node_modules/twitter-text/twitter-text.js'],
      jsOutputFile: 'compiled/background.cc.js',
      maxBuffer: 500,
      options: {
        'compilation_level': 'ADVANCED_OPTIMIZATIONS',
        'language_in': 'ECMASCRIPT5_STRICT',
        'externs': require('fs').readdirSync('./build/cc-externs')
      }
    }
  }
});

Now, I could see how someone would mostly use simple compilation and want advanced compilation for a few files where possible. So we could make an identical option to my simple

@gmarty
Copy link
Owner

gmarty commented Nov 21, 2012

To be honest, I prefer to keep this tool as simple as possible. What's great with Grunt is that you can actually automatize such tasks.
What about compiling your code and dependencies apart and then merging together with another task? This is very easy to do with Grunt.

And of course, the other way would be to contribute advanced optimizations compatible versions of your dependencies.

@devinrhode2
Copy link
Contributor Author

How could I basically say...

grunt.runMoreStuff({
    'closure-compiler': {
      frontend: {
        js: manifest.background.scripts,
        jsOutputFile: 'compiled/background.cc.js',
        maxBuffer: 500,
        options: {
          'compilation_level': 'ADVANCED_OPTIMIZATIONS',
          'language_in': 'ECMASCRIPT5_STRICT'
        }
      }
    }
});

Any idea?

@gmarty
Copy link
Owner

gmarty commented Dec 4, 2012

You should probably do something like this:

grunt.initConfig({
  'closure-compiler': {
    advanced: {
      js: manifest.background.scripts,
      jsOutputFile: 'compiled/background.cc.js',
        options: {
          'compilation_level': 'ADVANCED_OPTIMIZATIONS'
        }
    },
    simple: {
      js: manifest.api.scripts,
      jsOutputFile: 'compiled/api.cc.js',
      options: {
          'compilation_level': 'SIMPLE_OPTIMIZATIONS'
      }
    },
  }
});

Then, find or develop a task to concatenate compiled/background.cc.js and compiled/api.cc.js.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants