Skip to content

Commit a3bfd1e

Browse files
iDamsjhnns
authored andcommitted
Remove automatic -loader module name extension (webpack#3102)
* fix-2986: Remove automatic -loader module name extension * remove-automatic-loader-extension: update examples * fix-2986: Remove automatic -loader module name extension * fix-2986: Remove automatic -loader module name extension * fix-2986: Remove automatic -loader module name extension * Revert changes from spaces to tabs
1 parent 80bd894 commit a3bfd1e

18 files changed

Lines changed: 59 additions & 53 deletions

File tree

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
require("bundle!./file.js")(function(fileJsExports) {
1+
require("bundle-loader!./file.js")(function(fileJsExports) {
22
console.log(fileJsExports);
3-
});
3+
});
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
module.exports = {
22
module: {
33
loaders: [
4-
{ test: /\.coffee$/, loader: "coffee" }
4+
{ test: /\.coffee$/, loader: "coffee-loader" }
55
]
66
},
77
resolve: {
88
extensions: [".web.coffee", ".web.js", ".coffee", ".js"]
99
}
10-
}
10+
}

examples/hybrid-routing/router.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ window.onLinkToPage = function onLinkToPage(name) { // name is "a" or "b"
1515
// -> Pages are only loaded on demand
1616

1717
// This line may throw a exception on runtime if the page wasn't found.
18-
var pageBundle = require("bundle!./" + name + "Page");
18+
var pageBundle = require("bundle-loader!./" + name + "Page");
1919

2020
// Wait until the chunk is loaded
2121
pageBundle(function(page) {
2222
render(page);
2323
});
24-
}
24+
}

examples/loader/example.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ console.dir(require("./loader!./file"));
33

44
// use buildin json loader
55
console.dir(require("./test.json")); // default by extension
6-
console.dir(require("!json!./test.json")); // manual
6+
console.dir(require("!json-loader!./test.json")); // manual

examples/loader/webpack.config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module.exports = {
22
module: {
33
loaders: [
4-
{ test: /\.json$/, loader: "json" }
4+
{ test: /\.json$/, loader: "json-loader" }
55
]
66
}
7-
}
7+
}

examples/web-worker/README.md

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# example.js
33

44
``` javascript
5-
var Worker = require("worker!./worker");
5+
var Worker = require("worker-loader!./worker");
66
var worker = new Worker;
77
worker.postMessage("b");
88
worker.onmessage = function(event) {
@@ -335,9 +335,9 @@ Time: 191ms
335335
hash.worker.js 3.83 kB [emitted]
336336
output.js 3.18 kB 0 [emitted] main
337337
Entrypoint main = output.js
338-
chunk {0} output.js (main) 297 bytes [entry] [rendered]
339-
> main [1] ./example.js
340-
[0] (webpack)/~/worker-loader!./worker.js 96 bytes {0} [not cacheable] [built]
338+
chunk {0} output.js (main) 302 bytes [entry] [rendered]
339+
> main [1] ./example.js
340+
[0] (webpack)/~/worker-loader!./worker.js 96 bytes {0} [built]
341341
cjs require worker!./worker [1] ./example.js 1:13-39
342342
[1] ./example.js 201 bytes {0} [built]
343343
Child worker:
@@ -358,9 +358,16 @@ Child worker:
358358
[4] ../require.context/templates/c.js 80 bytes {0} [optional] [built]
359359
context element ./c [0] ../require.context/templates ^\.\/.*$
360360
context element ./c.js [0] ../require.context/templates ^\.\/.*$
361+
362+
8ee92337ff6112b0fe42a6aa1f479e12b4423ae3
361363
chunk {1} hash.worker.js (main) 162 bytes [entry] [rendered]
362-
> main [1] ./worker.js
364+
> main [1] ./worker.js
363365
[1] ./worker.js 162 bytes {1} [built]
366+
=======
367+
chunk {1} hash.worker.js (main) 168 bytes [entry] [rendered]
368+
> main [1] ./worker.js
369+
[1] ./worker.js 168 bytes {1} [built]
370+
>>>>>>> fix-2986: Remove automatic -loader module name extension
364371
```
365372

366373
## Minimized (uglify-js, no zip)
@@ -374,9 +381,9 @@ Time: 329ms
374381
hash.worker.js 842 bytes [emitted]
375382
output.js 655 bytes 0 [emitted] main
376383
Entrypoint main = output.js
377-
chunk {0} output.js (main) 297 bytes [entry] [rendered]
378-
> main [1] ./example.js
379-
[0] (webpack)/~/worker-loader!./worker.js 96 bytes {0} [not cacheable] [built]
384+
chunk {0} output.js (main) 302 bytes [entry] [rendered]
385+
> main [1] ./example.js
386+
[0] (webpack)/~/worker-loader!./worker.js 96 bytes {0} [built]
380387
cjs require worker!./worker [1] ./example.js 1:13-39
381388
[1] ./example.js 201 bytes {0} [built]
382389
Child worker:
@@ -397,7 +404,7 @@ Child worker:
397404
[4] ../require.context/templates/c.js 80 bytes {0} [optional] [built]
398405
context element ./c [0] ../require.context/templates ^\.\/.*$
399406
context element ./c.js [0] ../require.context/templates ^\.\/.*$
400-
chunk {1} hash.worker.js (main) 162 bytes [entry] [rendered]
401-
> main [1] ./worker.js
402-
[1] ./worker.js 162 bytes {1} [built]
407+
chunk {1} hash.worker.js (main) 168 bytes [entry] [rendered]
408+
> main [1] ./worker.js
409+
[1] ./worker.js 168 bytes {1} [built]
403410
```

examples/web-worker/example.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
var Worker = require("worker!./worker");
1+
var Worker = require("worker-loader!./worker");
22
var worker = new Worker;
33
worker.postMessage("b");
44
worker.onmessage = function(event) {
55
var templateB = event.data; // "This text was generated by template B"
6-
}
6+
}
Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
var webpack = require("../../");
22
module.exports = {
3-
plugins: [
4-
new webpack.LoaderOptionsPlugin({
5-
options: {
6-
worker: {
7-
output: {
8-
filename: "hash.worker.js",
9-
chunkFilename: "[id].hash.worker.js"
10-
}
11-
}
12-
}
13-
})
14-
]
3+
plugins: [
4+
new webpack.LoaderOptionsPlugin({
5+
options: {
6+
worker: {
7+
output: {
8+
filename: "hash.worker.js",
9+
chunkFilename: "[id].hash.worker.js"
10+
}
11+
}
12+
}
13+
})
14+
]
1515
}

lib/WebpackOptionsDefaulter.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@ function WebpackOptionsDefaulter() {
8989
this.set("resolveLoader.unsafeCache", true);
9090
this.set("resolveLoader.mainFields", ["loader", "main"]);
9191
this.set("resolveLoader.extensions", [".js", ".json"]);
92-
this.set("resolveLoader.moduleExtensions", ["-loader"]);
9392
}
9493
module.exports = WebpackOptionsDefaulter;
9594

test/cases/compile/deduplication-bundle-loader/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
it("should load a duplicate module with different dependencies correctly", function(done) {
2-
var a = require("bundle!./a/file");
3-
var b = require("bundle!./b/file");
2+
var a = require("bundle-loader!./a/file");
3+
var b = require("bundle-loader!./b/file");
44
(typeof a).should.be.eql("function");
55
(typeof b).should.be.eql("function");
66
a(function(ra) {

0 commit comments

Comments
 (0)