-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat rsc #6516
Closed
Closed
Feat rsc #6516
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
0f78209
refactor: improve rscServerRegister.ts and test
Coooder-X 464d6bd
refactor: clean code
Coooder-X c54c6d6
fix: pnpm-lock conflict
Coooder-X 6a99167
fix: merge and fix conflicts
Coooder-X 3a0feec
feat: rsc server register surpport tsx
Coooder-X 90698b7
refactor: change file name
Coooder-X 7f8902f
fix: revert pnpm-lock.yaml
Coooder-X cb65a27
fix: pnpm-lock.yaml
Coooder-X 5e9a88e
test: add rsc code transform test
Coooder-X 19c530d
fix: rsc code transform case: component has private function
Coooder-X 63af685
fix: add rsc code transform case and fix bugs
Coooder-X c90c6ee
fix: conflicts
Coooder-X a8a18eb
feat: rsc refresh (#6532)
chenjun1011 f4a49d2
fix: test case
Coooder-X cddbe88
Merge branch 'feat-rsc' of github.com:alibaba/ice into feat-rsc
Coooder-X File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
'use server'; | ||
|
||
import EditButton from '@/components/EditButton'; | ||
import Counter from '@/components/Counter'; | ||
import InnerServer from '@/components/Content'; | ||
|
||
export default function Container() { | ||
return ( | ||
<> | ||
<Counter> | ||
<InnerServer /> | ||
</Counter> | ||
<EditButton noteId="editButton"> | ||
hello world | ||
</EditButton> | ||
<div> {serverPrint('serverPrint call')} </div> | ||
</> | ||
); | ||
} | ||
|
||
export function serverPrint(sentence) { | ||
return sentence; | ||
} |
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 @@ | ||
'use server'; | ||
|
||
export default function InnerServer() { | ||
return ( | ||
<div> | ||
inner server | ||
</div> | ||
); | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
'use client'; | ||
import { useRefresh } from '@ice/runtime'; | ||
|
||
export default function Button({ children }) { | ||
const refresh = useRefresh(); | ||
|
||
return ( | ||
<button | ||
className={[ | ||
'edit-button', | ||
'edit-button--solid', | ||
].join(' ')} | ||
onClick={() => refresh()} | ||
role="menuitem" | ||
> | ||
{children} | ||
</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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { useAppContext } from 'ice'; | ||
import styles from './index.module.css'; | ||
import RefreshButton from '@/components/RefreshButton.client'; | ||
import Counter from '@/components/Counter.client'; | ||
|
||
if (!global.requestCount) { | ||
global.requestCount = 0; | ||
} | ||
|
||
export default function Home() { | ||
console.log('Render: Index'); | ||
|
||
const appContext = useAppContext(); | ||
console.log(appContext); | ||
|
||
return ( | ||
<div className={styles.app}> | ||
<h2>About Page</h2> | ||
<div>server request count: { global.requestCount++ }</div> | ||
<Counter /> | ||
<RefreshButton> | ||
Refresh Button | ||
</RefreshButton> | ||
</div> | ||
); | ||
} |
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
28 changes: 28 additions & 0 deletions
28
packages/ice/tests/fixtures/rscTransform/client/clientInput1.tsx
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,28 @@ | ||
'use client'; | ||
import { useState } from 'react'; | ||
import styles from './index.module.css'; | ||
import { clientPrint } from './EditButton'; | ||
|
||
type Name = string; | ||
interface Obj { | ||
name: Name; | ||
age: number; | ||
} | ||
|
||
export default function Counter({ children }) { | ||
const [count, setCount] = useState(0); | ||
const obj: Obj = { name: 'name', age: 100 }; | ||
|
||
function updateCount() { | ||
setCount(count + 1); | ||
} | ||
|
||
return ( | ||
<button className={styles.button} type="button" onClick={updateCount}> | ||
👍🏻 {count} | ||
<div> {clientPrint('clientPrint call')} </div> | ||
{children} | ||
<div> {JSON.stringify(obj)} </div> | ||
</button> | ||
); | ||
} |
20 changes: 20 additions & 0 deletions
20
packages/ice/tests/fixtures/rscTransform/client/clientInput2.jsx
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,20 @@ | ||
'use client'; | ||
import { useState } from 'react'; | ||
import styles from './index.module.css'; | ||
import { clientPrint } from './EditButton'; | ||
|
||
export default function Counter({ children }) { | ||
const [count, setCount] = useState(0); | ||
|
||
function updateCount() { | ||
setCount(count + 1); | ||
} | ||
|
||
return ( | ||
<button className={styles.button} type="button" onClick={updateCount}> | ||
👍🏻 {count} | ||
<div> {clientPrint('clientPrint call')} </div> | ||
{children} | ||
</button> | ||
); | ||
} |
20 changes: 20 additions & 0 deletions
20
packages/ice/tests/fixtures/rscTransform/client/clientInput3.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,20 @@ | ||
'use client'; | ||
import { useState } from 'react'; | ||
import styles from './index.module.css'; | ||
import { clientPrint } from './EditButton'; | ||
|
||
export default function Counter({ children }) { | ||
const [count, setCount] = useState(0); | ||
|
||
function updateCount() { | ||
setCount(count + 1); | ||
} | ||
|
||
return ( | ||
<button className={styles.button} type="button" onClick={updateCount}> | ||
👍🏻 {count} | ||
<div> {clientPrint('clientPrint call')} </div> | ||
{children} | ||
</button> | ||
); | ||
} |
4 changes: 4 additions & 0 deletions
4
packages/ice/tests/fixtures/rscTransform/client/clientOutput1.tsx
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,4 @@ | ||
const Server = require('react-server-dom-webpack/server.node'); | ||
const createClientModuleProxy = Server.createClientModuleProxy; | ||
const comp = createClientModuleProxy('file:///home/runner/work/ice/ice/packages/ice/tests/fixtures/rscTransform/client/clientInput1.tsx'); | ||
module.exports = comp; |
4 changes: 4 additions & 0 deletions
4
packages/ice/tests/fixtures/rscTransform/client/clientOutput2.jsx
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,4 @@ | ||
const Server = require('react-server-dom-webpack/server.node'); | ||
const createClientModuleProxy = Server.createClientModuleProxy; | ||
const comp = createClientModuleProxy('file:///home/runner/work/ice/ice/packages/ice/tests/fixtures/rscTransform/client/clientInput2.jsx'); | ||
module.exports = comp; |
4 changes: 4 additions & 0 deletions
4
packages/ice/tests/fixtures/rscTransform/client/clientOutput3.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,4 @@ | ||
const Server = require('react-server-dom-webpack/server.node'); | ||
const createClientModuleProxy = Server.createClientModuleProxy; | ||
const comp = createClientModuleProxy('file:///home/runner/work/ice/ice/packages/ice/tests/fixtures/rscTransform/client/clientInput3.js'); | ||
module.exports = comp; |
18 changes: 18 additions & 0 deletions
18
packages/ice/tests/fixtures/rscTransform/others/otherInput1.tsx
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,18 @@ | ||
import { useState } from 'react'; | ||
|
||
'use client' | ||
export default function Counter({ children }) { | ||
const [count, setCount] = useState(0); | ||
|
||
function updateCount() { | ||
setCount(count + 1); | ||
} | ||
|
||
return ( | ||
<button type="button" onClick={updateCount}> | ||
👍🏻 {count} | ||
{children} | ||
</button> | ||
); | ||
} | ||
'use client'; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use server 应该是用来标志 server action 的,组件默认情况下就是 server component