Issue #86 new

fanstatic-compile minifies everything twice

created an issue

Not a show-stopper but:

fanstatic-compile is minifying my resources twice on every run. This does not hurt, except that (using closure, at least) it is slow and so a painful waste of time.

What is happening: _compile_resources calls Resource.compile for all resources (i.e. both the minified and parent version of each resource). However, when .compile is called for the minified version, that, in turn, calls .compile for its mode_parent. This results in the parent being compiled twice.

I'm not sure what the best fix is for this. (Is it really required that .compile for a child resource needs to call .compile for the parent, or should the user be responsible for finding the parent and calling compile on that?)

Another nit: because the logging output generated by fanstatic-compile -v logs compilations by the NullCompiler in a manner indistinguishable from “real” compilations, its hard to tell what, exactly, is being compiled/minified.

Again, unsure as the the best fix. I guess NullCompiler could provide its own __call__ method which does nothing (not even logging). If it were me, I think I'd do away with NullCompiler altogether and just set .compiler (and .minifier) to None when there is no compiler/minimizer.

(It would probably be useful to log which compiler/minifier is being used for each compilation.)

Third nit: fanstatic-compile foo also compiles resources for package foo_bar.

Suggestions for other usability improvements

(Sorry to dump these all on one ticket. I just wanted to write them down somewhere while fresh in mind. Let me know if you'd rather have umpteen separate tickets.)

Direct specification of compiler

Allow direct specification of a compiler/minimizer instance without having to configure a setuptools entry point. E.g. to specify one-off special compilation for just one or a few resources, I'd like to be able to do:

# construct custom minifier
CLOSURE_ADVANCED = fanstatic.compiler.Closure()
CLOSURE_ADVANCED.arguments = ['--compilation_level', 'ADVANCED_OPTIMIZATIONS']

# use it
some_js = Resource(library, 'js/some.js', minimizer=CLOSURE_ADVANCED)

Compile multiple packages in one go

Allow specifying multiple package to fanstatic-compile. E.g.

fanstatic-compile some.package other packages

Comments (3)

  1. Log in to comment