Skip to content

Commit

Permalink
Merge pull request #9328 from jchapman127/bugfix/match-resource
Browse files Browse the repository at this point in the history
[WIP] Fixes #9053: Wrong loaders order when using inline match resource
  • Loading branch information
sokra committed Jul 1, 2019
2 parents 5523a0a + fec4d53 commit 5c7996d
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/NormalModuleFactory.js
Expand Up @@ -335,7 +335,11 @@ class NormalModuleFactory extends Tapable {
],
(err, results) => {
if (err) return callback(err);
loaders = results[0].concat(loaders, results[1], results[2]);
if (matchResource === undefined) {
loaders = results[0].concat(loaders, results[1], results[2]);
} else {
loaders = results[0].concat(results[1], loaders, results[2]);
}
process.nextTick(() => {
const type = settings.type;
const resolveOptions = settings.resolve;
Expand Down
1 change: 1 addition & 0 deletions test/configCases/loaders/issue-9053/b.js
@@ -0,0 +1 @@
module.exports = ["b"];
1 change: 1 addition & 0 deletions test/configCases/loaders/issue-9053/c.js
@@ -0,0 +1 @@
module.exports = ["c"];
17 changes: 17 additions & 0 deletions test/configCases/loaders/issue-9053/index.js
@@ -0,0 +1,17 @@
it("should apply inline loaders before matchResource", function() {
var foo = require("c.js!=!loader1!./b.js");

expect(foo).toEqual(["b", "1", "2"]);
});

it("should apply config loaders before inline loaders", function() {
var foo = require("loader1!./c.js");

expect(foo).toEqual(["c", "2", "1"]);
});

it("should not apply config loaders when matchResource is used", function() {
var foo = require("d.js!=!loader1!./c.js");

expect(foo).toEqual(["c", "1", "3"]);
});
3 changes: 3 additions & 0 deletions test/configCases/loaders/issue-9053/node_modules/loader1.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions test/configCases/loaders/issue-9053/node_modules/loader2.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions test/configCases/loaders/issue-9053/node_modules/loader3.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions test/configCases/loaders/issue-9053/webpack.config.js
@@ -0,0 +1,14 @@
module.exports = {
module: {
rules: [
{
test: /c\.js$/,
use: ["loader2"]
},
{
test: /d\.js$/,
use: ["loader3"]
}
]
}
};

0 comments on commit 5c7996d

Please sign in to comment.