webpack/lib/webworker/WebWorkerChunkTemplate.js

32 lines
1.1 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
*/
2013-03-26 23:54:41 +08:00
var ChunkTemplate = require("../ChunkTemplate");
2013-01-31 01:49:25 +08:00
function WebWorkerChunkTemplate(outputOptions) {
2013-03-26 23:54:41 +08:00
ChunkTemplate.call(this, outputOptions);
2013-01-31 01:49:25 +08:00
}
module.exports = WebWorkerChunkTemplate;
2013-03-26 23:54:41 +08:00
WebWorkerChunkTemplate.prototype = Object.create(ChunkTemplate.prototype);
WebWorkerChunkTemplate.prototype.renderHeader = function(chunk) {
var buf = ChunkTemplate.prototype.renderHeader.call(this, chunk);
2013-01-31 01:49:25 +08:00
var chunkCallbackName = this.outputOptions.chunkCallbackName || ("webpackChunk" + (this.outputOptions.library || ""));
2013-03-26 23:54:41 +08:00
buf.unshift(chunkCallbackName + "(" + JSON.stringify(chunk.ids) + ",");
return buf;
};
WebWorkerChunkTemplate.prototype.renderFooter = function(chunk) {
var buf = ChunkTemplate.prototype.renderFooter.call(this, chunk);
buf.push(")");
return buf;
2013-01-31 01:49:25 +08:00
};
WebWorkerChunkTemplate.prototype.updateHash = function(hash) {
2013-03-26 23:54:41 +08:00
ChunkTemplate.prototype.updateHash.call(this, hash);
2013-01-31 01:49:25 +08:00
hash.update("webworker");
2013-03-26 23:54:41 +08:00
hash.update("3");
2013-01-31 01:49:25 +08:00
hash.update(this.outputOptions.chunkCallbackName + "");
hash.update(this.outputOptions.library + "");
};