forked from vercel/next.js
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix barrel optimization to ignore layers (vercel#59254)
Fixes vercel#57624. The recent issue was an unexpected side effect caused by vercel@305bb01, which only affects specific packages like `@mui/material`. The problem was that the entry file of `@mui/material` has `"use client"` at top, which affects the compilation result to output reference info only (when on the RSC layer), instead of keeping the original export statements. And the fix here is to ignore all layer info and React specific transforms here, as barrel optimization isn't related to all these framework features at all. To keep all directives unchanged, the SWC transform needs to parse and pass that info to the Webpack loader. This PR adds a test to ensure that `@mui/material` is working as expected (less than 1500 modules compiled). Without this feature it'll be ~2400 modules. Closes NEXT-1793, closes NEXT-1762.
- Loading branch information
Showing
10 changed files
with
162 additions
and
54 deletions.
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
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
5 changes: 4 additions & 1 deletion
5
packages/next-swc/crates/core/tests/fixture/optimize-barrel/normal/4/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 |
---|---|---|
@@ -1,2 +1,5 @@ | ||
'use client'; | ||
/* Test */ /* Test directives inside comments | ||
'use server' | ||
*/ // This should be kept | ||
export const __next_private_export_map__ = '[["x","foo","a"],["y","1","y"],["b","foo","b"],["default","foo","default"],["z","bar","default"]]'; | ||
export const __next_private_directive_list__ = '["use client"]'; |
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
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
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
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
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
5 changes: 5 additions & 0 deletions
5
test/development/basic/barrel-optimization/fixture/app/mui/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,5 @@ | ||
import { Button } from '@mui/material' | ||
|
||
export default function Page() { | ||
return <Button>test_mui</Button> | ||
} |
Oops, something went wrong.