Skip to content

Commit 7b8fa11

Browse files
committed
Remove v3 deprecated APIs
1 parent e8c2596 commit 7b8fa11

File tree

7 files changed

+16
-61
lines changed

7 files changed

+16
-61
lines changed

lib/Chunk.js

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

7-
const util = require("util");
87
const SortableSet = require("./util/SortableSet");
98
const GraphHelpers = require("./GraphHelpers");
109
let debugId = 1000;
@@ -21,8 +20,6 @@ const sortByIdentifier = (a, b) => {
2120
return 0;
2221
};
2322

24-
const getFrozenArray = set => Object.freeze(Array.from(set));
25-
2623
const getModulesIdent = set => {
2724
set.sort();
2825
let str = "";
@@ -417,16 +414,7 @@ class Chunk {
417414
}
418415
}
419416

420-
Object.defineProperty(Chunk.prototype, "modules", {
421-
configurable: false,
422-
get: util.deprecate(function() {
423-
return this._modules.getFromCache(getFrozenArray);
424-
}, "Chunk.modules is deprecated. Use Chunk.getNumberOfModules/mapModules/forEachModule/containsModule instead."),
425-
set: util.deprecate(function(value) {
426-
this.setModules(value);
427-
}, "Chunk.modules is deprecated. Use Chunk.addModule/removeModule instead.")
428-
});
429-
417+
// TODO remove in webpack 5
430418
Object.defineProperty(Chunk.prototype, "chunks", {
431419
configurable: false,
432420
get() {
@@ -437,6 +425,7 @@ Object.defineProperty(Chunk.prototype, "chunks", {
437425
}
438426
});
439427

428+
// TODO remove in webpack 5
440429
Object.defineProperty(Chunk.prototype, "parents", {
441430
configurable: false,
442431
get() {
@@ -447,6 +436,7 @@ Object.defineProperty(Chunk.prototype, "parents", {
447436
}
448437
});
449438

439+
// TODO remove in webpack 5
450440
Object.defineProperty(Chunk.prototype, "blocks", {
451441
configurable: false,
452442
get() {
@@ -457,6 +447,7 @@ Object.defineProperty(Chunk.prototype, "blocks", {
457447
}
458448
});
459449

450+
// TODO remove in webpack 5
460451
Object.defineProperty(Chunk.prototype, "entrypoints", {
461452
configurable: false,
462453
get() {

lib/Compilation.js

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

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

1705+
// TODO remove in webpack 5
17041706
Object.defineProperty(Compilation.prototype, "moduleTemplate", {
17051707
configurable: false,
17061708
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 = {};
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) {
@@ -302,6 +300,7 @@ class Module extends DependenciesBlock {
302300
}
303301
}
304302

303+
// TODO remove in webpack 5
305304
Object.defineProperty(Module.prototype, "entry", {
306305
configurable: false,
307306
get() {
@@ -312,16 +311,7 @@ Object.defineProperty(Module.prototype, "entry", {
312311
}
313312
});
314313

315-
Object.defineProperty(Module.prototype, "chunks", {
316-
configurable: false,
317-
get: util.deprecate(function() {
318-
return this._chunks.getFromCache(getFrozenArray);
319-
}, "Module.chunks: Use Module.forEachChunk/mapChunks/getNumberOfChunks/isInChunk/addChunk/removeChunk instead"),
320-
set() {
321-
throw new Error("Readonly. Use Module.addChunk/removeChunk to modify chunks.");
322-
}
323-
});
324-
314+
// TODO remove in webpack 5
325315
Object.defineProperty(Module.prototype, "meta", {
326316
configurable: false,
327317
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)