-
Notifications
You must be signed in to change notification settings - Fork 27.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix client boundary inheritance for barrel optimization (#64467)
### What Inherit the client boudaries from the found matched target in load barrel ### Why The root cause with the barrel transform, we missed the client boundary directive during the transform. Since the new version of mui's case looks like this: Import path page.js (server module) -> `<module>/index.js` (shared module) -> `<module/subpath>/index.js` (client module) -> `<module/subpath/sub-module.js> (client module) After our transform, we lost the `"use client"` which causes the mismatch of the transform: In `rsc` layer: the file pointing to the sub module entry (`<module/subpath>/index.js`), but without the client boundary. Fixes #64369 Closes NEXT-3101
- Loading branch information
Showing
13 changed files
with
103 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
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
7 changes: 7 additions & 0 deletions
7
test/production/app-dir/barrel-optimization/basic/app/layout.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,7 @@ | ||
export default function RootLayout({ children }) { | ||
return ( | ||
<html> | ||
<body>{children}</body> | ||
</html> | ||
) | ||
} |
9 changes: 9 additions & 0 deletions
9
test/production/app-dir/barrel-optimization/basic/app/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,9 @@ | ||
import { ClientDefault } from 'my-lib' | ||
|
||
export default function Home() { | ||
return ( | ||
<div id="client-mod"> | ||
<ClientDefault /> | ||
</div> | ||
) | ||
} |
17 changes: 17 additions & 0 deletions
17
test/production/app-dir/barrel-optimization/basic/index.test.ts
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,17 @@ | ||
import { createNextDescribe } from 'e2e-utils' | ||
|
||
describe('Skipped in Turbopack', () => { | ||
createNextDescribe( | ||
'app-dir - optimizePackageImports - basic', | ||
{ | ||
files: __dirname, | ||
}, | ||
({ next }) => { | ||
it('should build successfully', async () => { | ||
// Ensure that MUI is working | ||
const $ = await next.render$('/') | ||
expect(await $('#client-mod').text()).toContain('client:default') | ||
}) | ||
} | ||
) | ||
}) |
5 changes: 5 additions & 0 deletions
5
test/production/app-dir/barrel-optimization/basic/next.config.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 @@ | ||
module.exports = { | ||
experimental: { | ||
optimizePackageImports: ['my-lib'], | ||
}, | ||
} |
9 changes: 9 additions & 0 deletions
9
.../production/app-dir/barrel-optimization/basic/node_modules/my-lib/client/client-module.js
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
4 changes: 4 additions & 0 deletions
4
test/production/app-dir/barrel-optimization/basic/node_modules/my-lib/client/index.js
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
2 changes: 2 additions & 0 deletions
2
test/production/app-dir/barrel-optimization/basic/node_modules/my-lib/index.js
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
5 changes: 5 additions & 0 deletions
5
test/production/app-dir/barrel-optimization/basic/node_modules/my-lib/package.json
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
7 changes: 7 additions & 0 deletions
7
test/production/app-dir/barrel-optimization/mui/app/layout.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,7 @@ | ||
export default function RootLayout({ children }) { | ||
return ( | ||
<html> | ||
<body>{children}</body> | ||
</html> | ||
) | ||
} |
11 changes: 11 additions & 0 deletions
11
test/production/app-dir/barrel-optimization/mui/app/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,11 @@ | ||
import { Typography } from '@mui/material' | ||
|
||
export default function Home() { | ||
return ( | ||
<div id="typography"> | ||
<Typography id="typography" variant="h1"> | ||
typography | ||
</Typography> | ||
</div> | ||
) | ||
} |
23 changes: 23 additions & 0 deletions
23
test/production/app-dir/barrel-optimization/mui/index.test.ts
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,23 @@ | ||
import { createNextDescribe } from 'e2e-utils' | ||
|
||
describe('Skipped in Turbopack', () => { | ||
createNextDescribe( | ||
'app-dir - optimizePackageImports - mui', | ||
{ | ||
files: __dirname, | ||
|
||
dependencies: { | ||
'@mui/material': '5.15.15', | ||
'@emotion/react': '11.11.1', | ||
'@emotion/styled': '11.11.0', | ||
}, | ||
}, | ||
({ next }) => { | ||
it('should build successfully', async () => { | ||
// Ensure that MUI is working | ||
const $ = await next.render$('/') | ||
expect(await $('#typography').text()).toContain('typography') | ||
}) | ||
} | ||
) | ||
}) |