javascript - Difference between "Q" and "q" in angularjs and requirejs -


i creating single page app built on angularjs, breeze, , requirejs. in setting amd requirejs work angular , breeze, encountered issue breeze's dependency on "q". if configuration rule "q" lowercase, if there no explicit export in "shim", breeze gives error:

uncaught error: unable initialize q. see https://github.com/kriskowal/q "http://localhost:1498/scripts/shared/breeze.js"breeze.js:1` 

when require config changes references "q" "q" (even without export), code works. know why happening?

this working require config:

require.config({     baseurl: '../scripts',     paths: {         angular: 'shared/angular',         bootstrap: 'shared/ui-bootstrap',         dropdowns: 'app/directives/dropdowns',         employeeapp: 'app/modules/employeemodule',         controllers: 'app/controllers',         dates: 'app/directives/dates',         jquery: 'shared/jquery',         q: 'shared/q',         breeze: 'shared/breeze',         config: 'app/services/config',         model: 'app/services/model',         dataservice: 'app/services/dataservice',         expenseinfo: 'app/services/expenseinfo'     },     shim: {         'angular': { 'exports': 'angular' },         'bootstrap': { deps: ['angular'] },         //'q': { 'exports': 'q' },         'breeze': { deps: ['q', 'jquery'], 'exports': 'breeze' }     },     priority: [ 'angular', 'bootstrap', 'dropdowns', 'jquery',                 'q', 'breeze', 'employeesearch', 'dates' ] }); 

technical reason breeze explicitly looks "q". find breeze requires search 'requirelib' (not whole word) in source.

breeze looks global first, , since q's global 'q' that's breeze searches for

more background: (yes i've been experiencing breeze + requirejs pain lately)

fortunately can change require path. knockout + durandal not work. breeze requires 'ko', durandal requires 'knockout'. workaround use requirejs map:

map: {     //knockout used durandal, ko used breeze  --> anytime ko requested, substitute knockout     '*': { 'ko': 'knockout' } } 

breeze have problems requirejs dependencies, because not predefine dependencies (no dependencies listed in define call). because of dependencies configurable (you don't want knockout, do). that's why need shim ensure loaded before breeze requests them.

jquery has unusual amd behaviour. libraries amd libraries when run. if find amd library (e.g. requirejs) load (e.g. define( ... )), , skip loading global. jquery both if can (for reasons). means breeze sees , loads global jquery, no need create map breeze's 'jquery' requirejs's 'jquery'.

btw "even without export" irrelevant. export property in shim used to: once loaded, use global 'breeze' module value. no point breeze sees requirejs, loads instead of global, , shim ignores export.


Comments

Popular posts from this blog

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -

java - JavaFX 2 slider labelFormatter not being used -