-
-
Notifications
You must be signed in to change notification settings - Fork 188
feat(rsc): support browser mode build #801
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
Merged
Merged
Changes from 20 commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
dace30b
feat(rsc): support browser mode build
hi-ogawa a0a3c6d
wip
hi-ogawa dfec6da
wip
hi-ogawa b761ef4
wip: build
hi-ogawa 50919e0
comment
hi-ogawa 2c0c4a4
fix: build client reference
hi-ogawa 67db530
fix: fix hard-coded "rsc" environment
hi-ogawa 195b006
refactor: cleanup
hi-ogawa 956e27a
chore: silenct build directive warning
hi-ogawa 489249b
Merge branch 'main' into 08-29-feat_rsc_support_build_on_browser_mode
hi-ogawa d7f1656
chore: empty build virtual during dev
hi-ogawa ceeb117
refactor: simplify load client virtual
hi-ogawa 384055c
chore: rename
hi-ogawa 3dcc0ae
test: test build
hi-ogawa f1f955e
chore: lint
hi-ogawa 41a43ec
Merge branch 'main' into 08-29-feat_rsc_support_build_on_browser_mode
hi-ogawa 49647e1
chore: comment
hi-ogawa 57d0adf
Merge remote-tracking branch 'origin/08-29-feat_rsc_support_build_on_…
hi-ogawa 1546f78
Merge branch 'main' into 08-29-feat_rsc_support_build_on_browser_mode
hi-ogawa 4e74e5c
chore: revert `playground/mdx/vite.config.ts`
hi-ogawa 91c3bf7
Merge branch 'main' into 08-29-feat_rsc_support_build_on_browser_mode
hi-ogawa 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
25 changes: 25 additions & 0 deletions
25
packages/plugin-rsc/examples/browser-mode/src/framework/load-client-dev.tsx
This file contains hidden or 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,25 @@ | ||
import { ESModulesEvaluator, ModuleRunner } from 'vite/module-runner' | ||
|
||
export default async function loadClient() { | ||
const runner = new ModuleRunner( | ||
{ | ||
sourcemapInterceptor: false, | ||
transport: { | ||
invoke: async (payload) => { | ||
const response = await fetch( | ||
'/@vite/invoke-react-client?' + | ||
new URLSearchParams({ | ||
data: JSON.stringify(payload), | ||
}), | ||
) | ||
return response.json() | ||
}, | ||
}, | ||
hmr: false, | ||
}, | ||
new ESModulesEvaluator(), | ||
) | ||
return await runner.import<typeof import('./entry.browser')>( | ||
'/src/framework/entry.browser.tsx', | ||
) | ||
} |
28 changes: 2 additions & 26 deletions
28
packages/plugin-rsc/examples/browser-mode/src/framework/main.tsx
This file contains hidden or 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,35 +1,11 @@ | ||
import { ESModulesEvaluator, ModuleRunner } from 'vite/module-runner' | ||
import * as server from './entry.rsc' | ||
import loadClient from 'virtual:vite-rsc-browser-mode/load-client' | ||
|
||
async function main() { | ||
const client = await importClient() | ||
const client = await loadClient() | ||
server.initialize() | ||
client.initialize({ fetchServer: server.fetchServer }) | ||
await client.main() | ||
} | ||
|
||
async function importClient() { | ||
const runner = new ModuleRunner( | ||
{ | ||
sourcemapInterceptor: false, | ||
transport: { | ||
invoke: async (payload) => { | ||
const response = await fetch( | ||
'/@vite/invoke-react-client?' + | ||
new URLSearchParams({ | ||
data: JSON.stringify(payload), | ||
}), | ||
) | ||
return response.json() | ||
}, | ||
}, | ||
hmr: false, | ||
}, | ||
new ESModulesEvaluator(), | ||
) | ||
return await runner.import<typeof import('./entry.browser')>( | ||
'/src/framework/entry.browser.tsx', | ||
) | ||
} | ||
|
||
main() |
14 changes: 14 additions & 0 deletions
14
packages/plugin-rsc/examples/browser-mode/src/framework/virtual.d.ts
This file contains hidden or 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,14 @@ | ||
declare module 'virtual:vite-rsc-browser-mode/build-client-references' { | ||
const default_: Record<string, () => Promise<any>> | ||
export default default_ | ||
} | ||
|
||
declare module 'virtual:vite-rsc-browser-mode/build-server-references' { | ||
const default_: Record<string, () => Promise<any>> | ||
export default default_ | ||
} | ||
|
||
declare module 'virtual:vite-rsc-browser-mode/load-client' { | ||
const default_: () => Promise<typeof import('./entry.browser')> | ||
export default default_ | ||
} |
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.
@kasperpeulen FYI, I'm not sure what to do about this, but probably this means this setup would be broken on all Safari. I tried
web-streams-polyfill
but it probably broke other things #807.