-
Notifications
You must be signed in to change notification settings - Fork 26.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve Server Reference ID DCE tests (#70191)
This PR improves the integration test of dead code elimination of Server Reference IDs in the client bundle, to cover: - Barrel files (re-exports and nested imports) - Side effects in server boundary and intermediate modules - SWC compression
- Loading branch information
Showing
4 changed files
with
40 additions
and
1 deletion.
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
test/production/app-dir/actions-tree-shaking/client-actions-tree-shaking/app/actions.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 |
---|---|---|
@@ -1,9 +1,16 @@ | ||
'use server' | ||
|
||
// Ensure side effects won't affect tree shaking and DCE | ||
console.log('This is a side effect') | ||
|
||
export async function foo() { | ||
console.log('This is action foo') | ||
} | ||
|
||
export async function bar() { | ||
console.log('This is action bar') | ||
} | ||
|
||
export async function baz() { | ||
console.log('This is action baz') | ||
} |
6 changes: 6 additions & 0 deletions
6
...production/app-dir/actions-tree-shaking/client-actions-tree-shaking/app/route-3/barrel.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 @@ | ||
import { baz } from '../actions' | ||
|
||
// Ensure side effects won't affect tree shaking and DCE | ||
console.log(1) | ||
|
||
export { baz } |
12 changes: 12 additions & 0 deletions
12
test/production/app-dir/actions-tree-shaking/client-actions-tree-shaking/app/route-3/page.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,12 @@ | ||
'use client' | ||
|
||
import { baz } from './barrel' | ||
|
||
export default function Page() { | ||
// Test DCE | ||
if (1 + 1 === 3) { | ||
baz() | ||
} | ||
|
||
return <div>hi</div> | ||
} |
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