-
Notifications
You must be signed in to change notification settings - Fork 673
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
node r.js -o build.js with no appDir duplicates baseUrl directory #20
Comments
This is done in case there will be dynamic loading from the baseUrl. If you just want one output file, see Optimizing one JavaScript file. If that is not what you are looking for, please feel free to reopen this issue with more info. |
Hey, thanks for getting back to me so quickly! Optimizing one JS file is nice for doing exactly that.., however I'm more interested in exporting out a library I've written. Naturally it's only What I have:
So what I've done so far is create a new Finally, despite the fact that all the files have been concatenated into one I still needed to use My main file looks like this:
I apologize for telling the longer story... What I'm really interested in is understanding how to take |
Yes, you can use a build.js for the commands, just change them to object name/properties. So name=value becomes name: 'value' (if value is a string) in the build.js file. For your main use case, that was one of the goals with almond. However to use almond, you will need to use this r.js snapshot -- it has some changes that have not made it out in a release yet (but they will be part of the upcoming 0.27.0 release). I did not quite follow the issue with underscore and such. Maybe if you can show me more of the project layout that may help. And just to confirm, underscore-min.js is an unmodified version of underscore? Or, if you were not using the aforementioned r.js snapshot, using that first. One thing to note: the build profile requires the paths settings in the build profile. It will not read the config in your main.js file -- this is done because it is common that the build layout is different from the runtime layout. |
Cool — I'll give these a try and keep you posted. Just to confirm I would use r.js snapshot instead of r.js for almond use? Like The comment about underscore was just that I'm renaming it and as a result leaves for some additional path params in the options when optimizing. It's unaltered pull of underscore. Just to be clear I'm using it like:
Finally, I did notice and is duly noted that r.js neglects the config in main.js. I like that decision. Thanks so much for the help! |
On Fri, Sep 23, 2011 at 8:40 AM, Jono Brandel
Yes, exactly.
OK, looks pretty standard. |
Thanks so much for the help! I was able to get it up and running! I had to make an interesting modification to main.js in order for my usage of the
and here's the modified main.js that builds to my library:
upon further inspection in almond. The fourth parameter in |
What you could do instead is to just use define() instead of require() in main.js (I'm assuming that is the only non-configuration require() call in main.js). That way the code would be a bit more portable and not depend on a non-standard require() signature that AMD uses for expediency/small download size. In general though, the issue is because there is an assumption that with page load means all scripts/modules are defined. That is not necessarily the case with AMD modules, in fact normally it is not. But if your primary use case is to just use AMD modules for internal development but just surface a built script to users where everything is defined up front, then what you did makes sense. And in that scenario I would just use define() in the main.js file. |
Cool, thanks so much for the help! I'll give this a go. |
From the example build configuration file it seems to state that if you left out
appDir
that no files except the output minified file would be indir
. However it seems to take the contents ofbaseUrl
and places it intodir
along with the built script.As a result I tried
appDir: ""
andappDir: path/to/empty/folder
and both give the same result as above. Is there a way to run r.js and output 1 file containing the module specified and all it's dependencies?The text was updated successfully, but these errors were encountered: