Skip to content
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

Initializers are required automatically #242

Merged
merged 1 commit into from
Apr 3, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
* Separate `tests` and `app` code. Tests are now within 'assets/tests.js' (#220).
* Implement `--proxy-port` and `--proxy-host` parameters to `ember server` command (#40)
* Add support for `.ember-cli` file to provide default flags to commands ([7b90bd9](https://github.com/stefanpenner/ember-cli/commit/dfac84ffd27acedfd18189a0e4b0b5d3fb13bd7b))
* Ember initializers are required automatically ([#242](https://github.com/stefanpenner/ember-cli/pull/242))

### 0.0.20

Expand Down
2 changes: 1 addition & 1 deletion blueprint/app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
</head>
<body>
<script>
window.<%= namespace %> = require('<%= modulePrefix %>/app')['default'].create();
window.<%= namespace %> = require('<%= modulePrefix %>/main')['default']('<%= modulePrefix %>');
</script>
</body>
</html>
Empty file.
16 changes: 16 additions & 0 deletions blueprint/app/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/* global requirejs, require */

export default function bootApp(prefix, attributes) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 for not hardcoding the modulePrefix there!

var App = require(prefix + '/app')['default'];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there should be a discussion if the app directory in ember-cli is strictly for business concerns or not. If it is (similar to Rails) then initializers should not be in the app directory. They would be a configuration concern.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as-is the app/ directory now has 10 directories in it. Things are getting crowded there. (I don't know why stylesheets are in the app directory but I guess that is another conversation)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're raising valid concerns. We got it in to make developer's life somewhat easier and just to take it for a spin to see how it feels. There's a lot of things to discuss around configuration (what suppose to be where, what to expose, etc.). It will be one of the things on the roadmap.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

something else to add to the constraints of folder layout, is to have other folders of lazy loadable bundles

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently the thinking is:

  • app/ everything for your app itself
  • config/ build time configuration depending on the environment
  • tests/ unit and acceptance tests to make sure the app works
  • public/ files copied 1:1

I personally like the inititializers being in the app/ folder because they're doing runtime configuration of app instances (not build time).

If we want to spilt propose a spilt of js and non js stuff. (That's currently just styles/, though)

var initializersRegExp = new RegExp(prefix + '/initializers');

Ember.keys(requirejs._eak_seen).filter(function(key) {
return initializersRegExp.test(key);
}).forEach(function(moduleName) {
var module = require(moduleName, null, null, true);
if (!module) { throw new Error(moduleName + ' must export an initializer.'); }
App.initializer(module['default']);
});

return App.create(attributes || {});
}
3 changes: 1 addition & 2 deletions blueprint/tests/helpers/start-app.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
var Application = require('<%= modulePrefix %>/app')['default'];
var Router = require('<%= modulePrefix %>/router')['default'];

function startApp(attrs) {
Expand All @@ -16,7 +15,7 @@ function startApp(attrs) {
});

Ember.run(function(){
App = Application.create(attributes);
App = require('<%= modulePrefix %>/main')['default']('<%= modulePrefix %>', attributes);
App.setupForTesting();
App.injectTestHelpers();
});
Expand Down