Skip to content

Commit

Permalink
Auto merge of #4888 - seanpdoyle:vendor-shim-blueprint, r=stefanpenner
Browse files Browse the repository at this point in the history
Introduce the `vendor-shim` blueprint

There isn't much documentation around how to properly wrap an otherwise
global `window` dependency in an ES6 compliant module.

The generated blueprint will nudge consumers in the correct direction.

Insprired by [this stack overflow response][shim].

[shim]: http://stackoverflow.com/questions/30443351/import-dependencies-in-ember-cli-e-g-import-math-js/30584671#30584671
  • Loading branch information
homu committed Oct 16, 2015
2 parents 33e260c + e80e967 commit e7df723
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 0 deletions.
9 changes: 9 additions & 0 deletions blueprints/vendor-shim/files/vendor/shims/__name__.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
(function() {
function vendorModule() {
'use strict';

return { 'default': self['<%= name %>'] };
}

define('<%= name %>', [], vendorModule);
})();
17 changes: 17 additions & 0 deletions blueprints/vendor-shim/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/*jshint node:true*/

var stringUtil = require('ember-cli-string-utils');

module.exports = {
description: 'Generates an ES6 module shim for global libraries.',

locals: function(options) {
var entity = options.entity;
var rawName = entity.name;
var name = stringUtil.dasherize(rawName);

return {
name: name,
};
},
};
7 changes: 7 additions & 0 deletions tests/acceptance/help-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -752,6 +752,13 @@ ember version \u001b[36m<options...>\u001b[39m' + EOL + '\
anonymousOptions: ['name'],
overridden: false
},
{
name: 'vendor-shim',
description: 'Generates an ES6 module shim for global libraries.',
availableOptions: [],
anonymousOptions: ['name'],
overridden: false
},
{
name: 'view',
description: 'Generates a view subclass.',
Expand Down

0 comments on commit e7df723

Please sign in to comment.