Permalink
Browse files

Fix exclusions in CommonJs module bundling.

  • Loading branch information...
1 parent 5300849 commit c44ce7292163f5b38f68dffce8fbc41e2ca55a22 Kenneth Kufluk committed Mar 22, 2012
Showing with 9 additions and 20 deletions.
  1. +9 −20 lib/loadbuilder/asset.js
@@ -129,18 +129,9 @@ util.extend(Module.prototype, {
return this._source;
},
isCJS: function() {
- if (typeof this._isCJS == 'undefined') {
- // FIXME: no memoization in Loadbuilder, please.
- var fileInfo = fs.statSync(this.fullPath());
- var cjsMemoKey = fileInfo.mtime + '_' + this.fullPath();
- if(typeof(Module.cjsMemo[cjsMemoKey]) !== 'undefined') {
- this._isCJS = Module.cjsMemo[cjsMemoKey];
- } else {
- this._isCJS = Module.cjsMemo[cjsMemoKey] = !analyzer.analyze(PROVIDE, this.fromFile()).length;
- }
- }
+ var fileInfo = fs.statSync(this.fullPath());
+ return !analyzer.analyze(PROVIDE, this.fromFile()).length;
- return this._isCJS;
},
amdWrappedSource: function() {
var deps = ['require', 'exports'].concat(this.dependencies().map(function(d) { return d.id; })),
@@ -152,21 +143,19 @@ util.extend(Module.prototype, {
},
dependencies: function() {
- if(!this._deps) {
- if (this.isCJS()) {
- this._deps = this.dependenciesFromRequire();
- } else {
- this._deps = Script.prototype.dependencies.call(this);
- }
+ if (this.isCJS()) {
+ return this.dependenciesFromRequire();
+ } else {
+ return Script.prototype.dependencies.call(this);
}
- return this._deps;
},
dependenciesFromRequire: function() {
var requires = analyzer.analyze(REQUIRE, this.fromFile());
return requires.map(function(r) {
- return this.builder.matchAsset(r.values[0]);
- }, this);
+ var asset = this.builder.matchAsset(r.values[0]);
+ return (asset.length==0) ? null : asset;
+ }, this).filter(function(item){ return item!=null; });
},
addId: function() {
var tree = uglify.parser.parse(this.fromFile()),

0 comments on commit c44ce72

Please sign in to comment.