Skip to content

Commit

Permalink
included modules is no longer needed
Browse files Browse the repository at this point in the history
* pre-packager will require an explicit dep-graph.json
* we no longer need module information for the module transpiler
* glob is basically broken in windows on shares – pending: isaacs/node-glob#192
  • Loading branch information
stefanpenner committed Apr 28, 2015
1 parent ed0a691 commit 7bed74b
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 59 deletions.
39 changes: 0 additions & 39 deletions lib/models/addon.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ var fs = require('fs');
var path = require('path');
var deprecate = require('../utilities/deprecate');
var assign = require('lodash/object/assign');
var glob = require('glob');
var SilentError = require('../errors/silent');
var reexport = require('../utilities/reexport');
var debug = require('debug')('ember-cli:addon');
Expand Down Expand Up @@ -348,40 +347,6 @@ Addon.prototype.included = function(/* app */) {
this.eachAddonInvoke('included', [this]);
};


/**
Returns a list of all javascript files included with this addon
@public
@method includedModules
@return {Object} Paths and exported objects as key-value pairs
*/
Addon.prototype.includedModules = function() {
if (this._includedModules) {
return this._includedModules;
}

var _this = this;
var treePath = path.join(this.root, this.treePaths['addon']).replace(/\\/g, '/');
var modulePath;

var globPattern = '**/*.+(' + this.registry.extensionsForType('js').join('|') + ')';

this._includedModules = glob.sync(path.join(treePath, globPattern)).reduce(function(ignoredModules, filePath) {
modulePath = filePath.replace(treePath, _this.moduleName());
modulePath = modulePath.slice(0, -(path.extname(modulePath).length));

ignoredModules[modulePath] = ['default'];
return ignoredModules;
}, {});

if (this._includedModules[this.moduleName() + '/index']) {
this._includedModules[this.moduleName()] = ['default'];
}

return this._includedModules;
};

/**
Returns the tree for all public files
Expand Down Expand Up @@ -496,10 +461,6 @@ Addon.prototype.compileTemplates = function(tree) {
Addon.prototype.compileAddon = function(tree) {
this._requireBuildPackages();

if (!this.isDevelopingAddon() && Object.keys(this.includedModules()).length === 0) {
return;
}

var addonJs = this.processedAddonJsFiles(tree);
var templatesTree = this.compileTemplates(this._treeFor('addon-templates'));
var reexported = reexport(this.name, this.name + '.js');
Expand Down
21 changes: 1 addition & 20 deletions tests/unit/models/addon-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,10 +173,10 @@ describe('models/addon.js', function() {
});

describe('initialized addon', function() {
this.timeout(40000);
before(function() {
projectPath = path.resolve(fixturePath, 'simple');
var packageContents = require(path.join(projectPath, 'package.json'));

project = new Project(projectPath, packageContents);
project.initializeAddons();
});
Expand All @@ -186,7 +186,6 @@ describe('models/addon.js', function() {
addon = findWhere(project.addons, { name: 'Ember CLI Generated with export' });

// Clear the caches
delete addon._includedModules;
delete addon._moduleName;
});

Expand All @@ -198,24 +197,6 @@ describe('models/addon.js', function() {
expect(addon.parent.name).to.equal(project.name);
});

it('generates a list of es6 modules to ignore', function() {
expect(addon.includedModules()).to.deep.equal({
'ember-cli-generated-with-export/controllers/people': ['default'],
'ember-cli-generated-with-export/mixins/thing': ['default']
});
});

it('generates a list of es6 modules to ignore with custom modulePrefix', function() {
addon.modulePrefix = 'custom-addon';

expect(addon.includedModules()).to.deep.equal({
'custom-addon/controllers/people': ['default'],
'custom-addon/mixins/thing': ['default']
});

delete addon.modulePrefix;
});

it('sets the root', function() {
expect(addon.root).to.not.equal(undefined);
});
Expand Down

0 comments on commit 7bed74b

Please sign in to comment.