Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions app/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ export PHOENIX_SMTP_USERNAME=apikey
export PHOENIX_SMTP_PASSWORD=XXXXXXXXXXXXXXXX
# Used for running chromatic visual tests on components
export CHROMATIC_PROJECT_TOKEN=XXXXXXX
# Use the react-compiler
export PHOENIX_ENABLE_REACT_COMPILER=True
6 changes: 6 additions & 0 deletions app/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ Before running the script above you should configure your running environment by

Depending on what flows you are trying to build features for, you may want to adjust the scripts block within the [package.json](./package.json) file so that the server is serving the appropriate fixture data.

### Environment Variables

The following environment variables can be configured in your `.env` file:

- **`PHOENIX_ENABLE_REACT_COMPILER`**: Enable or disable the React Compiler for improved performance. Set to `True` (capital T) to enable, or omit/leave unset to disable. The React Compiler can improve performance but may introduce new errors, so proceed with caution when enabling it.

### Authentication

For local development, you have two options for authentication:
Expand Down
5 changes: 3 additions & 2 deletions app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@
"@types/relay-runtime": "^19.0.3",
"@types/three": "^0.180.0",
"@vitejs/plugin-react": "^4.7.0",
"babel-plugin-react-compiler": "1.0.0",
"babel-plugin-relay": "^20.1.1",
"chromatic": "^11.29.0",
"cpy-cli": "^5.0.0",
Expand Down Expand Up @@ -126,10 +127,10 @@
"test:watch": "vitest",
"test:e2e": "playwright test",
"test:e2e:ui": "playwright test --ui",
"dev": "pnpm run dev:server & pnpm run build:static && pnpm run build:relay && vite",
"dev": "pnpm run dev:server & pnpm run dev:ui",
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Inconsistent React Compiler behavior across environments.

The build script doesn't source .env, so PHOENIX_ENABLE_REACT_COMPILER won't be available to vite.config.mts. This means the React Compiler will always be disabled during production builds, creating inconsistent behavior between development and production environments.

Fix in Cursor Fix in Web

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Inconsistent React Compiler in Dev Modes

The dev:offline and dev:embeddings scripts don't source .env before running vite, so PHOENIX_ENABLE_REACT_COMPILER won't be available. This creates inconsistent behavior where the React Compiler configuration works in dev mode but not in these alternative development modes.

Fix in Cursor Fix in Web

"dev:offline": "pnpm run dev:server:offline & pnpm run build:static && pnpm run build:relay && vite",
"dev:embeddings": "pnpm run dev:server:embeddings & pnpm run build:static && pnpm run build:relay && vite",
"dev:ui": "pnpm run build:static && pnpm run build:relay && vite",
"dev:ui": "source ./.env && pnpm run build:static && pnpm run build:relay && vite",
"dev:server": "source ./.env && uv run --compile --with-requirements=../requirements/dev.txt phoenix --dev serve",
"dev:server:offline": "python -m phoenix.server.main --dev serve",
"dev:server:embeddings": "pnpm dev:server --with-fixture=fashion_mnist",
Expand Down
27 changes: 26 additions & 1 deletion app/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 22 additions & 1 deletion app/vite.config.mts
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,33 @@ import { defineConfig } from "vite";
import reactFallbackThrottlePlugin from "vite-plugin-react-fallback-throttle";
import relay from "vite-plugin-relay";

const useReactCompiler = process.env.PHOENIX_ENABLE_REACT_COMPILER === "True";

if (useReactCompiler) {
// eslint-disable-next-line no-console
console.log(
"🔥 Using React Compiler. This will improve performance but also may introduce new errors. Proceed with caution."
);
} else {
// eslint-disable-next-line no-console
console.log("⏼ React compiler is disabled.");
}
export default defineConfig(() => {
const plugins = [
// disable react's built-in 300ms suspense fallback timer
// without this build plugin we see a 300ms delay on most UI interactions
reactFallbackThrottlePlugin(),
react(),
react(
useReactCompiler
? {
babel: {
plugins: [
["babel-plugin-react-compiler", { panicThreshold: "none" }],
],
},
}
: {}
),
relay,
lezer(),
];
Expand Down
Loading