forked from webpack/webpack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJsonpChunkTemplate.js
More file actions
32 lines (28 loc) · 1.08 KB
/
JsonpChunkTemplate.js
File metadata and controls
32 lines (28 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
var ChunkTemplate = require("./ChunkTemplate");
function JsonpChunkTemplate(outputOptions) {
ChunkTemplate.call(this, outputOptions);
}
module.exports = JsonpChunkTemplate;
JsonpChunkTemplate.prototype = Object.create(ChunkTemplate.prototype);
JsonpChunkTemplate.prototype.renderHeader = function(chunk) {
var buf = ChunkTemplate.prototype.renderHeader.call(this, chunk);
var jsonpFunction = this.outputOptions.jsonpFunction || ("webpackJsonp" + (this.outputOptions.library || ""));
buf.unshift(jsonpFunction + "(" + JSON.stringify(chunk.ids) + ",");
return buf;
};
JsonpChunkTemplate.prototype.renderFooter = function(chunk) {
var buf = ChunkTemplate.prototype.renderFooter.call(this, chunk);
buf.push(")");
return buf;
};
JsonpChunkTemplate.prototype.updateHash = function(hash) {
ChunkTemplate.prototype.updateHash.call(this, hash);
hash.update("JsonpChunkTemplate");
hash.update("3");
hash.update(this.outputOptions.jsonpFunction + "");
hash.update(this.outputOptions.library + "");
};