Skip to content

Commit 47d00a5

Browse files
committed
use util.deprecate to deprecate properties in ContextModule
1 parent 4b9939e commit 47d00a5

File tree

1 file changed

+51
-26
lines changed

1 file changed

+51
-26
lines changed

lib/ContextModule.js

Lines changed: 51 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
*/
55
"use strict";
66
const path = require("path");
7+
const util = require("util");
78
const Module = require("./Module");
89
const OriginalSource = require("webpack-sources").OriginalSource;
910
const RawSource = require("webpack-sources").RawSource;
@@ -23,32 +24,6 @@ class ContextModule extends Module {
2324
this.built = false;
2425
}
2526

26-
/* These getters are for backwards compatibility */
27-
get recursive() {
28-
console.error("contextModule.recursive has been moved to contextModule.options.recursive");
29-
return this.options.recursive;
30-
}
31-
32-
get regExp() {
33-
console.error("contextModule.regExp has been moved to contextModule.options.regExp");
34-
return this.options.regExp;
35-
}
36-
37-
get addon() {
38-
console.error("contextModule.addon has been moved to contextModule.options.addon");
39-
return this.options.addon;
40-
}
41-
42-
get async() {
43-
console.error("contextModule.async has been moved to contextModule.options.async");
44-
return this.options.async;
45-
}
46-
47-
get chunkName() {
48-
console.error("contextModule.chunkName has been moved to contextModule.options.chunkName");
49-
return this.options.chunkName;
50-
}
51-
5227
prettyRegExp(regexString) {
5328
// remove the "/" at the front and the beginning
5429
// "/foo/" -> "foo"
@@ -463,4 +438,54 @@ webpackEmptyAsyncContext.id = ${JSON.stringify(id)};`;
463438
}
464439
}
465440

441+
Object.defineProperty(ContextModule.prototype, "recursive", {
442+
configurable: false,
443+
get: util.deprecate(function() {
444+
return this.options.recursive;
445+
}, "ContextModule.recursive has been moved to ContextModule.options.recursive"),
446+
set: util.deprecate(function(value) {
447+
this.options.recursive = value;
448+
}, "ContextModule.recursive has been moved to ContextModule.options.recursive")
449+
});
450+
451+
Object.defineProperty(ContextModule.prototype, "regExp", {
452+
configurable: false,
453+
get: util.deprecate(function() {
454+
return this.options.regExp;
455+
}, "ContextModule.regExp has been moved to ContextModule.options.regExp"),
456+
set: util.deprecate(function(value) {
457+
this.options.regExp = value;
458+
}, "ContextModule.regExp has been moved to ContextModule.options.regExp")
459+
});
460+
461+
Object.defineProperty(ContextModule.prototype, "addon", {
462+
configurable: false,
463+
get: util.deprecate(function() {
464+
return this.options.addon;
465+
}, "ContextModule.addon has been moved to ContextModule.options.addon"),
466+
set: util.deprecate(function(value) {
467+
this.options.addon = value;
468+
}, "ContextModule.addon has been moved to ContextModule.options.addon")
469+
});
470+
471+
Object.defineProperty(ContextModule.prototype, "async", {
472+
configurable: false,
473+
get: util.deprecate(function() {
474+
return this.options.async;
475+
}, "ContextModule.async has been moved to ContextModule.options.async"),
476+
set: util.deprecate(function(value) {
477+
this.options.async = value;
478+
}, "ContextModule.async has been moved to ContextModule.options.async")
479+
});
480+
481+
Object.defineProperty(ContextModule.prototype, "chunkName", {
482+
configurable: false,
483+
get: util.deprecate(function() {
484+
return this.options.chunkName;
485+
}, "ContextModule.chunkName has been moved to ContextModule.options.chunkName"),
486+
set: util.deprecate(function(value) {
487+
this.options.chunkName = value;
488+
}, "ContextModule.chunkName has been moved to ContextModule.options.chunkName")
489+
});
490+
466491
module.exports = ContextModule;

0 commit comments

Comments
 (0)