fixed bugs
This commit is contained in:
parent
a84a0433c9
commit
327a990070
|
@ -35,9 +35,6 @@ ChunkTemplate.prototype.renderFooter = function(chunk) {
|
|||
};
|
||||
|
||||
ChunkTemplate.prototype.updateHash = function(hash) {
|
||||
hash.update("template");
|
||||
hash.update("jsonp");
|
||||
hash.update("2");
|
||||
hash.update(this.outputOptions.jsonpFunction + "");
|
||||
hash.update(this.outputOptions.library + "");
|
||||
hash.update("ChunkTemplate");
|
||||
hash.update("1");
|
||||
};
|
|
@ -541,7 +541,7 @@ Compilation.prototype.createChunkAssets = function createChunkAssets() {
|
|||
if(this.cache && this.cache["c" + chunk.id + chunk.name] && this.cache["c" + chunk.id + chunk.name].hash == hash) {
|
||||
source = this.cache["c" + chunk.id + chunk.name].source;
|
||||
} else {
|
||||
source = this.mainTemplate.render(hash, chunk, this.moduleTemplate, this.dependencyTemplates);
|
||||
source = this.mainTemplate.render(this.hash, chunk, this.moduleTemplate, this.dependencyTemplates);
|
||||
if(this.cache) {
|
||||
this.cache["c" + chunk.id + chunk.name] = {
|
||||
hash: hash,
|
||||
|
@ -572,7 +572,7 @@ Compilation.prototype.createChunkAssets = function createChunkAssets() {
|
|||
}
|
||||
this.assets[
|
||||
file = chunkFilename
|
||||
.replace(Template.REGEXP_HASH, hash)
|
||||
.replace(Template.REGEXP_HASH, this.hash)
|
||||
.replace(Template.REGEXP_CHUNKHASH, chunk.renderedHash)
|
||||
.replace(Template.REGEXP_ID, chunk.id)
|
||||
] = source;
|
||||
|
@ -582,7 +582,7 @@ Compilation.prototype.createChunkAssets = function createChunkAssets() {
|
|||
this.assets[
|
||||
file = namedChunkFilename
|
||||
.replace(Template.REGEXP_CHUNKHASH, chunk.renderedHash)
|
||||
.replace(Template.REGEXP_HASH, hash)
|
||||
.replace(Template.REGEXP_HASH, this.hash)
|
||||
.replace(Template.REGEXP_ID, chunk.id)
|
||||
.replace(Template.REGEXP_NAME, chunk.name || "")
|
||||
] = source;
|
||||
|
|
|
@ -25,7 +25,7 @@ JsonpChunkTemplate.prototype.renderFooter = function(chunk) {
|
|||
|
||||
JsonpChunkTemplate.prototype.updateHash = function(hash) {
|
||||
ChunkTemplate.prototype.updateHash.call(this, hash);
|
||||
hash.update("jsonp");
|
||||
hash.update("JsonpChunkTemplate");
|
||||
hash.update("3");
|
||||
hash.update(this.outputOptions.jsonpFunction + "");
|
||||
hash.update(this.outputOptions.library + "");
|
||||
|
|
|
@ -54,8 +54,8 @@ JsonpMainTemplate.prototype.renderRequireEnsure = function(hash, chunk) {
|
|||
"script.charset = 'utf-8';",
|
||||
"script.src = modules.c + " +
|
||||
JSON.stringify(chunkFilename
|
||||
.replace(Template.REGEXP_HASH, hash)
|
||||
.replace(Template.REGEXP_NAME, ""))
|
||||
.replace(Template.REGEXP_HASH, "\" + " + this.renderCurrentHashCode(hash) + " + \"")
|
||||
.replace(Template.REGEXP_CHUNKHASH, "\" + " + JSON.stringify(chunkHashMap) + "[chunkId] + \"")
|
||||
.replace(Template.REGEXP_ID, "\" + chunkId + \"") + ";",
|
||||
"head.appendChild(script);"
|
||||
|
@ -88,7 +88,7 @@ JsonpMainTemplate.prototype.renderInit = function(hash, chunk) {
|
|||
this.indent(this.renderAddModule(hash, chunk, "moduleId", "moreModules[moduleId]")),
|
||||
"}",
|
||||
"while(callbacks.length)",
|
||||
this.indent("callbacks.shift().call(null, require);"),
|
||||
this.indent("callbacks.shift().call(null, " + this.requireFn + ");"),
|
||||
]),
|
||||
"};"
|
||||
);
|
||||
|
@ -96,6 +96,10 @@ JsonpMainTemplate.prototype.renderInit = function(hash, chunk) {
|
|||
return buf;
|
||||
};
|
||||
|
||||
JsonpMainTemplate.prototype.renderCurrentHashCode = function(hash) {
|
||||
return JSON.stringify(hash);
|
||||
};
|
||||
|
||||
JsonpMainTemplate.prototype.updateHash = function(hash) {
|
||||
MainTemplate.prototype.updateHash.call(this, hash);
|
||||
hash.update("jsonp");
|
||||
|
|
|
@ -27,7 +27,7 @@ MainTemplate.prototype.render = function(hash, chunk, moduleTemplate, dependency
|
|||
buf.push(this.asString(this.renderInit(hash, chunk)));
|
||||
buf.push("");
|
||||
buf.push("// Load entry module and return exports");
|
||||
buf.push("return " + this.requireFn + "(0);");
|
||||
buf.push("return " + this.renderRequireFunctionForModule(hash, chunk, "0") + "(0);");
|
||||
var source = new ConcatSource();
|
||||
source.add("/******/ (function(modules) { // webpackBootstrap\n");
|
||||
source.add(new PrefixSource("/******/ \t", new OriginalSource(this.asString(buf), "webpackBootstrap " + hash)));
|
||||
|
@ -91,15 +91,11 @@ MainTemplate.prototype.renderRequireContent = function(hash, chunk) {
|
|||
"",
|
||||
"// Create a new module (and put it into the cache)",
|
||||
"var module = installedModules[moduleId] = {",
|
||||
this.indent([
|
||||
"exports: {},",
|
||||
"id: moduleId,",
|
||||
"loaded: false"
|
||||
]),
|
||||
this.indent(this.renderModule(hash, chunk, "moduleId")),
|
||||
"};",
|
||||
"",
|
||||
"// Execute the module function",
|
||||
"modules[moduleId].call(null, module, module.exports, " + this.requireFn + ");",
|
||||
"modules[moduleId].call(null, module, module.exports, " + this.renderRequireFunctionForModule(hash, chunk, "moduleId") + ");",
|
||||
"",
|
||||
"// Flag the module as loaded",
|
||||
"module.loaded = true;",
|
||||
|
@ -109,6 +105,18 @@ MainTemplate.prototype.renderRequireContent = function(hash, chunk) {
|
|||
];
|
||||
};
|
||||
|
||||
MainTemplate.prototype.renderRequireFunctionForModule = function(hash, chunk, varModuleId) {
|
||||
return this.requireFn;
|
||||
};
|
||||
|
||||
MainTemplate.prototype.renderModule = function(hash, chunk, varModuleId) {
|
||||
return [
|
||||
"exports: {},",
|
||||
"id: moduleId,",
|
||||
"loaded: false"
|
||||
];
|
||||
};
|
||||
|
||||
MainTemplate.prototype.renderRequireExtensions = function(hash, chunk) {
|
||||
var buf = [];
|
||||
if(chunk.chunks.length == 0) {
|
||||
|
|
|
@ -25,6 +25,7 @@ RecordIdsPlugin.prototype.apply = function(compiler) {
|
|||
if(module.id !== null) return;
|
||||
var identifier = module.identifier();
|
||||
var id = records.modules.byIdentifier[identifier];
|
||||
if(id === undefined) return;
|
||||
if(usedIds[id]) return;
|
||||
usedIds[id] = true;
|
||||
module.id = id;
|
||||
|
@ -68,6 +69,7 @@ RecordIdsPlugin.prototype.apply = function(compiler) {
|
|||
if(chunk.id !== null) return;
|
||||
if(!chunk.name) return;
|
||||
var id = records.chunks.byName[chunk.name];
|
||||
if(id === undefined) return;
|
||||
if(usedIds[id]) return;
|
||||
usedIds[id] = true;
|
||||
chunk.id = id;
|
||||
|
|
|
@ -92,8 +92,10 @@ WebpackOptionsApply.prototype.process = function(options, compiler) {
|
|||
);
|
||||
break;
|
||||
}
|
||||
if(options.output.library || options.output.libraryTarget != "var")
|
||||
if(options.output.library || options.output.libraryTarget != "var") {
|
||||
compiler.apply(new LibraryTemplatePlugin(options.output.library, options.output.libraryTarget));
|
||||
}
|
||||
|
||||
if(options.devtool == "eval")
|
||||
compiler.apply(new EvalDevToolModulePlugin());
|
||||
else if(options.devtool == "sourcemap" || options.devtool == "source-map")
|
||||
|
@ -102,6 +104,7 @@ WebpackOptionsApply.prototype.process = function(options, compiler) {
|
|||
options.devtool == "inline-sourcemap" ||
|
||||
options.devtool == "inline-source-map")
|
||||
compiler.apply(new SourceMapDevToolPlugin(options.context));
|
||||
|
||||
function itemToPlugin(item, name) {
|
||||
if(Array.isArray(item))
|
||||
return new MultiEntryPlugin(options.context, item, name);
|
||||
|
@ -115,6 +118,7 @@ WebpackOptionsApply.prototype.process = function(options, compiler) {
|
|||
compiler.apply(itemToPlugin(options.entry[name], name));
|
||||
});
|
||||
}
|
||||
|
||||
if(options.prefetch) {
|
||||
options.prefetch.map(function(request) {
|
||||
compiler.apply(new PrefetchPlugin(options.context, request));
|
||||
|
|
|
@ -190,7 +190,7 @@ function DedupModuleTemplateDecorator(template) {
|
|||
}
|
||||
|
||||
DedupModuleTemplateDecorator.prototype.render = function(module, dependencyTemplates, chunk) {
|
||||
if(!module.rootDuplicatesChunks) return this.template.render(module, dependencyTemplates, chunk);
|
||||
if(!module.rootDuplicatesChunks || !chunk) return this.template.render(module, dependencyTemplates, chunk);
|
||||
var chunkIndex = module.rootDuplicatesChunks.indexOf(chunk);
|
||||
if(!module.rootDuplicates || !module.rootDuplicates[chunkIndex]) return this.template.render(module, dependencyTemplates, chunk);
|
||||
var rootDuplicates = module.rootDuplicates[chunkIndex];
|
||||
|
|
|
@ -34,8 +34,8 @@ WebWorkerMainTemplate.prototype.renderRequireEnsure = function(hash, chunk) {
|
|||
this.indent([
|
||||
"importScripts(" +
|
||||
JSON.stringify(chunkFilename
|
||||
.replace(Template.REGEXP_HASH, hash)
|
||||
.replace(Template.REGEXP_NAME, ""))
|
||||
.replace(Template.REGEXP_HASH, "\" + " + this.renderCurrentHashCode(hash) + " + \"")
|
||||
.replace(Template.REGEXP_ID, "\" + chunkId + \"") + ");"
|
||||
]),
|
||||
"}",
|
||||
|
@ -62,6 +62,10 @@ WebWorkerMainTemplate.prototype.renderInit = function(hash, chunk) {
|
|||
return buf;
|
||||
};
|
||||
|
||||
WebWorkerMainTemplate.prototype.renderCurrentHashCode = function(hash) {
|
||||
return JSON.stringify(hash);
|
||||
};
|
||||
|
||||
WebWorkerMainTemplate.prototype.updateHash = function(hash) {
|
||||
MainTemplate.prototype.updateHash.call(this, hash);
|
||||
hash.update("webworker");
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "webpack",
|
||||
"version": "0.10.0-beta24",
|
||||
"version": "0.10.0-beta25",
|
||||
"author": "Tobias Koppers @sokra",
|
||||
"description": "Packs CommonJs/AMD/Labeled Modules for the browser. Allows to split your codebase into multiple bundles, which can be loaded on demand. Support loaders to preprocess files, i.e. json, jade, coffee, css, less, ... and your custom stuff.",
|
||||
"dependencies": {
|
||||
|
|
Loading…
Reference in New Issue