-
-
Notifications
You must be signed in to change notification settings - Fork 112
vibe code server-only client-only #592
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?
Conversation
|
🚅 Deployed to the one-pr-592 environment in onestack.dev
|
| define: { | ||
| 'process.env.TAMAGUI_IS_SERVER': '"1"', | ||
| 'process.env.VITE_ENVIRONMENT': '"server"', | ||
| 'process.env.VITE_ENVIRONMENT': '"ssr"', |
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.
actually i think this is a legit bugfix because vite uses ssr other places
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.
Pull Request Overview
This PR implements server-only and client-only module enforcement for the One framework, preventing code from being incorrectly imported in the wrong environment (server vs client).
- Adds
server-onlyandclient-onlymodules that throw runtime errors when imported in the wrong environment - Creates a Vite plugin to resolve these modules and enforce environment-specific imports
- Includes comprehensive test coverage for both the plugin functionality and end-to-end behavior
Reviewed Changes
Copilot reviewed 14 out of 18 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
packages/one/src/vite/server-only.ts |
Runtime guard that throws error when imported outside SSR environment |
packages/one/src/vite/client-only.ts |
Runtime guard that throws error when imported outside client environment |
packages/one/src/vite/plugins/serverClientOnlyPlugin.ts |
Vite plugin that resolves server-only/client-only imports to custom modules |
packages/one/src/vite/one.ts |
Integrates the server-client-only plugin into the One framework |
packages/vxrn/src/exports/build.ts |
Updates VITE_ENVIRONMENT from "server" to "ssr" for consistency |
tests/test/utils/server-utils.ts |
Example server-only utilities for testing |
tests/test/utils/client-utils.ts |
Example client-only utilities for testing |
tests/test/app/test-server-only+ssr.tsx |
Test page demonstrating server-only functionality |
tests/test/app/test-client-only+spa.tsx |
Test page demonstrating client-only functionality |
tests/test/tests/server-client-only.test.ts |
End-to-end tests verifying server-only/client-only behavior |
| return { | ||
| resolve: { | ||
| alias: { | ||
| 'server-only': resolve(__dirname, '../server-only.js'), |
Copilot
AI
Jul 31, 2025
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.
The alias points to '../server-only.js' but the actual file is '../server-only.ts'. This will cause module resolution to fail since the .js extension doesn't match the TypeScript source file.
| 'server-only': resolve(__dirname, '../server-only.js'), | |
| 'server-only': resolve(__dirname, '../server-only.ts'), |
| resolve: { | ||
| alias: { | ||
| 'server-only': resolve(__dirname, '../server-only.js'), | ||
| 'client-only': resolve(__dirname, '../client-only.js'), |
Copilot
AI
Jul 31, 2025
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.
The alias points to '../client-only.js' but the actual file is '../client-only.ts'. This will cause module resolution to fail since the .js extension doesn't match the TypeScript source file.
| 'client-only': resolve(__dirname, '../client-only.js'), | |
| 'client-only': resolve(__dirname, '../client-only.ts'), |
|
|
||
| resolveId(source) { | ||
| if (source === 'server-only') { | ||
| return { id: resolve(__dirname, '../server-only.js'), external: false } |
Copilot
AI
Jul 31, 2025
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.
The resolveId function points to '../server-only.js' but the actual file is '../server-only.ts'. This will cause module resolution to fail.
| return { id: resolve(__dirname, '../server-only.js'), external: false } | |
| return { id: resolve(__dirname, '../server-only.ts'), external: false } |
| return { id: resolve(__dirname, '../server-only.js'), external: false } | ||
| } | ||
| if (source === 'client-only') { | ||
| return { id: resolve(__dirname, '../client-only.js'), external: false } |
Copilot
AI
Jul 31, 2025
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.
The resolveId function points to '../client-only.js' but the actual file is '../client-only.ts'. This will cause module resolution to fail.
| return { id: resolve(__dirname, '../client-only.js'), external: false } | |
| return { id: resolve(__dirname, '../client-only.ts'), external: false } |
No description provided.