#11 ✓invalid
Martin Kleppe

Splitting Up Files for Development

Reported by Martin Kleppe | February 23rd, 2009 @ 10:31 AM

The concatenation is fine for production use. But if we debug JavaScript based application it is necessary to spit up files. If an error occurs in browser Firebug and other development tools will point to the specific source file and line number.

An option "development=true" or "concatenation=false" would be sweet!

Comments and changes to this ticket

  • Tys von Gaza

    Tys von Gaza February 23rd, 2009 @ 06:25 PM

    This would be useful too if one is using Passenger for development. Each time a new passenger instance has to start up it seems to regenerate the sprockets.js file. For us this takes about 100 seconds (not sure why it is so slow), which gets old after awhile.

    Anyone else have this issue with Passenger, any advice so this doesn't happen? I'm not touch any js files, but I might have some plugins like ActiveScaffold, that copy their assets to public/javascript each time rails starts up.

  • Tys von Gaza
  • Sam Stephenson

    Sam Stephenson February 23rd, 2009 @ 07:12 PM

    • State changed from “new” to “invalid”

    There are a number of reasons it's not possible to write out a script tag for each source file:

    1. Source files are preprocessed. Constant interpolation in source files would raise a syntax error.

    2. Require directives can occur at any point in a source file. Consider the case where you define a variable, then require a second file after its definition that depends on that variable being set. If we wrote out script tags, the second file would be loaded before the first, causing a runtime error.

    3. Source files can live outside of the document root by design. Script tags will only load files inside the document root.

    Source line annotations will solve the problem of mapping a line in the concatenation to its original source file during development.

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

JavaScript dependency management and concatenation
<a href="http://getsprockets.org/">http://getsprockets.org/</a>

Tags

Pages