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

Split bower_components into it's own directory #1436

Merged
merged 1 commit into from
Aug 4, 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 @@ -13,6 +13,7 @@
* [BUGFIX] Allow `public/` to contain files in the root of the project. [#1549](https://github.com/stefanpenner/ember-cli/pull/1549)
* [ENHANCEMENT] Add `robots.txt` and `crossdomain.xml` files in the root of the project. [#1550](https://github.com/stefanpenner/ember-cli/pull/1550)
* [BUGFIX] Generating mixins and utils with several levels of nesting no longer produces a failing test. [#1551](https://github.com/stefanpenner/ember-cli/pull/1551)
* [BREAKING ENHANCEMENT] bower assets moved to bower_components instead of vendor [#1436](https://github.com/stefanpenner/ember-cli/pull/1436)

### 0.0.40

Expand Down
2 changes: 1 addition & 1 deletion blueprints/app/files/.bowerrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"directory": "vendor"
"directory": "bower_components"
}
2 changes: 1 addition & 1 deletion blueprints/app/files/gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

# dependencies
/node_modules
/vendor/*
/bower_components/*

# misc
/.sass-cache
Expand Down
36 changes: 19 additions & 17 deletions lib/broccoli/ember-app.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,57 +78,57 @@ function EmberApp(options) {
compress: true
}
},
loader: 'vendor/loader/loader.js',
loader: 'bower_components/loader/loader.js',
trees: {},
jshintrc: {},
getEnvJSON: this.project.require(options.environment || './config/environment'),
vendorFiles: {}
}, defaults);

this.vendorFiles = merge(options.vendorFiles, {
'loader.js': 'vendor/loader/loader.js',
'jquery.js': 'vendor/jquery/dist/jquery.js',
'loader.js': 'bower_components/loader/loader.js',
'jquery.js': 'bower_components/jquery/dist/jquery.js',
'handlebars.js': {
development: 'vendor/handlebars/handlebars.js',
production: 'vendor/handlebars/handlebars.runtime.js'
development: 'bower_components/handlebars/handlebars.js',
production: 'bower_components/handlebars/handlebars.runtime.js'
},
'ember.js': {
development: 'vendor/ember/ember.js',
production: 'vendor/ember/ember.prod.js'
development: 'bower_components/ember/ember.js',
production: 'bower_components/ember/ember.prod.js'
},
'app-shims.js': [
'vendor/ember-cli-shims/app-shims.js', {
'bower_components/ember-cli-shims/app-shims.js', {
exports: {
ember: ['default']
}
}
],
'ember-resolver.js': [
'vendor/ember-resolver/dist/modules/ember-resolver.js', {
'bower_components/ember-resolver/dist/modules/ember-resolver.js', {
exports: {
'ember/resolver': ['default']
}
}
],
'ember-load-initializers.js': [
'vendor/ember-load-initializers/ember-load-initializers.js', {
'bower_components/ember-load-initializers/ember-load-initializers.js', {
exports: {
'ember/load-initializers': ['default']
}
}
],
'qunit.js' : [
'vendor/qunit/qunit/qunit.js', {
'bower_components/qunit/qunit/qunit.js', {
type: 'test '
}
],
'qunit.css': [
'vendor/qunit/qunit/qunit.css', {
'bower_components/qunit/qunit/qunit.css', {
type: 'test'
}
],
'qunit-notifications.js': [
'vendor/qunit-notifications/index.js', {
'bower_components/qunit-notifications/index.js', {
type: 'test'
}
]
Expand All @@ -142,8 +142,8 @@ function EmberApp(options) {
styles: unwatchedTree('app/styles'),
templates: unwatchedTree('app/templates'),

// do not watch vendor/ by default
vendor: unwatchedTree('vendor'),
// do not watch vendor/ or bower_components/ by default
vendor: mergeTrees([unwatchedTree('vendor'), unwatchedTree('bower_components')]),
}, defaults);

this.options.jshintrc = merge(this.options.jshintrc, {
Expand Down Expand Up @@ -389,7 +389,7 @@ EmberApp.prototype.javascript = memoize(function() {
var legacyFilesToAppend = this.legacyFilesToAppend;

if (this.tests) {
this.import('vendor/ember-qunit/dist/named-amd/main.js', {
this.import('bower_components/ember-qunit/dist/named-amd/main.js', {
Copy link
Member

Choose a reason for hiding this comment

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

We are merging bower_components and vendor into the vendor tree (in our constructor), then moving the vendor tree into a vendor/ destDir (in _processedVendorTree). So at this point shouldn't this still be vendor?

Copy link
Member Author

Choose a reason for hiding this comment

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

@rwjblue It's kind of personal preference. Either one actually works fine. Though semantically I figured bower_components makes more sense as that's the actual location of the file on disk.

exports: {
'ember-qunit': [
'globalize',
Expand All @@ -402,7 +402,7 @@ EmberApp.prototype.javascript = memoize(function() {
}
});

this.import('vendor/ember-cli-shims/test-shims.js', {
this.import('bower_components/ember-cli-shims/test-shims.js', {
Copy link
Member

Choose a reason for hiding this comment

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

See above comment.

exports: {
'qunit': ['default']
}
Expand Down Expand Up @@ -553,6 +553,8 @@ EmberApp.prototype.import = function(asset, options) {
return;
}

assetPath = assetPath.replace(/^bower_components\//, 'vendor/');
Copy link
Member

Choose a reason for hiding this comment

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

This is what makes my above statement a non-issue here (because you are just replacing bower_components/ with vendor/).

I suppose it makes sense to instruct folks to use "bower_components/foo-bar/baz.js" when the file is actually in that directory (it is easier to reason about that way) even though in reality at this stage of processing things have already been consolidated into vendor/.

Copy link
Member Author

Choose a reason for hiding this comment

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

Exactly my thinking 👍


if (assetPath.split('/').length < 2) {
console.log(chalk.red('Using `app.import` with a file in the root of `vendor/` causes a significant performance penalty. Please move `'+ assetPath + '` into a subdirectory.'));
}
Expand Down