webpack/lib/AsyncDependenciesBlock.js

41 lines
1.2 KiB
JavaScript
Raw Normal View History

2013-01-31 01:49:25 +08:00
/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
var DependenciesBlock = require("./DependenciesBlock");
2014-01-23 22:31:40 +08:00
function AsyncDependenciesBlock(name, module, loc) {
2013-01-31 01:49:25 +08:00
DependenciesBlock.call(this);
2014-01-23 22:31:40 +08:00
this.chunkName = name;
this.chunks = null;
2014-01-23 22:31:40 +08:00
this.module = module;
this.loc = loc;
Object.defineProperty(this, "chunk", {
get: function() {
throw new Error("`chunk` was been renamed to `chunks` and is now an array");
},
set: function() {
throw new Error("`chunk` was been renamed to `chunks` and is now an array");
}
});
2013-01-31 01:49:25 +08:00
}
module.exports = AsyncDependenciesBlock;
AsyncDependenciesBlock.prototype = Object.create(DependenciesBlock.prototype);
AsyncDependenciesBlock.prototype.constructor = AsyncDependenciesBlock;
2013-01-31 01:49:25 +08:00
AsyncDependenciesBlock.prototype.updateHash = function updateHash(hash) {
2014-01-23 22:31:40 +08:00
hash.update(this.chunkName || "");
hash.update(this.chunks && this.chunks.map(function(chunk) {
return typeof chunk.id === "number" ? chunk.id : "";
}).join(",") || "");
2013-01-31 01:49:25 +08:00
DependenciesBlock.prototype.updateHash.call(this, hash);
};
AsyncDependenciesBlock.prototype.disconnect = function() {
2015-01-07 16:20:48 +08:00
this.chunks = null;
2013-01-31 01:49:25 +08:00
DependenciesBlock.prototype.disconnect.call(this);
2015-01-07 16:20:48 +08:00
};