Skip to content

Commit 75b93a1

Browse files
committed
fixes webpack#2455, fixes webpack#2460
1 parent 9162f9e commit 75b93a1

File tree

9 files changed

+33
-15
lines changed

9 files changed

+33
-15
lines changed

lib/dependencies/HarmonyAcceptDependency.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,6 @@ HarmonyAcceptDependency.Template.prototype.apply = function(dep, source, outputO
2222
var content = dep.dependencies.map(function(d) {
2323
return HarmonyImportDependency.makeStatement(false, d, outputOptions, requestShortener);
2424
}).join("");
25-
source.insert(dep.range[0], "function(callback) { " + content + " (");
26-
source.insert(dep.range[1], "()); }");
25+
source.insert(dep.range[0], "function(__WEBPACK_OUTDATED_DEPENDENCIES__) { " + content + " (");
26+
source.insert(dep.range[1], ")(__WEBPACK_OUTDATED_DEPENDENCIES__); }");
2727
};

lib/dependencies/HarmonyImportDependencyParserPlugin.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,13 @@ module.exports = AbstractPlugin.create({
3535
},
3636
"call imported var": function(expr) {
3737
var args = expr.arguments;
38+
var fullExpr = expr;
3839
expr = expr.callee;
3940
var name = expr.name;
4041
var settings = this.state.harmonySpecifier["$" + name];
4142
var dep = new HarmonyImportSpecifierDependency(settings[0], settings[1], settings[2], name, expr.range);
42-
dep.call = true;
43+
dep.callArgs = args;
44+
dep.call = fullExpr;
4345
dep.loc = expr.loc;
4446
this.state.current.addDependency(dep);
4547
if(args)

lib/dependencies/HarmonyImportSpecifierDependency.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,11 @@ HarmonyImportSpecifierDependency.Template.prototype.apply = function(dep, source
5050
} else {
5151
content = "/* harmony namespace import */ " + dep.importedVar;
5252
}
53-
if(dep.call) {
54-
content = "" + content + ".bind()";
53+
if(!dep.call) {
54+
source.replace(dep.range[0], dep.range[1] - 1, content);
55+
} else if(dep.callArgs.length > 0) {
56+
source.replace(dep.range[0], dep.callArgs[0].range[0] - 1, content + ".call(undefined, ");
57+
} else {
58+
source.replace(dep.call.range[0], dep.call.range[1] - 1, content + ".call()");
5559
}
56-
source.replace(dep.range[0], dep.range[1] - 1, content);
5760
};

lib/dependencies/RequireEnsureDependency.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ RequireEnsureDependency.Template = function RequireEnsureDependencyTemplate() {}
2020
RequireEnsureDependency.Template.prototype.apply = function(dep, source, outputOptions, requestShortener) {
2121
var depBlock = dep.block;
2222
var wrapper = DepBlockHelpers.getLoadDepBlockWrapper(depBlock, outputOptions, requestShortener, /*require.e*/ "nsure");
23-
wrapper[1] = ".bind(null, __webpack_require__)" + wrapper[1];
24-
source.replace(depBlock.expr.range[0], depBlock.expr.arguments[1].range[0] - 1, wrapper[0]);
25-
source.replace(depBlock.expr.arguments[1].range[1], depBlock.expr.range[1] - 1, wrapper[1]);
23+
source.replace(depBlock.expr.range[0], depBlock.expr.arguments[1].range[0] - 1, wrapper[0] + "(");
24+
source.replace(depBlock.expr.arguments[1].range[1], depBlock.expr.range[1] - 1, ").bind(null, __webpack_require__)" + wrapper[1]);
2625
};
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = "async";

test/cases/parsing/es6.nominimize/index.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
"use strict";
22

3+
import a from "./a";
4+
35
it("should parse classes", function() {
46
class MyClass {
57
constructor() {
@@ -32,6 +34,17 @@ it("should parse arrow function", function() {
3234
(() => {
3335
return require("./a");
3436
})().should.be.eql("a");
37+
require.ensure([], () => {
38+
require("./a");
39+
});
40+
require.ensure([], () => {
41+
require("./async");
42+
});
43+
if(module.hot) {
44+
module.hot.accept("./a", () => {
45+
var x = 1;
46+
});
47+
}
3548
});
3649

3750
it("should parse template literals", function() {

test/statsCases/chunks/expected.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Hash: 55b4e00b04fd0c502b1f
22
Time: Xms
33
Asset Size Chunks Chunk Names
44
bundle.js 4.55 kB 0 [emitted] main
5-
1.bundle.js 250 bytes 1 [emitted]
5+
1.bundle.js 252 bytes 1 [emitted]
66
2.bundle.js 107 bytes 2 [emitted]
77
3.bundle.js 202 bytes 3 [emitted]
88
chunk {0} bundle.js (main) 73 bytes [rendered]

test/statsCases/optimize-chunks/expected.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
Hash: e3dc693bc52a75b4a39b
22
Time: Xms
33
Asset Size Chunks Chunk Names
4-
0.js 243 bytes 0 [emitted] cir1
4+
0.js 245 bytes 0 [emitted] cir1
55
1.js 215 bytes 1, 2 [emitted] abd
66
2.js 131 bytes 2 [emitted] ab
7-
main.js 5.27 kB 3 [emitted] main
8-
4.js 258 bytes 4 [emitted] cir2
7+
main.js 5.28 kB 3 [emitted] main
8+
4.js 260 bytes 4 [emitted] cir2
99
5.js 138 bytes 5, 7 [emitted] chunk
10-
6.js 317 bytes 6, 4 [emitted] cir2 from cir1
10+
6.js 319 bytes 6, 4 [emitted] cir2 from cir1
1111
7.js 79 bytes 7 [emitted] ac in ab
1212
chunk {0} 0.js (cir1) 81 bytes {3} {6} {4} [rendered]
1313
> cir1 [7] (webpack)/test/statsCases/optimize-chunks/index.js 13:0-54

test/statsCases/preset-verbose/expected.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Hash: 8ca45b6d16d1f1e8be32
22
Time: Xms
33
Asset Size Chunks Chunk Names
44
main.js 4.54 kB 0 [emitted] main
5-
1.js 250 bytes 1 [emitted]
5+
1.js 252 bytes 1 [emitted]
66
2.js 107 bytes 2 [emitted]
77
3.js 202 bytes 3 [emitted]
88
chunk {0} main.js (main) 73 bytes [rendered]

0 commit comments

Comments
 (0)