mirror of
https://github.com/discourse/discourse.git
synced 2024-11-22 09:42:02 +08:00
DEV: Move from babel-plugin-debug-macros fork to in-repo patch (#22702)
This commit is contained in:
parent
bb2d1f8703
commit
2ed223fced
|
@ -21,7 +21,6 @@
|
|||
"wizard"
|
||||
],
|
||||
"resolutions": {
|
||||
"**/babel-plugin-debug-macros": "npm:@discourse/babel-plugin-debug-macros@0.4.0-pre1",
|
||||
"**/unset-value": "2.0.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
|
|
@ -0,0 +1,76 @@
|
|||
diff --git a/node_modules/babel-plugin-debug-macros/src/utils/builder.js b/node_modules/babel-plugin-debug-macros/src/utils/builder.js
|
||||
index ea61084..e17eb68 100644
|
||||
--- a/node_modules/babel-plugin-debug-macros/src/utils/builder.js
|
||||
+++ b/node_modules/babel-plugin-debug-macros/src/utils/builder.js
|
||||
@@ -7,6 +7,7 @@ module.exports = class Builder {
|
||||
this.global = options.global;
|
||||
this.assertPredicateIndex = options.assertPredicateIndex;
|
||||
this.isDebug = options.isDebug;
|
||||
+ this.deprecationsEnabled = true;
|
||||
this.expressions = [];
|
||||
}
|
||||
|
||||
@@ -89,11 +90,16 @@ module.exports = class Builder {
|
||||
let expression = path.node.expression;
|
||||
let callee = expression.callee;
|
||||
let args = expression.arguments;
|
||||
+ let flag = this.isDebug;
|
||||
|
||||
if (options.validate) {
|
||||
options.validate(expression, args);
|
||||
}
|
||||
|
||||
+ if (options.flag !== undefined) {
|
||||
+ flag = options.flag;
|
||||
+ }
|
||||
+
|
||||
let callExpression;
|
||||
if (this.module) {
|
||||
callExpression = expression;
|
||||
@@ -115,7 +121,7 @@ module.exports = class Builder {
|
||||
|
||||
this.expressions.push([
|
||||
path,
|
||||
- this._buildLogicalExpressions(prefixedIdentifiers, callExpression),
|
||||
+ this._buildLogicalExpressions(prefixedIdentifiers, callExpression, flag),
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -165,6 +171,8 @@ module.exports = class Builder {
|
||||
throw new ReferenceError(`deprecate's meta information requires an "id" field.`);
|
||||
}
|
||||
},
|
||||
+
|
||||
+ flag: this.deprecationsEnabled,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -173,12 +181,11 @@ module.exports = class Builder {
|
||||
*/
|
||||
expandMacros() {
|
||||
let t = this.t;
|
||||
- let flag = t.booleanLiteral(this.isDebug);
|
||||
for (let i = 0; i < this.expressions.length; i++) {
|
||||
let expression = this.expressions[i];
|
||||
let exp = expression[0];
|
||||
let logicalExp = expression[1];
|
||||
- exp.replaceWith(t.parenthesizedExpression(logicalExp(flag)));
|
||||
+ exp.replaceWith(t.parenthesizedExpression(logicalExp()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -196,11 +203,11 @@ module.exports = class Builder {
|
||||
return t.callExpression(t.memberExpression(t.identifier('console'), identifier), args);
|
||||
}
|
||||
|
||||
- _buildLogicalExpressions(identifiers, callExpression) {
|
||||
+ _buildLogicalExpressions(identifiers, callExpression, flagValue) {
|
||||
let t = this.t;
|
||||
|
||||
- return debugIdentifier => {
|
||||
- identifiers.unshift(debugIdentifier);
|
||||
+ return () => {
|
||||
+ identifiers.unshift(t.booleanLiteral(flagValue));
|
||||
identifiers.push(callExpression);
|
||||
let logicalExpressions;
|
||||
|
|
@ -2308,10 +2308,17 @@ babel-loader@^8.0.6:
|
|||
make-dir "^3.1.0"
|
||||
schema-utils "^2.6.5"
|
||||
|
||||
babel-plugin-debug-macros@^0.2.0, babel-plugin-debug-macros@^0.3.4, "babel-plugin-debug-macros@npm:@discourse/babel-plugin-debug-macros@0.4.0-pre1":
|
||||
version "0.4.0-pre1"
|
||||
resolved "https://registry.yarnpkg.com/@discourse/babel-plugin-debug-macros/-/babel-plugin-debug-macros-0.4.0-pre1.tgz#f1aa632fcf5d0d673edfba7dc84003acc6b507b3"
|
||||
integrity sha512-faMBuks7QDgwS9Vz+lw60z0CHk5jd0NlLtcxXSIJ13X9Fil5v8k0fOztIF9eYkqKuGHuDoCC2mFQlFNftb1RxA==
|
||||
babel-plugin-debug-macros@^0.2.0:
|
||||
version "0.2.0"
|
||||
resolved "https://registry.yarnpkg.com/babel-plugin-debug-macros/-/babel-plugin-debug-macros-0.2.0.tgz#0120ac20ce06ccc57bf493b667cf24b85c28da7a"
|
||||
integrity sha512-Wpmw4TbhR3Eq2t3W51eBAQSdKlr+uAyF0GI4GtPfMCD12Y4cIdpKC9l0RjNTH/P9isFypSqqewMPm7//fnZlNA==
|
||||
dependencies:
|
||||
semver "^5.3.0"
|
||||
|
||||
babel-plugin-debug-macros@^0.3.4:
|
||||
version "0.3.4"
|
||||
resolved "https://registry.yarnpkg.com/babel-plugin-debug-macros/-/babel-plugin-debug-macros-0.3.4.tgz#22961d0cb851a80654cece807a8b4b73d85c6075"
|
||||
integrity sha512-wfel/vb3pXfwIDZUrkoDrn5FHmlWI96PCJ3UCDv2a86poJ3EQrnArNW5KfHSVJ9IOgxHbo748cQt7sDU+0KCEw==
|
||||
dependencies:
|
||||
semver "^5.3.0"
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user