Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions packages/next/src/build/webpack/loaders/next-barrel-loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,9 +221,12 @@ async function getBarrelMapping(
true,
isClientEntry
)

if (targetMatches) {
// Merge the export list
exportList = exportList.concat(targetMatches.exportList)
// Inherit the client boundary from the target matched file
isClientEntry = isClientEntry || targetMatches.isClientEntry
}
})
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { hasRedbox } from 'next-test-utils'
files: join(__dirname, 'fixture'),

dependencies: {
'@mui/material': '5.15.4',
'@mui/material': '5.15.15',
'@emotion/react': '11.11.1',
'@emotion/styled': '11.11.0',
},
Expand Down
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 test/production/app-dir/barrel-optimization/basic/app/page.js
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>
)
}
21 changes: 21 additions & 0 deletions test/production/app-dir/barrel-optimization/basic/index.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { createNextDescribe } from 'e2e-utils'

// Skipped in Turbopack, will be added later.
;(process.env.TURBOPACK ? describe.skip : 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')
})
}
)
}
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = {
experimental: {
optimizePackageImports: ['my-lib'],
},
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions test/production/app-dir/barrel-optimization/mui/app/layout.js
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 test/production/app-dir/barrel-optimization/mui/app/page.js
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>
)
}
27 changes: 27 additions & 0 deletions test/production/app-dir/barrel-optimization/mui/index.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { createNextDescribe } from 'e2e-utils'

// Skipped in Turbopack, will be added later.
;(process.env.TURBOPACK ? describe.skip : 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')
})
}
)
}
)