Closed agis closed 9 years ago
This is most probably a path issue but I'm not yet sure why it happens.
After some further investigation, I've found that in 0.9.2 (a working version that successfully compiles the assets), the temporary rjs_driver.js
file (my_app/tmp/rjs_driver.js
) has an extra snippet regarding baseConfig
and also contain the proper paths for each of the modules in question (application_desktop
etc.):
// generated rjs_driver.js file using 0.9.2
// ...
// Function used to mix in baseConfig to a new config target
function mix(target) {
for (var prop in baseConfig) {
if (baseConfig.hasOwnProperty(prop)) {
target[prop] = baseConfig[prop];
}
}
return target;
}
var module_specs = [
{
"name": "application_desktop",
"out": "/home/staging/public/assets/application_desktop.js" // <-- CORRECT
},
{
"name": "application_tablet",
"out": "/home/staging/public/assets/application_tablet.js"
},
{
"name": "application_mobile",
"out": "/home/staging/public/assets/application_mobile.js"
},
Now, compare this with the generated file when using 0.9.5, a version that causes the asset compilation to fail (notice the comments I've added):
// generated rjs_driver.js file using 0.9.5
// ...
// NOTICE! The mix() function doesn't exist anymore!
// NOTICE! The paths are missing!
baseConfig.modules = [
{
"name": "application_desktop" // <-- OOPS! Output path (`out`) is missing
},
{
"name": "application_tablet"
},
{
"name": "application_mobile"
},
Not sure if the output paths are an issue, but I think the baseUrl
not being taken into account in 0.9.5 is the culprit.
Apparently, after https://github.com/jwhitley/requirejs-rails/commit/878516272d45d263c32d4fe12fb1409956c63354#diff-d678a8a60f5428d7f354e0856743c206R20 the source path has changed, so I've also had to update the initializer to reflect the new default path.
@agis- Nice find! Why were you depending on the source staging path anyways?
@carsomyr I guess because scripts that use requirejs are placed in app/assets/javascripts/rjs/
and without that initializer the source_dir
is incorrectly set to /home/staging/tmp/assets
(it should really be home/staging/tmp/assets/rjs
) so asset compilation fails.
Not sure if that makes sense to you.
Hello.
I'm on a Rails 3.2.22 application and using requirejs-rails 0.9.0 for a long time everything is fine. However, after upgrading to 0.9.5, I get the following error while deploying:
Here are the relevant parts from
requirejs.yml
:The file in question is located at
app/assets/javascripts/rjs/application_desktop.js.coffee
.Note that I also have the following initializer:
Note that compilation is fine with 0.9.0, 0.9.1 and 0.9.2. Also, it fails with the same error in 0.9.8.
Thanks.