fixed edge cases
This commit is contained in:
parent
45a6749b08
commit
e43ec6251e
|
@ -103,8 +103,8 @@ NormalModule.prototype.source = function(dependencyTemplates, outputOptions, req
|
|||
function emitFunction() {
|
||||
if(varNames.length == 0) return;
|
||||
|
||||
varStartCode += "/* WEBPACK VAR INJECTION */(function(" + varNames.join(", ") + ") {";
|
||||
varEndCode = "}(" + varExpressions.map(function(e) {return e.source()}).join(", ") + "))" + varEndCode;
|
||||
varStartCode += "/* WEBPACK VAR INJECTION */(function(require, " + varNames.join(", ") + ") {";
|
||||
varEndCode = "}(require, " + varExpressions.map(function(e) {return e.source()}).join(", ") + "))" + varEndCode;
|
||||
|
||||
varNames.length = 0;
|
||||
varExpressions.length = 0;
|
||||
|
|
|
@ -20,7 +20,7 @@ function RequestShortener(directory) {
|
|||
this.parentDirectoryRegExp = parentDirectoryRegExp;
|
||||
this.buildinsRegExp = buildinsRegExp;
|
||||
this.node_modulesRegExp = /\/node_modules\//g;
|
||||
this.index_jsRegExp = /\/index.js!/g;
|
||||
this.index_jsRegExp = /\/index.js(!|\?|\(query\))/g;
|
||||
}
|
||||
module.exports = RequestShortener;
|
||||
|
||||
|
@ -35,6 +35,6 @@ RequestShortener.prototype.shorten = function(request) {
|
|||
request = request.replace(this.buildinsRegExp, "!(webpack)");
|
||||
request = request.replace(/\\/g, "/");
|
||||
request = request.replace(this.node_modulesRegExp, "/~/");
|
||||
request = request.replace(this.index_jsRegExp, "!");
|
||||
request = request.replace(this.index_jsRegExp, "$1");
|
||||
return request.replace(/^!|!$/, "");
|
||||
};
|
||||
|
|
|
@ -23,7 +23,8 @@ SourceMapDevToolPlugin.prototype.apply = function(compiler) {
|
|||
var asset = this.assets[file];
|
||||
var sourceMap = asset.map();
|
||||
if(sourceMap) {
|
||||
sourceMap.sources = sourceMap.sources.map(function(source) {
|
||||
for(var i = 0; i < sourceMap.sources.length; i++) {
|
||||
var source = sourceMap.sources[i];
|
||||
var str;
|
||||
var module = compilation.findModule(source);
|
||||
if(module)
|
||||
|
@ -31,9 +32,13 @@ SourceMapDevToolPlugin.prototype.apply = function(compiler) {
|
|||
else
|
||||
str = requestShortener.shorten(source);
|
||||
while(str.indexOf("?") >= 0 && str.indexOf("?") < str.lastIndexOf("!"))
|
||||
str = str.replace(/\?/, "(query)")
|
||||
return str;
|
||||
});
|
||||
str = str.replace(/\?/, "(query)");
|
||||
var idx;
|
||||
while((idx = sourceMap.sources.indexOf(str) >= 0) && (idx < i)) {
|
||||
str += "*";
|
||||
}
|
||||
sourceMap.sources[i] = str;
|
||||
}
|
||||
sourceMap.sourceRoot = "webpack-module://";
|
||||
if(sourceMapFilename) {
|
||||
var sourceMapFile = sourceMapFilename
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "webpack",
|
||||
"version": "0.10.0-beta4",
|
||||
"version": "0.10.0-beta5",
|
||||
"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": {
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
// Should not break it... should not include complete directory...
|
||||
require = require("enhanced-require")(module);
|
||||
if(typeof define != "function") var define = require.define;
|
||||
// Should not break it...
|
||||
if(typeof require !== "function")
|
||||
var require = require("amdrequire");
|
||||
if(typeof define != "function")
|
||||
var define = require("amdefine");
|
||||
|
||||
function test(cond, message) {
|
||||
if(!cond) throw new Error(message);
|
||||
|
@ -149,6 +151,12 @@ describe("main", function() {
|
|||
var require = 123;
|
||||
require.should.be.eql(123);
|
||||
}());
|
||||
(function() {
|
||||
function require() {
|
||||
return 123;
|
||||
};
|
||||
require("error").should.be.eql(123);
|
||||
}());
|
||||
(function() {
|
||||
var module = 1233;
|
||||
module.should.be.eql(1233);
|
||||
|
|
Loading…
Reference in New Issue