I'm having trouble using r.js to optimize modules in the bower_components/
directory.
My basic project directory structure looks like this:
- bower_components/
- src/
- activities/
- client/
...and the r.js configuration lists the following details:
({
appDir: 'src',
baseUrl: 'client',
dir: 'out',
modules: [
{ name: 'scripts/main' },
/* (+ more) */
]
})
I'd like to optimize the file
bower_components/socket.io-client/dist/socket.io
, which is outside the
baseUrl
. As recommended in the "Common Pitfalls" section of the Optimizer
guide, I'm trying to
define a path for the file:
({
appDir: 'src',
baseUrl: 'client',
dir: 'out',
+ paths: {
+ 'socket.io': '../../bower_components/socket.io-client/dist/socket.io'
+ },
modules: [
{ name: 'scripts/main' },
/* (+ more) */
+ { name: 'socket.io' }
]
})
...but this yields the following error:
Running "requirejs:prod" (requirejs) task
{ [Error: Error: Module ID 'socket.io' has a source path that is same as output path: /home/mike/projects/bocoup/cee/cee/bower_components/socket.io-client/dist/socket.io.js. Stopping, config is malformed.
at /home/mike/projects/bocoup/cee/cee/node_modules/grunt-contrib-requirejs/node_modules/requirejs/bin/r.js:26000:39
]
originalError: [Error: Module ID 'socket.io' has a source path that is same as output path: /home/mike/projects/bocoup/cee/cee/bower_components/socket.io-client/dist/socket.io.js. Stopping, config is malformed.] }
It seems like the point of the path
config indirection is so that the
optimizer will not attempt to create a file outside the output directory. At
the same time, this is clearly not happening. Am I doing something wrong? Or is
this not something r.js is capable of?
hi friend, i came across the problem too, as i saw you questioned long time back, could i know how did u solve this. thanks so much.