Open thany opened 8 years ago
What does your gulp.src()
look like? You should probably try to use the option object to set the base
. Have a look at the example in the readme
Doesn't really matter, now does it? the .
mean to look in the directory where the caller is located. That doesn't really have anything to do with any base url.
But if you think it'll help, my src
is set as ['source/js/**/*.js']
. I've also tried just ['source/js/main.js']
which makes it unable to find a whole bunch of other includes. Really strange, since main.js is the entry point, so I don't know why that makes any difference for how it searches for the includes.
Further, setting base
to source
or source/js
also makes it unable to find includes, differing ones again.
But no matter how you put it, .
should mean "current directory", regardless of anything.
Update: I got it working. But with so many places where a dir, subdir, option or something else could be missing or must be provided, I have no clue why I got it working. I don't think I changed anything.
I hope this won't be another Grunt problem (which I thouroughly hate) where it 'suddenly' works and I add a comment promising to punish anyone who touches anything :)
ah, sorry, unfortunately relative module loading doesn't work very well, so you can't really do require('./app', ...)
. This tool is designed for frontend website stuff, and so it might not map very well to what you are used to from for example CJS, unfortunately :-/
I suggest you use absolute urls from some base place all the time, and that you include .js
in the path you require. I haven't tested how it works without these, so I can't guarantee that it will work. If you want to help me make it work I would love your thoughts on it!
Eh, sorry, now I'm confusing myself! You shouldn't have the .js
, obviously. But, relative modules are still not recommended with AMD.
It seems as if it always tries to load a module from the baseUrl:
But
app.js
is insource\js\app.js
, next tomain.js
. That's what./app.js
means.Before amd-optimizer it works fine, when I let require.js do it's thing just in the browser.