Skip to content

Comments

extract env json into its own file#5658

Merged
adhami3310 merged 3 commits intomainfrom
extract-env-json-into-its-own-file
Aug 6, 2025
Merged

extract env json into its own file#5658
adhami3310 merged 3 commits intomainfrom
extract-env-json-into-its-own-file

Conversation

@adhami3310
Copy link
Member

that would make all reflex builds output reflex-env-<hash>.js inside of build/client/assets/*

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

Greptile Summary

This PR introduces a build optimization that extracts environment-related code into a separate JavaScript chunk file. The change modifies the Vite configuration in reflex/.templates/web/vite.config.js by adding an advancedChunks configuration that uses a regex pattern /env/ to identify and group environment-related modules into a dedicated chunk named "reflex-env".

When built, this will generate a separate file reflex-env-<hash>.js in the build/client/assets/ directory, containing all modules that match the environment pattern. This primarily targets the $/env.json imports used throughout Reflex applications for environment configuration, as seen in the state management system.

The change fits into Reflex's build system architecture by leveraging Vite's code splitting capabilities. This allows for better separation of concerns between application logic and environment configuration, enabling more granular caching strategies and potentially easier deployment scenarios where environment settings might need updates without full application rebuilds.

Confidence score: 4/5

  • This PR is safe to merge with minimal risk as it only affects build output organization without changing runtime behavior
  • Score reflects the straightforward nature of the Vite configuration change and clear benefit for bundle optimization
  • Pay close attention to the regex pattern /env/ to ensure it matches the intended modules without catching unrelated files

1 file reviewed, 1 comment

Edit Code Review Bot Settings | Greptile

@codspeed-hq
Copy link

codspeed-hq bot commented Aug 1, 2025

CodSpeed Performance Report

Merging #5658 will not alter performance

Comparing extract-env-json-into-its-own-file (8819444) with main (54e0727)

Summary

✅ 8 untouched benchmarks

masenf
masenf previously approved these changes Aug 6, 2025
Copy link
Collaborator

@masenf masenf left a comment

Choose a reason for hiding this comment

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

this is great. i think it would/could be even better if the contents of reflex-env-<whatever>.js wasn't minified

const e=`http://localhost:8001/ping`,t=`ws://localhost:8001/_event`,n=`http://localhost:8001/_upload`,r=`http://localhost:8001/auth-codespace`,i=`http://localhost:8001/_health`,a=`http://localhost:8001/_all_routes`,o=!1;var s={PING:e,EVENT:t,UPLOAD:n,AUTH_CODESPACE:r,HEALTH:i,ALL_ROUTES:a,TEST_MODE:o};export{s as b};

@adhami3310
Copy link
Member Author

i might catch that guy later, bbut it's typically difficult to not have a compiled output when the original is a json file

@adhami3310 adhami3310 merged commit 7b24971 into main Aug 6, 2025
41 checks passed
@adhami3310 adhami3310 deleted the extract-env-json-into-its-own-file branch August 6, 2025 20:31
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