Skip to content

Commit e18f7d6

Browse files
committed
fix(loader): drop "2 applied rules" warning
1 parent 1f0f583 commit e18f7d6

3 files changed

Lines changed: 0 additions & 40 deletions

File tree

lib/exceptions.js

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,6 @@ class ExtractPluginMissingException extends LoaderException {
2929

3030
class InvalidRuntimeException extends LoaderException {}
3131

32-
class SeveralRulesAppliedException extends LoaderException {
33-
constructor(resource, rules) {
34-
super(`${rules.length} rules applies to ${resource}`);
35-
}
36-
}
37-
3832
class RemainingLoadersInExtractModeException extends LoaderException {
3933
constructor() {
4034
super(`Some loaders will be applied after ${PACKAGE_NAME} in extract mode`);
@@ -45,5 +39,4 @@ exports.LoaderException = LoaderException;
4539
exports.InvalidSvg = InvalidSvg;
4640
exports.ExtractPluginMissingException = ExtractPluginMissingException;
4741
exports.InvalidRuntimeException = InvalidRuntimeException;
48-
exports.SeveralRulesAppliedException = SeveralRulesAppliedException;
4942
exports.RemainingLoadersInExtractModeException = RemainingLoadersInExtractModeException;

lib/loader.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,6 @@ module.exports = function loader(content) {
2626
const issuer = loaderContext._module && loaderContext._module.issuer;
2727
const matchedRules = getMatchedRules(resource, getLoadersRules(compiler), issuer);
2828

29-
if (matchedRules.length > 1 && !compiler.isChild()) {
30-
this.emitWarning(new Exceptions.SeveralRulesAppliedException(resource, matchedRules));
31-
}
32-
3329
if (!content.includes('<svg')) {
3430
throw new Exceptions.InvalidSvg(content, matchedRules);
3531
}

test/loader.test.js

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -37,20 +37,6 @@ describe('loader and plugin', () => {
3737
errors.should.be.lengthOf(1);
3838
errors[0].error.should.be.instanceOf(Exceptions.InvalidRuntimeException);
3939
});
40-
41-
it('should warn if several rules applied to module without issuer applied', async () => {
42-
const { warnings } = await compileAndNotReject({
43-
entry: './entry',
44-
module: rules(
45-
svgRule(),
46-
rule({ test: /\.svg$/, loader: loaderPath })
47-
)
48-
});
49-
50-
// TODO loader applies 2 times so warning also will me emitted 2 times
51-
warnings.should.be.lengthOf(2);
52-
warnings[0].warning.should.be.instanceOf(Exceptions.SeveralRulesAppliedException);
53-
});
5440
});
5541

5642
it('should allow to use custom runtime generator', async () => {
@@ -65,21 +51,6 @@ describe('loader and plugin', () => {
6551

6652
assets['main.js'].source().should.contain('olala');
6753
});
68-
69-
it('should filter rules against issuer', async () => {
70-
const { warnings } = await compileAndNotReject({
71-
entry: './entry',
72-
module: rules(
73-
svgRule(),
74-
rule({ test: /\.svg$/, loader: loaderPath, issuer: /\.css$/ })
75-
)
76-
});
77-
78-
warnings.should.be.lengthOf(isWebpack1 ? 2 : 0);
79-
if (isWebpack1) {
80-
warnings[0].warning.should.be.instanceOf(Exceptions.SeveralRulesAppliedException);
81-
}
82-
});
8354
});
8455

8556
describe('extract mode', () => {

0 commit comments

Comments
 (0)