Skip to content

Conversation

@natew
Copy link
Collaborator

@natew natew commented Jul 30, 2025

No description provided.

@railway-app
Copy link

railway-app bot commented Jul 30, 2025

🚅 Deployed to the one-pr-592 environment in onestack.dev

Service Status Web Updated (UTC)
one ✅ Success (View Logs) Web Dec 23, 2025 at 11:02 pm

define: {
'process.env.TAMAGUI_IS_SERVER': '"1"',
'process.env.VITE_ENVIRONMENT': '"server"',
'process.env.VITE_ENVIRONMENT': '"ssr"',
Copy link
Collaborator Author

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

Copy link
Contributor

Copilot AI left a 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-only and client-only modules 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'),
Copy link

Copilot AI Jul 31, 2025

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.

Suggested change
'server-only': resolve(__dirname, '../server-only.js'),
'server-only': resolve(__dirname, '../server-only.ts'),

Copilot uses AI. Check for mistakes.
resolve: {
alias: {
'server-only': resolve(__dirname, '../server-only.js'),
'client-only': resolve(__dirname, '../client-only.js'),
Copy link

Copilot AI Jul 31, 2025

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.

Suggested change
'client-only': resolve(__dirname, '../client-only.js'),
'client-only': resolve(__dirname, '../client-only.ts'),

Copilot uses AI. Check for mistakes.

resolveId(source) {
if (source === 'server-only') {
return { id: resolve(__dirname, '../server-only.js'), external: false }
Copy link

Copilot AI Jul 31, 2025

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.

Suggested change
return { id: resolve(__dirname, '../server-only.js'), external: false }
return { id: resolve(__dirname, '../server-only.ts'), external: false }

Copilot uses AI. Check for mistakes.
return { id: resolve(__dirname, '../server-only.js'), external: false }
}
if (source === 'client-only') {
return { id: resolve(__dirname, '../client-only.js'), external: false }
Copy link

Copilot AI Jul 31, 2025

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.

Suggested change
return { id: resolve(__dirname, '../client-only.js'), external: false }
return { id: resolve(__dirname, '../client-only.ts'), external: false }

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants