Skip to content

Commit

Permalink
replaced Class with constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
sokra committed Oct 18, 2015
1 parent 85e0f87 commit 5acfacf
Show file tree
Hide file tree
Showing 36 changed files with 12 additions and 45 deletions.
10 changes: 5 additions & 5 deletions lib/Compilation.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,9 @@ Compilation.prototype.addModuleDependencies = function(module, dependencies, bai

var factories = [];
for(var i = 0; i < dependencies.length; i++) {
var factory = this.dependencyFactories.get(dependencies[i][0].Class);
var factory = this.dependencyFactories.get(dependencies[i][0].constructor);
if(!factory) {
return callback(new Error("No module factory available for dependency type: " + dependencies[i][0].Class.name));
return callback(new Error("No module factory available for dependency type: " + dependencies[i][0].constructor.name));
}
factories[i] = [factory, dependencies[i]];
}
Expand Down Expand Up @@ -343,13 +343,13 @@ Compilation.prototype._addModuleChain = function process(context, dependency, on
callback();
}.bind(this);

if(typeof dependency !== "object" || dependency === null || !dependency.Class) {
if(typeof dependency !== "object" || dependency === null || !dependency.constructor) {
throw new Error("Parameter 'dependency' must be a Dependency");
}

var moduleFactory = this.dependencyFactories.get(dependency.Class);
var moduleFactory = this.dependencyFactories.get(dependency.constructor);
if(!moduleFactory) {
throw new Error("No dependency factory available for this dependency type: " + dependency.Class.name);
throw new Error("No dependency factory available for this dependency type: " + dependency.constructor.name);
}

moduleFactory.create(context, dependency, function(err, module) {
Expand Down
4 changes: 2 additions & 2 deletions lib/DependenciesBlockVariable.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ DependenciesBlockVariable.prototype.updateHash = function(hash) {
DependenciesBlockVariable.prototype.expressionSource = function(dependencyTemplates, outputOptions, requestShortener) {
var source = new ReplaceSource(new RawSource(this.expression));
this.dependencies.forEach(function(dep) {
var template = dependencyTemplates.get(dep.Class);
if(!template) throw new Error("No template for dependency: " + dep.Class.name);
var template = dependencyTemplates.get(dep.constructor);
if(!template) throw new Error("No template for dependency: " + dep.constructor.name);
template.apply(dep, source, outputOptions, requestShortener, dependencyTemplates);
});
return source;
Expand Down
1 change: 0 additions & 1 deletion lib/Dependency.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
*/
function Dependency() {
this.module = null;
this.Class = Dependency;
}
module.exports = Dependency;

Expand Down
4 changes: 2 additions & 2 deletions lib/NormalModule.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,8 @@ NormalModule.prototype.source = function(dependencyTemplates, outputOptions, req
var topLevelBlock = this;

function doDep(dep) {
var template = dependencyTemplates.get(dep.Class);
if(!template) throw new Error("No template for dependency: " + dep.Class.name);
var template = dependencyTemplates.get(dep.constructor);
if(!template) throw new Error("No template for dependency: " + dep.constructor.name);
template.apply(dep, source, outputOptions, requestShortener, dependencyTemplates);
}

Expand Down
1 change: 0 additions & 1 deletion lib/dependencies/AMDDefineDependency.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ var NullDependency = require("./NullDependency");

function AMDDefineDependency(range, arrayRange, functionRange, objectRange) {
NullDependency.call(this);
this.Class = AMDDefineDependency;
this.range = range;
this.arrayRange = arrayRange;
this.functionRange = functionRange;
Expand Down
1 change: 0 additions & 1 deletion lib/dependencies/AMDRequireArrayDependency.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ var Dependency = require("../Dependency");

function AMDRequireArrayDependency(depsArray, range) {
Dependency.call(this);
this.Class = AMDRequireArrayDependency;
this.depsArray = depsArray;
this.range = range;
}
Expand Down
1 change: 0 additions & 1 deletion lib/dependencies/AMDRequireContextDependency.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ function AMDRequireContextDependency(request, recursive, regExp, range, valueRan
ContextDependency.call(this, request, recursive, regExp);
this.range = range;
this.valueRange = valueRange;
this.Class = AMDRequireContextDependency;
}
module.exports = AMDRequireContextDependency;

Expand Down
1 change: 0 additions & 1 deletion lib/dependencies/AMDRequireDependency.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ var DepBlockHelpers = require("./DepBlockHelpers");

function AMDRequireDependency(block) {
NullDependency.call(this);
this.Class = AMDRequireDependency;
this.block = block;
}
module.exports = AMDRequireDependency;
Expand Down
1 change: 0 additions & 1 deletion lib/dependencies/AMDRequireItemDependency.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ var ModuleDependency = require("./ModuleDependency");

function AMDRequireItemDependency(request, range) {
ModuleDependency.call(this, request);
this.Class = AMDRequireItemDependency;
this.range = range;
}
module.exports = AMDRequireItemDependency;
Expand Down
1 change: 0 additions & 1 deletion lib/dependencies/CommonJsRequireContextDependency.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ function CommonJsRequireContextDependency(request, recursive, regExp, range, val
ContextDependency.call(this, request, recursive, regExp);
this.range = range;
this.valueRange = valueRange;
this.Class = CommonJsRequireContextDependency;
}
module.exports = CommonJsRequireContextDependency;

Expand Down
1 change: 0 additions & 1 deletion lib/dependencies/CommonJsRequireDependency.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ var ModuleDependency = require("./ModuleDependency");

function CommonJsRequireDependency(request, range) {
ModuleDependency.call(this, request);
this.Class = CommonJsRequireDependency;
this.range = range;
}
module.exports = CommonJsRequireDependency;
Expand Down
1 change: 0 additions & 1 deletion lib/dependencies/ConstDependency.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ var NullDependency = require("./NullDependency");

function ConstDependency(expression, range) {
NullDependency.call(this);
this.Class = ConstDependency;
this.expression = expression;
this.range = range;
}
Expand Down
1 change: 0 additions & 1 deletion lib/dependencies/ContextDependency.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ function ContextDependency(request, recursive, regExp) {
this.userRequest = request;
this.recursive = recursive;
this.regExp = regExp;
this.Class = ContextDependency;
}
module.exports = ContextDependency;

Expand Down
1 change: 0 additions & 1 deletion lib/dependencies/ContextElementDependency.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ var ModuleDependency = require("./ModuleDependency");

function ContextElementDependency(request) {
ModuleDependency.call(this, request);
this.Class = ContextElementDependency;
}
module.exports = ContextElementDependency;

Expand Down
1 change: 0 additions & 1 deletion lib/dependencies/DelegatedSourceDependency.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ var ModuleDependency = require("./ModuleDependency");

function DelegatedSourceDependency(request) {
ModuleDependency.call(this, request);
this.Class = DelegatedSourceDependency;
}
module.exports = DelegatedSourceDependency;

Expand Down
1 change: 0 additions & 1 deletion lib/dependencies/DllEntryDependency.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ var Dependency = require("../Dependency");

function DllEntryDependency(dependencies, name, type) {
Dependency.call(this);
this.Class = DllEntryDependency;
this.dependencies = dependencies;
this.name = name;
this.type = type;
Expand Down
1 change: 0 additions & 1 deletion lib/dependencies/LabeledExportsDependency.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ var NullDependency = require("./NullDependency");

function LabeledExportsDependency(name, pos) {
NullDependency.call(this);
this.Class = LabeledExportsDependency;
this.name = name;
this.pos = pos;
}
Expand Down
1 change: 0 additions & 1 deletion lib/dependencies/LabeledModuleDependency.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ var Template = require("../Template");

function LabeledModuleDependency(request, range) {
ModuleDependency.call(this, request);
this.Class = LabeledModuleDependency;
this.range = range;
}
module.exports = LabeledModuleDependency;
Expand Down
1 change: 0 additions & 1 deletion lib/dependencies/LoaderDependency.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ var ModuleDependency = require("./ModuleDependency");

function LoaderDependency(request) {
ModuleDependency.call(this, request);
this.Class = LoaderDependency;
}
module.exports = LoaderDependency;

Expand Down
1 change: 0 additions & 1 deletion lib/dependencies/LocalModuleDependency.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ var NullDependency = require("./NullDependency");

function LocalModuleDependency(localModule, range) {
NullDependency.call(this);
this.Class = LocalModuleDependency;
localModule.flagUsed();
this.localModule = localModule;
this.range = range;
Expand Down
1 change: 0 additions & 1 deletion lib/dependencies/ModuleDependency.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ function ModuleDependency(request) {
Dependency.call(this);
this.request = request;
this.userRequest = request;
this.Class = ModuleDependency;
}
module.exports = ModuleDependency;

Expand Down
1 change: 0 additions & 1 deletion lib/dependencies/ModuleHotAcceptDependency.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ var ModuleDependency = require("./ModuleDependency");

function ModuleHotAcceptDependency(request, range) {
ModuleDependency.call(this, request);
this.Class = ModuleHotAcceptDependency;
this.range = range;
this.weak = true;
}
Expand Down
1 change: 0 additions & 1 deletion lib/dependencies/ModuleHotDeclineDependency.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ var ModuleDependency = require("./ModuleDependency");

function ModuleHotDeclineDependency(request, range) {
ModuleDependency.call(this, request);
this.Class = ModuleHotDeclineDependency;
this.range = range;
this.weak = true;
}
Expand Down
1 change: 0 additions & 1 deletion lib/dependencies/MultiEntryDependency.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ var Dependency = require("../Dependency");

function MultiEntryDependency(dependencies, name) {
Dependency.call(this);
this.Class = MultiEntryDependency;
this.dependencies = dependencies;
this.name = name;
}
Expand Down
1 change: 0 additions & 1 deletion lib/dependencies/NullDependency.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ var Dependency = require("../Dependency");

function NullDependency() {
Dependency.call(this);
this.Class = NullDependency;
}
module.exports = NullDependency;

Expand Down
1 change: 0 additions & 1 deletion lib/dependencies/PrefetchDependency.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ var ModuleDependency = require("./ModuleDependency");

function PrefetchDependency(request) {
ModuleDependency.call(this, request);
this.Class = PrefetchDependency;
}
module.exports = PrefetchDependency;

Expand Down
1 change: 0 additions & 1 deletion lib/dependencies/RequireContextDependency.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ var ContextDependency = require("./ContextDependency");
function RequireContextDependency(request, recursive, regExp, range) {
ContextDependency.call(this, request, recursive, regExp);
this.range = range;
this.Class = RequireContextDependency;
}
module.exports = RequireContextDependency;

Expand Down
1 change: 0 additions & 1 deletion lib/dependencies/RequireEnsureDependency.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ var DepBlockHelpers = require("./DepBlockHelpers");

function RequireEnsureDependency(block) {
NullDependency.call(this);
this.Class = RequireEnsureDependency;
this.block = block;
}
module.exports = RequireEnsureDependency;
Expand Down
1 change: 0 additions & 1 deletion lib/dependencies/RequireEnsureItemDependency.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ var ModuleDependency = require("./ModuleDependency");

function RequireEnsureItemDependency(request) {
ModuleDependency.call(this, request);
this.Class = RequireEnsureItemDependency;
}
module.exports = RequireEnsureItemDependency;

Expand Down
1 change: 0 additions & 1 deletion lib/dependencies/RequireHeaderDependency.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ var NullDependency = require("./NullDependency");
function RequireHeaderDependency(range) {
if(!Array.isArray(range)) throw new Error("range must be valid");
NullDependency.call(this);
this.Class = RequireHeaderDependency;
this.range = range;
}
module.exports = RequireHeaderDependency;
Expand Down
1 change: 0 additions & 1 deletion lib/dependencies/RequireIncludeDependency.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ var ModuleDependency = require("./ModuleDependency");

function RequireIncludeDependency(request, range) {
ModuleDependency.call(this, request);
this.Class = RequireIncludeDependency;
this.range = range;
}
module.exports = RequireIncludeDependency;
Expand Down
1 change: 0 additions & 1 deletion lib/dependencies/RequireResolveContextDependency.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ function RequireResolveContextDependency(request, recursive, regExp, range, valu
ContextDependency.call(this, request, recursive, regExp);
this.range = range;
this.valueRange = valueRange;
this.Class = RequireResolveContextDependency;
}
module.exports = RequireResolveContextDependency;

Expand Down
1 change: 0 additions & 1 deletion lib/dependencies/RequireResolveDependency.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ var ModuleDependency = require("./ModuleDependency");

function RequireResolveDependency(request, range) {
ModuleDependency.call(this, request);
this.Class = RequireResolveDependency;
this.range = range;
}
module.exports = RequireResolveDependency;
Expand Down
1 change: 0 additions & 1 deletion lib/dependencies/RequireResolveHeaderDependency.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ var NullDependency = require("./NullDependency");
function RequireResolveHeaderDependency(range) {
if(!Array.isArray(range)) throw new Error("range must be valid");
NullDependency.call(this);
this.Class = RequireResolveHeaderDependency;
this.range = range;
}
module.exports = RequireResolveHeaderDependency;
Expand Down
1 change: 0 additions & 1 deletion lib/dependencies/SingleEntryDependency.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ var ModuleDependency = require("./ModuleDependency");

function SingleEntryDependency(request) {
ModuleDependency.call(this, request);
this.Class = SingleEntryDependency;
}
module.exports = SingleEntryDependency;

Expand Down
7 changes: 3 additions & 4 deletions lib/dependencies/TemplateArgumentDependency.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
*/
function TemplateArgumentDependency(name, dep) {
this.name = name;
this.Class = TemplateArgumentDependency;
this.dep = dep;
}
module.exports = TemplateArgumentDependency;
Expand All @@ -20,8 +19,8 @@ TemplateArgumentDependency.Template = function TemplateArgumentDependencyTemplat

TemplateArgumentDependency.Template.prototype.apply = function(dep, source, outputOptions, requestShortener, dependencyTemplates) {
var d = dep.dep;
var template = dependencyTemplates.get(d.Class);
if(!template) throw new Error("No template for dependency: " + d.Class.name);
if(!template.applyAsTemplateArgument) throw new Error("Template cannot be applied as TemplateArgument: " + d.Class.name);
var template = dependencyTemplates.get(d.constructor);
if(!template) throw new Error("No template for dependency: " + d.constructor.name);
if(!template.applyAsTemplateArgument) throw new Error("Template cannot be applied as TemplateArgument: " + d.constructor.name);
return template.applyAsTemplateArgument(dep.name, d, source, outputOptions, requestShortener, dependencyTemplates);
};

0 comments on commit 5acfacf

Please sign in to comment.