You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- Refactor getUndefinedCJSGlobalLike to use ArrayPrototypeFind
- Change if-else chain to switch statement
- Add single quotes around global names in error messages
- Revert test file to use --input-type=module flag and original order
- Update test regex patterns to expect quoted global names
advice='use export instead of module.exports/exports';
89
-
}elseif(undefinedGlobal==='__filename'){
90
-
advice='use import.meta.filename instead';
91
-
}elseif(undefinedGlobal==='__dirname'){
92
-
advice='use import.meta.dirname instead';
82
+
letadvice;
83
+
switch(undefinedGlobal){
84
+
case'require':
85
+
advice='replace require() with import';
86
+
break;
87
+
case'module':
88
+
case'exports':
89
+
advice='use export instead of module.exports/exports';
90
+
break;
91
+
case'__filename':
92
+
advice='use import.meta.filename instead';
93
+
break;
94
+
case'__dirname':
95
+
advice='use import.meta.dirname instead';
96
+
break;
93
97
}
94
98
95
-
e.message=`Cannot determine intended module format because both ${undefinedGlobal} and top-level await are present. If the code is intended to be CommonJS, wrap await in an async function. If the code is intended to be an ES module, ${advice}.`;
99
+
e.message=`Cannot determine intended module format because both '${undefinedGlobal}' and top-level await are present. If the code is intended to be CommonJS, wrap await in an async function. If the code is intended to be an ES module, ${advice}.`;
0 commit comments