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) {
|
ChunkTemplate.prototype.updateHash = function(hash) {
|
||||||
hash.update("template");
|
hash.update("ChunkTemplate");
|
||||||
hash.update("jsonp");
|
hash.update("1");
|
||||||
hash.update("2");
|
|
||||||
hash.update(this.outputOptions.jsonpFunction + "");
|
|
||||||
hash.update(this.outputOptions.library + "");
|
|
||||||
};
|
};
|
|
@ -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) {
|
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;
|
source = this.cache["c" + chunk.id + chunk.name].source;
|
||||||
} else {
|
} 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) {
|
if(this.cache) {
|
||||||
this.cache["c" + chunk.id + chunk.name] = {
|
this.cache["c" + chunk.id + chunk.name] = {
|
||||||
hash: hash,
|
hash: hash,
|
||||||
|
@ -572,7 +572,7 @@ Compilation.prototype.createChunkAssets = function createChunkAssets() {
|
||||||
}
|
}
|
||||||
this.assets[
|
this.assets[
|
||||||
file = chunkFilename
|
file = chunkFilename
|
||||||
.replace(Template.REGEXP_HASH, hash)
|
.replace(Template.REGEXP_HASH, this.hash)
|
||||||
.replace(Template.REGEXP_CHUNKHASH, chunk.renderedHash)
|
.replace(Template.REGEXP_CHUNKHASH, chunk.renderedHash)
|
||||||
.replace(Template.REGEXP_ID, chunk.id)
|
.replace(Template.REGEXP_ID, chunk.id)
|
||||||
] = source;
|
] = source;
|
||||||
|
@ -582,7 +582,7 @@ Compilation.prototype.createChunkAssets = function createChunkAssets() {
|
||||||
this.assets[
|
this.assets[
|
||||||
file = namedChunkFilename
|
file = namedChunkFilename
|
||||||
.replace(Template.REGEXP_CHUNKHASH, chunk.renderedHash)
|
.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_ID, chunk.id)
|
||||||
.replace(Template.REGEXP_NAME, chunk.name || "")
|
.replace(Template.REGEXP_NAME, chunk.name || "")
|
||||||
] = source;
|
] = source;
|
||||||
|
|
|
@ -25,7 +25,7 @@ JsonpChunkTemplate.prototype.renderFooter = function(chunk) {
|
||||||
|
|
||||||
JsonpChunkTemplate.prototype.updateHash = function(hash) {
|
JsonpChunkTemplate.prototype.updateHash = function(hash) {
|
||||||
ChunkTemplate.prototype.updateHash.call(this, hash);
|
ChunkTemplate.prototype.updateHash.call(this, hash);
|
||||||
hash.update("jsonp");
|
hash.update("JsonpChunkTemplate");
|
||||||
hash.update("3");
|
hash.update("3");
|
||||||
hash.update(this.outputOptions.jsonpFunction + "");
|
hash.update(this.outputOptions.jsonpFunction + "");
|
||||||
hash.update(this.outputOptions.library + "");
|
hash.update(this.outputOptions.library + "");
|
||||||
|
|
|
@ -54,8 +54,8 @@ JsonpMainTemplate.prototype.renderRequireEnsure = function(hash, chunk) {
|
||||||
"script.charset = 'utf-8';",
|
"script.charset = 'utf-8';",
|
||||||
"script.src = modules.c + " +
|
"script.src = modules.c + " +
|
||||||
JSON.stringify(chunkFilename
|
JSON.stringify(chunkFilename
|
||||||
.replace(Template.REGEXP_HASH, hash)
|
|
||||||
.replace(Template.REGEXP_NAME, ""))
|
.replace(Template.REGEXP_NAME, ""))
|
||||||
|
.replace(Template.REGEXP_HASH, "\" + " + this.renderCurrentHashCode(hash) + " + \"")
|
||||||
.replace(Template.REGEXP_CHUNKHASH, "\" + " + JSON.stringify(chunkHashMap) + "[chunkId] + \"")
|
.replace(Template.REGEXP_CHUNKHASH, "\" + " + JSON.stringify(chunkHashMap) + "[chunkId] + \"")
|
||||||
.replace(Template.REGEXP_ID, "\" + chunkId + \"") + ";",
|
.replace(Template.REGEXP_ID, "\" + chunkId + \"") + ";",
|
||||||
"head.appendChild(script);"
|
"head.appendChild(script);"
|
||||||
|
@ -88,7 +88,7 @@ JsonpMainTemplate.prototype.renderInit = function(hash, chunk) {
|
||||||
this.indent(this.renderAddModule(hash, chunk, "moduleId", "moreModules[moduleId]")),
|
this.indent(this.renderAddModule(hash, chunk, "moduleId", "moreModules[moduleId]")),
|
||||||
"}",
|
"}",
|
||||||
"while(callbacks.length)",
|
"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;
|
return buf;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
JsonpMainTemplate.prototype.renderCurrentHashCode = function(hash) {
|
||||||
|
return JSON.stringify(hash);
|
||||||
|
};
|
||||||
|
|
||||||
JsonpMainTemplate.prototype.updateHash = function(hash) {
|
JsonpMainTemplate.prototype.updateHash = function(hash) {
|
||||||
MainTemplate.prototype.updateHash.call(this, hash);
|
MainTemplate.prototype.updateHash.call(this, hash);
|
||||||
hash.update("jsonp");
|
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(this.asString(this.renderInit(hash, chunk)));
|
||||||
buf.push("");
|
buf.push("");
|
||||||
buf.push("// Load entry module and return exports");
|
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();
|
var source = new ConcatSource();
|
||||||
source.add("/******/ (function(modules) { // webpackBootstrap\n");
|
source.add("/******/ (function(modules) { // webpackBootstrap\n");
|
||||||
source.add(new PrefixSource("/******/ \t", new OriginalSource(this.asString(buf), "webpackBootstrap " + hash)));
|
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)",
|
"// Create a new module (and put it into the cache)",
|
||||||
"var module = installedModules[moduleId] = {",
|
"var module = installedModules[moduleId] = {",
|
||||||
this.indent([
|
this.indent(this.renderModule(hash, chunk, "moduleId")),
|
||||||
"exports: {},",
|
|
||||||
"id: moduleId,",
|
|
||||||
"loaded: false"
|
|
||||||
]),
|
|
||||||
"};",
|
"};",
|
||||||
"",
|
"",
|
||||||
"// Execute the module function",
|
"// 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",
|
"// Flag the module as loaded",
|
||||||
"module.loaded = true;",
|
"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) {
|
MainTemplate.prototype.renderRequireExtensions = function(hash, chunk) {
|
||||||
var buf = [];
|
var buf = [];
|
||||||
if(chunk.chunks.length == 0) {
|
if(chunk.chunks.length == 0) {
|
||||||
|
|
|
@ -25,6 +25,7 @@ RecordIdsPlugin.prototype.apply = function(compiler) {
|
||||||
if(module.id !== null) return;
|
if(module.id !== null) return;
|
||||||
var identifier = module.identifier();
|
var identifier = module.identifier();
|
||||||
var id = records.modules.byIdentifier[identifier];
|
var id = records.modules.byIdentifier[identifier];
|
||||||
|
if(id === undefined) return;
|
||||||
if(usedIds[id]) return;
|
if(usedIds[id]) return;
|
||||||
usedIds[id] = true;
|
usedIds[id] = true;
|
||||||
module.id = id;
|
module.id = id;
|
||||||
|
@ -68,6 +69,7 @@ RecordIdsPlugin.prototype.apply = function(compiler) {
|
||||||
if(chunk.id !== null) return;
|
if(chunk.id !== null) return;
|
||||||
if(!chunk.name) return;
|
if(!chunk.name) return;
|
||||||
var id = records.chunks.byName[chunk.name];
|
var id = records.chunks.byName[chunk.name];
|
||||||
|
if(id === undefined) return;
|
||||||
if(usedIds[id]) return;
|
if(usedIds[id]) return;
|
||||||
usedIds[id] = true;
|
usedIds[id] = true;
|
||||||
chunk.id = id;
|
chunk.id = id;
|
||||||
|
|
|
@ -92,8 +92,10 @@ WebpackOptionsApply.prototype.process = function(options, compiler) {
|
||||||
);
|
);
|
||||||
break;
|
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));
|
compiler.apply(new LibraryTemplatePlugin(options.output.library, options.output.libraryTarget));
|
||||||
|
}
|
||||||
|
|
||||||
if(options.devtool == "eval")
|
if(options.devtool == "eval")
|
||||||
compiler.apply(new EvalDevToolModulePlugin());
|
compiler.apply(new EvalDevToolModulePlugin());
|
||||||
else if(options.devtool == "sourcemap" || options.devtool == "source-map")
|
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-sourcemap" ||
|
||||||
options.devtool == "inline-source-map")
|
options.devtool == "inline-source-map")
|
||||||
compiler.apply(new SourceMapDevToolPlugin(options.context));
|
compiler.apply(new SourceMapDevToolPlugin(options.context));
|
||||||
|
|
||||||
function itemToPlugin(item, name) {
|
function itemToPlugin(item, name) {
|
||||||
if(Array.isArray(item))
|
if(Array.isArray(item))
|
||||||
return new MultiEntryPlugin(options.context, item, name);
|
return new MultiEntryPlugin(options.context, item, name);
|
||||||
|
@ -115,6 +118,7 @@ WebpackOptionsApply.prototype.process = function(options, compiler) {
|
||||||
compiler.apply(itemToPlugin(options.entry[name], name));
|
compiler.apply(itemToPlugin(options.entry[name], name));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if(options.prefetch) {
|
if(options.prefetch) {
|
||||||
options.prefetch.map(function(request) {
|
options.prefetch.map(function(request) {
|
||||||
compiler.apply(new PrefetchPlugin(options.context, request));
|
compiler.apply(new PrefetchPlugin(options.context, request));
|
||||||
|
|
|
@ -190,7 +190,7 @@ function DedupModuleTemplateDecorator(template) {
|
||||||
}
|
}
|
||||||
|
|
||||||
DedupModuleTemplateDecorator.prototype.render = function(module, dependencyTemplates, chunk) {
|
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);
|
var chunkIndex = module.rootDuplicatesChunks.indexOf(chunk);
|
||||||
if(!module.rootDuplicates || !module.rootDuplicates[chunkIndex]) return this.template.render(module, dependencyTemplates, chunk);
|
if(!module.rootDuplicates || !module.rootDuplicates[chunkIndex]) return this.template.render(module, dependencyTemplates, chunk);
|
||||||
var rootDuplicates = module.rootDuplicates[chunkIndex];
|
var rootDuplicates = module.rootDuplicates[chunkIndex];
|
||||||
|
|
|
@ -34,8 +34,8 @@ WebWorkerMainTemplate.prototype.renderRequireEnsure = function(hash, chunk) {
|
||||||
this.indent([
|
this.indent([
|
||||||
"importScripts(" +
|
"importScripts(" +
|
||||||
JSON.stringify(chunkFilename
|
JSON.stringify(chunkFilename
|
||||||
.replace(Template.REGEXP_HASH, hash)
|
|
||||||
.replace(Template.REGEXP_NAME, ""))
|
.replace(Template.REGEXP_NAME, ""))
|
||||||
|
.replace(Template.REGEXP_HASH, "\" + " + this.renderCurrentHashCode(hash) + " + \"")
|
||||||
.replace(Template.REGEXP_ID, "\" + chunkId + \"") + ");"
|
.replace(Template.REGEXP_ID, "\" + chunkId + \"") + ");"
|
||||||
]),
|
]),
|
||||||
"}",
|
"}",
|
||||||
|
@ -62,6 +62,10 @@ WebWorkerMainTemplate.prototype.renderInit = function(hash, chunk) {
|
||||||
return buf;
|
return buf;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
WebWorkerMainTemplate.prototype.renderCurrentHashCode = function(hash) {
|
||||||
|
return JSON.stringify(hash);
|
||||||
|
};
|
||||||
|
|
||||||
WebWorkerMainTemplate.prototype.updateHash = function(hash) {
|
WebWorkerMainTemplate.prototype.updateHash = function(hash) {
|
||||||
MainTemplate.prototype.updateHash.call(this, hash);
|
MainTemplate.prototype.updateHash.call(this, hash);
|
||||||
hash.update("webworker");
|
hash.update("webworker");
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "webpack",
|
"name": "webpack",
|
||||||
"version": "0.10.0-beta24",
|
"version": "0.10.0-beta25",
|
||||||
"author": "Tobias Koppers @sokra",
|
"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.",
|
"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": {
|
"dependencies": {
|
||||||
|
|
Loading…
Reference in New Issue