-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove dependency on
window
throughout Ember
Previously, Ember used the `window` object for three concerns: * `imports`: libraries that Ember requires in order to work, such as `jQuery`, `Handlebars`, and `Metamorph` * `exports`: the variables that Ember itself exports (`Ember` and `Em`) * `lookup`: the global lookup path for application code (e.g. when used in Handlebars templates). Now, these three concerns are looked up on `Ember.imports`, `Ember.exports` and `Ember.lookup` respectively. For convenience, all three of these are assigned to `window` by default. You can change the defaults by assigning a new Ember object before loading Ember: ```javascript var imports = { Handlebars: Handlebars, Metamorph: Metamorph, jQuery: jQuery }; var exports = {}, lookup = {}; Ember = { imports: imports, exports: exports, lookup: lookup } ``` You can use this to package Ember for external module loaders like AMD: ```javascript define("Ember", ["exports", "App", "handlebars", "metamorph", "jQuery"], function(exports, App, Handlebars, Metamorph, jQuery) { var imports = { Handlebars: Handlebars, Metamorph: Metamorph, jQuery: jQuery }; var Ember = { imports: imports, exports: exports, lookup: { App: App } } // distributed ember.js }); define("App", [], function() { return {}; }); define("Post", ["App", "Ember"], function(App, Ember) { App.Post = Ember.Object.extend({ // stuff }); }); ``` You can use a similar technique to package Ember Runtime for Node or other environments with CommonJS-style modules.
- Loading branch information
Showing
33 changed files
with
306 additions
and
196 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
305202f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! This helps encapsulation in our project a lot 👍
305202f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kitsunet Awesome!
305202f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great coding, @wycats!
305202f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, I'm pretty new to Ember. I'm interested in packaging it for Require/AMD, but I'm not sure what this commit description "means" in practice. In the
define('Ember'
call, where does"exports"
come from, and where/when/how does this define call return a module? Does anyone have a working example of loading Ember via AMD in this way? Does this also keep Handlebars and jQuery out of the global namespace? Is there a way to do that?