-
Notifications
You must be signed in to change notification settings - Fork 26.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix swc compiling of client components when directive appears later t…
…han exports (#54392) When `"use client"` directive appears after other statements, it should be ignored instead of treat as client components. There's a bug inside swc transform that we should mark the directives detection is "finished" after other non string literals directives AST nodes are detected before the first directive x-ref: #54358 (comment)
- Loading branch information
Showing
4 changed files
with
20 additions
and
0 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
6 changes: 6 additions & 0 deletions
6
.../crates/core/tests/errors/react-server-components/server-graph/fake-client-entry/input.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 @@ | ||
export default function () { | ||
return null | ||
} | ||
|
||
// prettier-ignore | ||
'use client' |
3 changes: 3 additions & 0 deletions
3
...crates/core/tests/errors/react-server-components/server-graph/fake-client-entry/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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export default function() { | ||
return null; | ||
} |
7 changes: 7 additions & 0 deletions
7
...es/core/tests/errors/react-server-components/server-graph/fake-client-entry/output.stderr
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 @@ | ||
|
||
x NEXT_RSC_ERR_CLIENT_DIRECTIVE | ||
,-[input.js:5:1] | ||
5 | // prettier-ignore | ||
6 | 'use client' | ||
: ^^^^^^^^^^^^ | ||
`---- |