Complex require escenario #422

Closed
outaTiME opened this Issue Mar 22, 2013 · 2 comments

Comments

Projects
None yet
3 participants
@outaTiME

Hi Sam,

Its possible to resolve this scenario with sprockets v2 ?? im come from v1.0.2 and that code works like a charm ...

//= require foo/platform/desktop/plugins/notificator

if (Foo.Platform.Desktop.Core.Utility.isGoogleMaps2()) { // no google maps v3
//= require foo/platform/desktop/plugins/arrow
//= require foo/platform/desktop/plugins/heading
//= require foo/platform/desktop/plugins/notification
//= require foo/platform/desktop/plugins/image
//= require foo/platform/desktop/plugins/cluster
//= require foo/platform/desktop/plugins/polyline
//= require foo/platform/desktop/plugins/tools
//= require foo/platform/desktop/plugins/geoserver
}

if (Foo.Platform.Desktop.Core.Utility.isGoogleMaps3()) { // no google maps v2
//= require foo/platform/desktop/plugins/map
}

//= require foo/platform/desktop/plugins/search
//= require foo/platform/desktop/plugins/sensor

its any way to resolve this ?? im using rake module ...

thks!

@STRd6

This comment has been minimized.

Show comment Hide comment
@STRd6

STRd6 Apr 22, 2013

For Sprockets v2 you'll need to move all of your require statements to the top. Sprockets was never able to conditionally require files at compile time based on runtime conditionals.

The reason it worked previously was that Sprockets v1.0.2 executed every require statement and didn't mandate that they be at the top.

If you really do need runtime dependency management you could look into another tool, but you'd still need to package up all of your scripts anyway so that any potential runtime would have access to them.

Eliminating the conditionals and moving the #= requires to the top should solve your problem.

STRd6 commented Apr 22, 2013

For Sprockets v2 you'll need to move all of your require statements to the top. Sprockets was never able to conditionally require files at compile time based on runtime conditionals.

The reason it worked previously was that Sprockets v1.0.2 executed every require statement and didn't mandate that they be at the top.

If you really do need runtime dependency management you could look into another tool, but you'd still need to package up all of your scripts anyway so that any potential runtime would have access to them.

Eliminating the conditionals and moving the #= requires to the top should solve your problem.

@josh

This comment has been minimized.

Show comment Hide comment
@josh

josh Feb 9, 2014

Contributor

For Sprockets v2 you'll need to move all of your require statements to the top. Sprockets was never able to conditionally require files at compile time based on runtime conditionals.

yep

Contributor

josh commented Feb 9, 2014

For Sprockets v2 you'll need to move all of your require statements to the top. Sprockets was never able to conditionally require files at compile time based on runtime conditionals.

yep

@josh josh closed this Feb 9, 2014

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