-
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 missing SWC transforms for optimized barrel files (#57474)
With Barrel Optimization, we are trying to "shortcut" the import to be directly pointing to the final target, as barrel files shouldn't have any side effects. However, there could be `"use client"` and `"use server"` directives which we can't ignore. Hence we must apply the `serverComponents` transform of SWC to these barrel files too. Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
- Loading branch information
1 parent
df0fb70
commit 3e34167
Showing
6 changed files
with
27 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
5 changes: 5 additions & 0 deletions
5
test/development/basic/barrel-optimization/app/client-boundary/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 'my-client-lib' | ||
|
||
export default function Page() { | ||
return <Button /> | ||
} |
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,5 +1,6 @@ | ||
module.exports = { | ||
transpilePackages: ['my-client-lib'], | ||
experimental: { | ||
optimizePackageImports: ['my-lib', 'recursive-barrel'], | ||
optimizePackageImports: ['my-lib', 'recursive-barrel', 'my-client-lib'], | ||
}, | ||
} |
6 changes: 6 additions & 0 deletions
6
test/development/basic/barrel-optimization/node_modules_bak/my-client-lib/button.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 { useState } from 'react' | ||
|
||
export function Button() { | ||
const [count, setCount] = useState(0) | ||
return <button onClick={() => setCount(count + 1)}>{count}</button> | ||
} |
3 changes: 3 additions & 0 deletions
3
test/development/basic/barrel-optimization/node_modules_bak/my-client-lib/index.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 @@ | ||
'use client' | ||
|
||
export { Button } from './button' |