Skip to content

Commit bdd83d3

Browse files
mischnicabhi12299
authored andcommitted
Turbopack: fix another case of edge runtime warnings (vercel#70455)
Closes PACK-3276
1 parent 03238db commit bdd83d3

File tree

3 files changed

+16
-4
lines changed

3 files changed

+16
-4
lines changed

crates/next-custom-transforms/src/transforms/warn_for_edge_runtime.rs

+10-4
Original file line numberDiff line numberDiff line change
@@ -298,10 +298,16 @@ impl Visit for WarnForEdgeRuntime {
298298
fn visit_bin_expr(&mut self, node: &BinExpr) {
299299
match node.op {
300300
op!("&&") | op!("||") | op!("??") => {
301-
self.with_new_scope(move |this| {
302-
this.add_guards(&node.left);
303-
node.right.visit_with(this);
304-
});
301+
if self.should_add_guards {
302+
// This is a condition and not a shorthand for if-then
303+
self.add_guards(&node.left);
304+
node.right.visit_with(self);
305+
} else {
306+
self.with_new_scope(move |this| {
307+
this.add_guards(&node.left);
308+
node.right.visit_with(this);
309+
});
310+
}
305311
}
306312
op!("==") | op!("===") => {
307313
self.add_guard_for_test(&node.left);
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
11
if (typeof process.loadEnvFile === 'function') {
22
console.log(process.loadEnvFile())
33
}
4+
5+
typeof process < 'u' &&
6+
typeof process.off == 'function' &&
7+
(process.off('uncaughtException', this.onUncaughtException),
8+
process.off('unhandledRejection', this.onUncaughtRejection))
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
if (typeof process.loadEnvFile === 'function') {
22
console.log(process.loadEnvFile());
33
}
4+
typeof process < 'u' && typeof process.off == 'function' && (process.off('uncaughtException', this.onUncaughtException), process.off('unhandledRejection', this.onUncaughtRejection));

0 commit comments

Comments
 (0)