Skip to content

Commit 9c8098c

Browse files
authored
Merge pull request webpack#6370 from webpack/remove_v3_deprecated
Remove v3 deprecated APIs
2 parents f2141e1 + b706309 commit 9c8098c

File tree

7 files changed

+16
-60
lines changed

7 files changed

+16
-60
lines changed

lib/Chunk.js

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ const sortByIdentifier = (a, b) => {
2121
return 0;
2222
};
2323

24-
const getFrozenArray = set => Object.freeze(Array.from(set));
25-
2624
const getModulesIdent = set => {
2725
set.sort();
2826
let str = "";
@@ -423,16 +421,7 @@ Object.defineProperty(Chunk.prototype, "mapModules", {
423421
}, "Chunk.mapModules: Use Array.from(chunk.modulesIterable, fn) instead")
424422
});
425423

426-
Object.defineProperty(Chunk.prototype, "modules", {
427-
configurable: false,
428-
get: util.deprecate(function() {
429-
return this._modules.getFromCache(getFrozenArray);
430-
}, "Chunk.modules is deprecated. Use Chunk.getNumberOfModules/containsModule/modulesIterable instead."),
431-
set: util.deprecate(function(value) {
432-
this.setModules(value);
433-
}, "Chunk.modules is deprecated. Use Chunk.addModule/removeModule instead.")
434-
});
435-
424+
// TODO remove in webpack 5
436425
Object.defineProperty(Chunk.prototype, "chunks", {
437426
configurable: false,
438427
get() {
@@ -443,6 +432,7 @@ Object.defineProperty(Chunk.prototype, "chunks", {
443432
}
444433
});
445434

435+
// TODO remove in webpack 5
446436
Object.defineProperty(Chunk.prototype, "parents", {
447437
configurable: false,
448438
get() {
@@ -453,6 +443,7 @@ Object.defineProperty(Chunk.prototype, "parents", {
453443
}
454444
});
455445

446+
// TODO remove in webpack 5
456447
Object.defineProperty(Chunk.prototype, "blocks", {
457448
configurable: false,
458449
get() {
@@ -463,6 +454,7 @@ Object.defineProperty(Chunk.prototype, "blocks", {
463454
}
464455
});
465456

457+
// TODO remove in webpack 5
466458
Object.defineProperty(Chunk.prototype, "entrypoints", {
467459
configurable: false,
468460
get() {

lib/Compilation.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1699,10 +1699,12 @@ class Compilation extends Tapable {
16991699
}
17001700
}
17011701

1702+
// TODO remove in webpack 5
17021703
Compilation.prototype.applyPlugins = util.deprecate(function(name, ...args) {
17031704
this.hooks[name.replace(/[- ]([a-z])/g, match => match[1].toUpperCase())].call(...args);
17041705
}, "Compilation.applyPlugins is deprecated. Use new API on `.hooks` instead");
17051706

1707+
// TODO remove in webpack 5
17061708
Object.defineProperty(Compilation.prototype, "moduleTemplate", {
17071709
configurable: false,
17081710
get: util.deprecate(function() {

lib/Compiler.js

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ class Compiler extends Tapable {
8282
this.contextTimestamps = new Map();
8383

8484
this.resolverFactory = new ResolverFactory();
85+
86+
// TODO remove in webpack 5
8587
this.resolvers = {
8688
normal: {
8789
plugins: util.deprecate(
@@ -144,30 +146,6 @@ class Compiler extends Tapable {
144146
)
145147
}
146148
};
147-
this.parser = {
148-
plugin: util.deprecate(
149-
(hook, fn) => {
150-
this.plugin("compilation", (compilation, data) => {
151-
data.normalModuleFactory.plugin("parser", parser => {
152-
parser.plugin(hook, fn);
153-
});
154-
});
155-
},
156-
"webpack: Using compiler.parser is deprecated.\n" +
157-
"Use compiler.plugin(\"compilation\", function(compilation, data) {\n data.normalModuleFactory.plugin(\"parser\", function(parser, options) { parser.plugin(/* ... */); });\n}); instead. "
158-
),
159-
apply: util.deprecate(
160-
(...args) => {
161-
this.plugin("compilation", (compilation, data) => {
162-
data.normalModuleFactory.plugin("parser", parser => {
163-
parser.apply(...args);
164-
});
165-
});
166-
},
167-
"webpack: Using compiler.parser is deprecated.\n" +
168-
"Use compiler.plugin(\"compilation\", function(compilation, data) {\n data.normalModuleFactory.plugin(\"parser\", function(parser, options) { parser.apply(/* ... */); });\n}); instead. "
169-
)
170-
};
171149

172150
this.options = {};
173151

lib/ContextModule.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -597,6 +597,7 @@ webpackEmptyAsyncContext.id = ${JSON.stringify(id)};`;
597597
}
598598
}
599599

600+
// TODO remove in webpack 5
600601
Object.defineProperty(ContextModule.prototype, "recursive", {
601602
configurable: false,
602603
get: util.deprecate(function() {
@@ -607,6 +608,7 @@ Object.defineProperty(ContextModule.prototype, "recursive", {
607608
}, "ContextModule.recursive has been moved to ContextModule.options.recursive")
608609
});
609610

611+
// TODO remove in webpack 5
610612
Object.defineProperty(ContextModule.prototype, "regExp", {
611613
configurable: false,
612614
get: util.deprecate(function() {
@@ -617,6 +619,7 @@ Object.defineProperty(ContextModule.prototype, "regExp", {
617619
}, "ContextModule.regExp has been moved to ContextModule.options.regExp")
618620
});
619621

622+
// TODO remove in webpack 5
620623
Object.defineProperty(ContextModule.prototype, "addon", {
621624
configurable: false,
622625
get: util.deprecate(function() {
@@ -627,6 +630,7 @@ Object.defineProperty(ContextModule.prototype, "addon", {
627630
}, "ContextModule.addon has been moved to ContextModule.options.addon")
628631
});
629632

633+
// TODO remove in webpack 5
630634
Object.defineProperty(ContextModule.prototype, "async", {
631635
configurable: false,
632636
get: util.deprecate(function() {
@@ -637,6 +641,7 @@ Object.defineProperty(ContextModule.prototype, "async", {
637641
}, "ContextModule.async has been moved to ContextModule.options.mode")
638642
});
639643

644+
// TODO remove in webpack 5
640645
Object.defineProperty(ContextModule.prototype, "chunkName", {
641646
configurable: false,
642647
get: util.deprecate(function() {

lib/Module.js

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ const sortByDebugId = (a, b) => {
2323
return a.debugId - b.debugId;
2424
};
2525

26-
const getFrozenArray = set => Object.freeze(Array.from(set));
27-
2826
class Module extends DependenciesBlock {
2927

3028
constructor(type) {
@@ -310,6 +308,7 @@ Object.defineProperty(Module.prototype, "mapChunks", {
310308
}, "Module.mapChunks: Use Array.from(module.chunksIterable, fn) instead")
311309
});
312310

311+
// TODO remove in webpack 5
313312
Object.defineProperty(Module.prototype, "entry", {
314313
configurable: false,
315314
get() {
@@ -320,16 +319,7 @@ Object.defineProperty(Module.prototype, "entry", {
320319
}
321320
});
322321

323-
Object.defineProperty(Module.prototype, "chunks", {
324-
configurable: false,
325-
get: util.deprecate(function() {
326-
return this._chunks.getFromCache(getFrozenArray);
327-
}, "Module.chunks: Use Module.chunksIterable/getNumberOfChunks/isInChunk/addChunk/removeChunk instead"),
328-
set() {
329-
throw new Error("Readonly. Use Module.addChunk/removeChunk to modify chunks.");
330-
}
331-
});
332-
322+
// TODO remove in webpack 5
333323
Object.defineProperty(Module.prototype, "meta", {
334324
configurable: false,
335325
get: util.deprecate(function() {

lib/ModuleReason.js

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
*/
55
"use strict";
66

7-
const util = require("util");
8-
97
class ModuleReason {
108
constructor(module, dependency, explanation) {
119
this.module = module;
@@ -42,14 +40,4 @@ class ModuleReason {
4240
}
4341
}
4442

45-
Object.defineProperty(ModuleReason.prototype, "chunks", {
46-
configurable: false,
47-
get: util.deprecate(function() {
48-
return this._chunks ? Array.from(this._chunks) : null;
49-
}, "ModuleReason.chunks: Use ModuleReason.hasChunk/rewriteChunks instead"),
50-
set() {
51-
throw new Error("Readonly. Use ModuleReason.rewriteChunks to modify chunks.");
52-
}
53-
});
54-
5543
module.exports = ModuleReason;

lib/util/StackedSetMap.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ class StackedSetMap {
115115
}
116116
}
117117

118+
// TODO remove in webpack 5
118119
StackedSetMap.prototype.push = util.deprecate(function(item) {
119120
this.add(item);
120121
}, "This is no longer an Array: Use add instead.");

0 commit comments

Comments
 (0)