-
-
Notifications
You must be signed in to change notification settings - Fork 196
feat: split runtime/build server entries to exclude static routes from runtime bundle #1974
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,4 @@ | ||
| import { EXTENSIONS, SRC_MIDDLEWARE, SRC_PAGES } from '../constants.js'; | ||
|
|
||
| export const getManagedServerEntry = (srcDir: string) => { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure if I 100% follow the idea, but it shouldn't be managed mode only. So, changing code here seems not ideal. |
||
| const globBase = `/${srcDir}/${SRC_PAGES}`; | ||
| const exts = EXTENSIONS.map((ext) => ext.slice(1)).join(','); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,9 +11,23 @@ export function userEntriesPlugin({ srcDir }: { srcDir: string }): Plugin { | |
| // resolve user entries and fallbacks to "managed mode" if not found. | ||
| async resolveId(source, _importer, options) { | ||
| if (source === 'virtual:vite-rsc-waku/server-entry') { | ||
| return '\0virtual:vite-rsc-waku/server-entry-runtime'; | ||
| } | ||
| if (source === 'virtual:vite-rsc-waku/server-entry-runtime') { | ||
| return '\0' + source; | ||
| } | ||
| if (source === 'virtual:vite-rsc-waku/server-entry-build') { | ||
| return '\0' + source; | ||
| } | ||
| if (source === 'virtual:vite-rsc-waku/server-entry-inner') { | ||
| if (source === 'virtual:vite-rsc-waku/server-entry-runtime-inner') { | ||
| const resolved = await this.resolve( | ||
| `/${srcDir}/${SRC_SERVER_ENTRY}`, | ||
| undefined, | ||
| options, | ||
| ); | ||
| return resolved ? resolved : '\0' + source; | ||
| } | ||
| if (source === 'virtual:vite-rsc-waku/server-entry-build-inner') { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Any difference between |
||
| const resolved = await this.resolve( | ||
| `/${srcDir}/${SRC_SERVER_ENTRY}`, | ||
| undefined, | ||
|
|
@@ -30,16 +44,27 @@ export function userEntriesPlugin({ srcDir }: { srcDir: string }): Plugin { | |
| return resolved ? resolved : '\0' + source; | ||
| } | ||
| }, | ||
| load(id) { | ||
| if (id === '\0virtual:vite-rsc-waku/server-entry') { | ||
| async load(id) { | ||
| if (id === '\0virtual:vite-rsc-waku/server-entry-runtime') { | ||
| return `\ | ||
| export { default } from 'virtual:vite-rsc-waku/server-entry-inner'; | ||
| export { default } from 'virtual:vite-rsc-waku/server-entry-runtime-inner'; | ||
| if (import.meta.hot) { | ||
| import.meta.hot.accept() | ||
| } | ||
| `; | ||
| } | ||
| if (id === '\0virtual:vite-rsc-waku/server-entry-inner') { | ||
| if (id === '\0virtual:vite-rsc-waku/server-entry-build') { | ||
| return `\ | ||
| export { default } from 'virtual:vite-rsc-waku/server-entry-build-inner'; | ||
| if (import.meta.hot) { | ||
| import.meta.hot.accept() | ||
| } | ||
| `; | ||
| } | ||
| if (id === '\0virtual:vite-rsc-waku/server-entry-runtime-inner') { | ||
| return getManagedServerEntry(srcDir); | ||
| } | ||
| if (id === '\0virtual:vite-rsc-waku/server-entry-build-inner') { | ||
| return getManagedServerEntry(srcDir); | ||
| } | ||
| if (id === '\0virtual:vite-rsc-waku/client-entry') { | ||
|
|
||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do not change this in this PR. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,17 +1,28 @@ | ||
| packages: | ||
| - 'packages/*' | ||
| - 'examples/*' | ||
| - 'e2e/fixtures/*' | ||
| # package.json in dist is generated by `waku build` | ||
| - packages/* | ||
| - examples/* | ||
| - e2e/fixtures/* | ||
| - '!**/dist' | ||
| preferWorkspacePackages: true | ||
| saveWorkspaceProtocol: true | ||
|
|
||
| linkWorkspacePackages: true | ||
|
|
||
| minimumReleaseAge: 1440 | ||
|
|
||
| minimumReleaseAgeExclude: | ||
| - '@vitejs/plugin-rsc' | ||
| - 'react' | ||
| - 'react-dom' | ||
| - 'react-server-dom-webpack' | ||
| - 'scheduler' | ||
| - 'waku-jotai' | ||
| - react | ||
| - react-dom | ||
| - react-server-dom-webpack | ||
| - scheduler | ||
| - waku-jotai | ||
|
|
||
| onlyBuiltDependencies: | ||
| - '@swc/core' | ||
| - esbuild | ||
| - sharp | ||
| - unrs-resolver | ||
| - workerd | ||
|
|
||
| preferWorkspacePackages: true | ||
|
|
||
| saveWorkspaceProtocol: true |
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.
remove changes in this file.