Skip to content

Commit fae5bec

Browse files
committed
add some comments to clarify why this is important here
1 parent 99b8af4 commit fae5bec

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

‎lib/DefinePlugin.js‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,14 @@ class DefinePlugin {
6767
if(!isTypeof) {
6868
parser.plugin("can-rename " + key, ParserHelpers.approve);
6969
parser.plugin("evaluate Identifier " + key, (expr) => {
70+
/**
71+
* this is needed in case there is a recursion in the DefinePlugin
72+
* to prevent an endless recursion
73+
* e.g.: new DefinePlugin({
74+
* "a": "b",
75+
* "b": "a"
76+
* });
77+
*/
7078
if(recurse) return;
7179
recurse = true;
7280
const res = parser.evaluate(code);
@@ -78,6 +86,14 @@ class DefinePlugin {
7886
}
7987
const typeofCode = isTypeof ? code : "typeof (" + code + ")";
8088
parser.plugin("evaluate typeof " + key, (expr) => {
89+
/**
90+
* this is needed in case there is a recursion in the DefinePlugin
91+
* to prevent an endless recursion
92+
* e.g.: new DefinePlugin({
93+
* "typeof a": "tyepof b",
94+
* "typeof b": "typeof a"
95+
* });
96+
*/
8197
if(recurseTypeof) return;
8298
recurseTypeof = true;
8399
const res = parser.evaluate(typeofCode);

0 commit comments

Comments
 (0)