Converting an existing Backbone.js project to Require.js
ozkatz.github.io
Converting an existing Backbone.js project to Require.js
1–10 of 34 posts
Re: Converting an existing Backbone.js project to Require.js
#2Re: Converting an existing Backbone.js project to Require.js
#3Re: Converting an existing Backbone.js project to Require.js
#4I thought Backbone and Require were 2 separate things?
Re: Converting an existing Backbone.js project to Require.js
#5Instead, RequireJS yielded a fairly verbose and error-prone header* coupled with large and distinct JS downloads for each and every page. Add in Backbone's verbosity and it's boilerplate and hand-wiring all the way down. Just the kind of thing for when you want to handcraft an artisan website, but not so great for cranking out code.
* Good luck catching typos when you're pulling in 20 modules and you lose synchronization between the strings and the vars. Here's a simple example:
define([
'jquery',
'handlebars',
'backbone',
'mymodel',
'mycontrolleranimals',
'mycontrollerpeople',
'myview_cats',
'myview_dogs',
'myview_birds'
],
function(
$,
Handlebars,
Backbone,
MyModel,
MyControllerAnimals,
MyControllerPeople,
MyViewDogs,
MyViewCats,
MyViewBirds) {
Sure, you caught the error because you were looking for it, but what happens in a RequireJS application is that you get weird errors in your application because you were trying to use the MyViewDogs, but myview_cats was actually bound to that variable.To be perfectly honest, I didn't build the system, so don't that it was configured correctly.
Re: Converting an existing Backbone.js project to Require.js
#6I'm really puzzled by the enthusiasm around RequireJS. I've read up on it, I've built several large JS applications (~100 models, views, whatevers in ExtJS and Knockout), have been involved with a large BackboneJS/RequireJS application and am currently rebuilding a large site in AngularJS. AFAICT, RequireJS did not solve any problems that I had more easily solved with proper namespacing (yes, the feared global , e.g.…
You should look into Dojo Toolkit source code, which now is almost entirely built on AMD.
Regarding "distinct JS downloads for each and every page": again, look at Dojo Toolkit source code and its build system.
Re: Converting an existing Backbone.js project to Require.js
#7I'm really puzzled by the enthusiasm around RequireJS. I've read up on it, I've built several large JS applications (~100 models, views, whatevers in ExtJS and Knockout), have been involved with a large BackboneJS/RequireJS application and am currently rebuilding a large site in AngularJS. AFAICT, RequireJS did not solve any problems that I had more easily solved with proper namespacing (yes, the feared global , e.g.…
define(function (require) {
'use strict';
var Backbone = require('backbone');
var Handlebars = require('lib/handlebars/handlebars');
var someTemplate = require('text!component/templates/some-template.hbs');
http://requirejs.org/docs/whyamd.html#sugarRe: Converting an existing Backbone.js project to Require.js
#8I'm really puzzled by the enthusiasm around RequireJS. I've read up on it, I've built several large JS applications (~100 models, views, whatevers in ExtJS and Knockout), have been involved with a large BackboneJS/RequireJS application and am currently rebuilding a large site in AngularJS. AFAICT, RequireJS did not solve any problems that I had more easily solved with proper namespacing (yes, the feared global , e.g.…
> Care must be taken that the $inject annotation is kept in sync with the actual arguments in the function declaration.
> This method of annotation is useful for controller declarations since it assigns the annotation information with the function.
Re: Converting an existing Backbone.js project to Require.js
#9I'm really puzzled by the enthusiasm around RequireJS. I've read up on it, I've built several large JS applications (~100 models, views, whatevers in ExtJS and Knockout), have been involved with a large BackboneJS/RequireJS application and am currently rebuilding a large site in AngularJS. AFAICT, RequireJS did not solve any problems that I had more easily solved with proper namespacing (yes, the feared global , e.g.…
define(function(require) {
var $ = require('jquery'),
Handlebars = require('handlebars'),
Backbone = require('backbone'),
MyModel = require('mymodel'),
MyControllerAnimals = require('mycontrolleranimals');
Also require.js comes with an optimizer that automatically concatenates all required files (and no more!) minifies them and you don't have to worry about script order. Also using the text plugin you can package templates (text files) along with the rest of the scripts.Re: Converting an existing Backbone.js project to Require.js
#10I'm really puzzled by the enthusiasm around RequireJS. I've read up on it, I've built several large JS applications (~100 models, views, whatevers in ExtJS and Knockout), have been involved with a large BackboneJS/RequireJS application and am currently rebuilding a large site in AngularJS. AFAICT, RequireJS did not solve any problems that I had more easily solved with proper namespacing (yes, the feared global , e.g.…