-
Notifications
You must be signed in to change notification settings - Fork 27.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Allow guarded usage of node.js APIs from edge runtime (#69283)
### What? Improve the node.js linter ### Why? It should not warn for _safe_ usage. x-ref: https://vercel.slack.com/archives/C04DUD7EB1B/p1724522593235339 ### How?
- Loading branch information
Showing
5 changed files
with
104 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
crates/next-custom-transforms/tests/fixture/edge-assert/guarded-nodejs/input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
if (typeof clearImmediate === 'function') { | ||
console.log(clearImmediate()) | ||
} | ||
|
||
// We allow this. | ||
const scheduleTimeoutA = | ||
typeof setImmediate === 'function' ? setImmediate : setTimeout | ||
const scheduleTimeoutB = | ||
typeof setImmediate !== 'function' ? setTimeout : setImmediate |
6 changes: 6 additions & 0 deletions
6
crates/next-custom-transforms/tests/fixture/edge-assert/guarded-nodejs/output.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
if (typeof clearImmediate === 'function') { | ||
console.log(clearImmediate()); | ||
} | ||
// We allow this. | ||
const scheduleTimeoutA = typeof setImmediate === 'function' ? setImmediate : setTimeout; | ||
const scheduleTimeoutB = typeof setImmediate !== 'function' ? setTimeout : setImmediate; |
3 changes: 3 additions & 0 deletions
3
crates/next-custom-transforms/tests/fixture/edge-assert/guarded-process/input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
if (typeof process.loadEnvFile === 'function') { | ||
console.log(process.loadEnvFile()) | ||
} |
3 changes: 3 additions & 0 deletions
3
crates/next-custom-transforms/tests/fixture/edge-assert/guarded-process/output.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
if (typeof process.loadEnvFile === 'function') { | ||
console.log(process.loadEnvFile()); | ||
} |