I've got a directory structure like so:
app/
├ js/
│ ├ gui/
│ │ ├ main.js
│ │ └ santa.js
│ └ app.js
└ index.html <- includes requirejs and starts js/app.js
app.js:
baseUrl: 'js' // Pseudo-code for requirejs.config() of course
require('gui/main');
So far so good. But every same-dir require()
in main.js
gives problems:
main.js:
require('santa')
Tries to require()
app/js/santa.js which does not exist.
require('./santa')
Tries to require()
app/js/santa.js which does not exist.
require('gui/santa')
Tries to require()
app/js/gui/gui/santa.js which does not exist.
require('./gui/santa')
Tries to require()
app/js/gui/gui/santa.js which does not exist.
The only way I seem to get my file to be included is like this:
require('js/gui/santa.js')
which kind of defeats the purpose of name resolving and the baseUrl
setting.
Apart from this weirdness, I'd like to have the baseUrl
changed to js/gui
for any require()
within main.js
. The configuration is supposed to be extensible and overwritable. But when I do:
requirejs.config({
baseUrl : 'js/layout'
});
within main.js
, the new setting seems to be ignored like politicians ignore their own promises.