teamcfadvance / cfstatic

CfStatic is a framework for managing the inclusion and packaging of CSS and JavaScript in CFML applications.
https://teamcfadvance.github.io/cfstatic
MIT License
102 stars 35 forks source link

When an error occurs, cfstatic silently does nothing. #96

Closed boughtonp closed 9 years ago

boughtonp commented 11 years ago

In some scenarios, something causes cfstatic to fail processing, but no error is thrown or logged - it simply fails to generate a complete JS file and does not output a script tag.

The partially generated JS file includes references to JS files which have not been included nor specified as dependencies, despite IncludeAllByDefault being set to false.

Setting the debug URL parameter does not appear to have any effect - no script tags are rendered.

DominicWatson commented 11 years ago

Curious, I've not seen anything like this before. Will need some more info.

Firstly though, the calling of the include() method has no effect whatsoever on the compilation and minification of files. The two are completely independent of each other. Compilation will happen once on init() of cfstatic + also once per request if checkForUpdates is set to true and files have changed (should not be used in Production).

Are you seeing a concatenated and minified file have parts missing? Part of a file? Can you gather any info from the point at which the file is incomplete (i.e. a list of files being concatenated + the point at which it fails in that list)?

Thanks in advance,

Dominic

boughtonp commented 11 years ago

Can you clarify your second paragraph - does it mean that (when wanting to cherry pick files) it's correct/valid to exclude all files in the init call (or is that what IncludeAllByDefault=false should do?), and if that is done they'll only get inspected zero or one times, when renderIncludes is executed (depending on CheckForUpdates)?

I'll have to get back to you on the rest - from what I remember it looked like it had completed four or five files, but I'm not certain on that (or on which ones). I suspect the issue might have been something like YUI tripping up on effectively having duplicate files (i.e. x.js and x.min.js) - we have a number of those in the JS directory (needs cleaning up, but that's not a priority at the moment), but it also might have been something else - will probably be a while before I can check more.

DominicWatson commented 11 years ago

This is something the docs need to work on - i.e. the clarity of what is going on here. I think people come with a preconception of what is happening that is really far from what is happening.

On init(), the engine scans your static directory and:

  1. precompiles any .less and .coffeescript files
  2. depending on your minifyMode setting, concatenates files (see http://fusion.dominicwatson.co.uk/2011/09/understanding-the-package-minify-mode-in-cfstatic.html)
  3. minifies the concatenated files

So the minified files you see in the min directory are generated before include() is ever called. When in "package" or "all" minify modes, files will be concatenated and CfStatic figures out the order to do that in based on dependencies and falling back to file name ordering.

The 'includeAllByDefault" setting is a bit annoying and the default will change at some point. The default setting is to include all static files when renderIncludes() is called after include() never being called. Horrid, I know. If you set the setting to false and call renderIncludes() without ever calling include(...), no scripts will be included.

Does that answer your question?

boughtonp commented 9 years ago

Heh, I'd forgotton about this.

I think I understand better how it works now.

Not sure if it's the same problem as before, but coming back to looking at it with a newer version, there's an error thrown this time - "invalid property id - the YUICompressor runs via Rhino which doesn't support reserved words as property names (see http://kangax.github.io/compat-table/es5/).

That means stuff like .css({ float : this.options.button_position }) causes it to fail until the float is quoted. Probably not something that cfStatic can fix, but fortunately only a handful of those to change.

I don't think there's any outstanding issue, so closing this.

Also, I just noticed Sticker, so will go have a look at that.