Skip to content

Commit 2cf8023

Browse files
Fix compatibility with plugins depending on plugin properties (e.g. HappyPack's 'name' and 'id' references)
1 parent 1212447 commit 2cf8023

3 files changed

Lines changed: 19 additions & 2 deletions

File tree

WrappedPlugin/index.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,22 @@ module.exports.WrappedPlugin = class WrappedPlugin {
103103
this._smp = smp;
104104

105105
this.apply = this.apply.bind(this);
106+
107+
const wp = this;
108+
return new Proxy(plugin, {
109+
get(target, property) {
110+
if (property === "apply") {
111+
return wp.apply;
112+
}
113+
return target[property];
114+
},
115+
set: (target, property, value) => {
116+
return Reflect.set(target, property, value);
117+
},
118+
deleteProperty: (target, property) => {
119+
return Reflect.deleteProperty(target, property);
120+
},
121+
});
106122
}
107123

108124
apply(compiler) {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "speed-measure-webpack-plugin",
3-
"version": "1.0.1",
3+
"version": "1.0.2",
44
"description": "Measure + analyse the speed of your webpack loaders and plugins",
55
"main": "index.js",
66
"scripts": {

utils.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ const prependLoader = rules => {
9494
}
9595

9696
if (rules.use) {
97+
if (!Array.isArray(rules.use)) rules.use = [rules.use];
9798
rules.use.unshift("speed-measure-webpack-plugin/loader");
9899
}
99100

@@ -122,7 +123,7 @@ module.exports.hackWrapLoaders = (loaderPaths, callback) => {
122123
return function() {
123124
const ret = reqMethod.apply(this, arguments);
124125
if (loaderPaths.includes(arguments[0])) {
125-
if(ret.__smpHacked) return ret;
126+
if (ret.__smpHacked) return ret;
126127
ret.__smpHacked = true;
127128
return callback(ret, arguments[0]);
128129
}

0 commit comments

Comments
 (0)