Skip to content

Closure Compiler support in minification mode only #70

Description

@alexflav23

Hi,

I wanted to confirm something before moving forward with an API proposal and hopefully a pull request very soon.

The problem

In Google Land, high upon the mountains, the laws of JavaScript dictate one should use adequate package management, with an a-la Java type provisioning system built with 2 compiler primitives, namely goog.require and goog.provide.

This is perhaps the most powerful feature the Closure Compiler has to offer, and to the best of my knowledge the sbt-js plugin is completely ignoring it by feeding in JavaScript sources to the compiler in parallel for minification only.

Conversely, using the Compiler directly in the "intended" way generally means, beyond the tedious annotations, working with a deps.js file, sub-modules that are auto-included, and a very advanced automated dependency generation and compilation system, dead code elimination, etc.

Without further ado, I would like to have:

In the following file: users/users-service.js

goog.provide('myapp.users.UserService');

/**
 * @constructor
 * @ngInject
 */
myapp.users.UserService = function($q, $http) {
  ..//etc
}
goog.addSingletonGetter(myapp.users.UserService);

And then in: users/users-controller.js

goog.provide('myapp.users.UserController');
goog.require('myapp.users.UserService');

Why would I go through all this trouble? Well, in an ideal world the compiler would then take care of every single .js output file and I would only include the single generated file, just like in the Java world all I need to worry about is a .jar.

Proposed solution

sbt-js should have a mode of feeding JS sources in the Google-esque way, where files are not individually compiled, but rather the entire output is fed to the compiler call in a single go via --input directives and a single output file(or one file per module) is being compiled and generated under a specified path.

For people who are committed to the Closure Compiler beyond simple minification, this seemingly simple change does introduce a new world of productivity, where you no longer need to include a thousand JS scripts in your header manually.

Is this something that's actively being considered or that you would happily merge as adjacent functionality?

Regards,

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions