Since I started I've learned quite a bit about it. It was a bit rough at first but forms a solid part of my toolkit now. I really find it hard to imagine JS development without it. It's like driving a Porsche without proper wheels... Just as frustrating. :) Besides providing nifty module syntax it allows you to optimize your project easily. Even though the project documentation is quite vast, it's pretty easy for a beginner to get lost in the detail. Before getting into actual application structure I'm going to cover some core concepts briefly. Fundamentals of RequireJS You can probably live without RequireJS in case you application isn't that big (say ~500 lines of code).
It allows you to separate your source code semantically into modules. The next snippet contains a few examples of possible module definitions to give you a better idea of what I'm talking about: Project Structure Source Structure. Use require.js without grunt · Issue #1 · tzellman/ember-todos. RequireJS AGAIN · Issue #2194 · emberjs/ember.js. Added a "loader" method in Ember.Router to be used to load files async by guilhermeaiolfi · Pull Request #2215 · emberjs/ember.js. AMD is Not the Answer : Tom Dale. Every so often, we get requests to make Ember.js support AMD (asynchronous module definition).
So, while James is both smart and I’m sure good-looking (and I agree with his comments on CommonJS), here are the reasons I think he is wrong about AMD. Build Tools Are Okay However, for those of us who came from Dojo, requiring a server tool or compile step to just develop in JS was a complication. I have a lot of respect for Alex but, if this is his current opinion, he’s wrong. Many HTTP Requests. Ninja Geddesign - AMD is the Answer. Eight Ember.js Gotchas With Workarounds - CodeBrief. Having used Ember.js for a few months now, I have compiled a list of gotchas that I have encountered.
Many of these will change/be fixed as Ember matures, but until then I hope these will serve as pre-emptive time savers for other developers. 1. Computed Properties and .cacheable() This one has actually been fixed in the lastest build of Ember, but I'm putting it here since it is still present in the latest 0.9.5 release. Consider the following object: It turns out that if you try and bind to the tags property of the above object, you will encounter an infinite run loop.
Even though the infinite loop issue has been fixed, making computed properties cacheable is generally a good idea and will be more the rule than the exception. Requirejs - ember.js and require.js. Upgrading to RequireJS 2.0 · jrburke/requirejs Wiki. Why There has been a good deal real world usage of requirejs, and there were some features around configuration that have come up that would be nice to add.
At the same time, there were some configuration options and internal features that have not held their weight, and it would be good to remove them. Support for the AMD APIs has not changed. If anything, I am hoping that the AMD loader implementers are starting to agree on higher level APIs, like common config. The changes were more around the configuration and internal operation of requirejs. However, since some configuration options have been removed, and some things about how modules are loaded and executed were changed, semantic versioning dictates that these changes warrant a 2.0 version. Primary Changes These are the primary changes: Delayed module evaluation In RequireJS 1.0, any built file with a bunch of define() calls in them will have all the modules executed once a top-level require call is hit.
Shim config It gets bad if order!