Conversation
This will avoid conflicts with reflex apps that also host some javascript app in the same directory.
Greptile SummaryThis PR moves the canonical
Confidence Score: 4/5Safe to merge for bun users; npm users who specify unpinned frontend_packages will hit a broken install. The reflex/utils/js_runtimes.py — the unpinned package install paths pass --only-missing without checking whether the active package manager is bun. Important Files Changed
Reviews (2): Last reviewed commit: "remove bad test assertion" | Re-trigger Greptile |
Merging this PR will not alter performance
Comparing Footnotes
|
|
LOL hot reload is broken now, because reflex.lock is not excluded from the reload path 🤦 |
Avoid reload loop when a code change results in a lock file change.
This allows restoration of the previous package.json for the app. Explicitly pinned packages will be updated with `bun add` so they will overwrite what might have been in the lock file / package.json previously. This is important for updating framework dependencies across reflex versions which are strictly pinned. Unpinned packages are added with `bun add --only-missing` so they will NOT override previously saved version pins.
now that packages.json isn't being rewritten on each init, it is important to explicitly look for referenced top-level packages that are no longer used in the current app and remove them.
Avoid extra invocations of the package manager.
Also sync package-lock.json to reflex.lock directory.
The first `install` command only does something if there is an existing package.json / lockfile; in the absense of the lock file, there is nothing to install, so skip it.
To better respect checked-in lock files, do not automatically try using a different package manager which may NOT have a lock file, resulting in unexpected packages being downloaded.
|
@greptile-apps re-review |
| if unpinned_packages: | ||
| run_package_manager( | ||
| [ | ||
| primary_package_manager, | ||
| "add", | ||
| "--legacy-peer-deps", | ||
| "--only-missing", | ||
| *unpinned_packages, | ||
| ], | ||
| show_status_message="Installing frontend packages", | ||
| ) | ||
| if all_pinned_dev: | ||
| run_package_manager( | ||
| [ | ||
| primary_package_manager, | ||
| "add", | ||
| "--legacy-peer-deps", | ||
| "-d", | ||
| *development_deps, | ||
| *all_pinned_dev, | ||
| ], | ||
| show_status_message="Installing frontend development dependencies", | ||
| show_status_message="Pinning frontend development dependencies", | ||
| ) | ||
|
|
||
| # Install custom packages defined in frontend_packages | ||
| if packages: | ||
| if unpinned_dev_deps: | ||
| run_package_manager( | ||
| [primary_package_manager, "add", "--legacy-peer-deps", *packages], | ||
| show_status_message="Installing frontend packages from config and components", | ||
| [ | ||
| primary_package_manager, | ||
| "add", | ||
| "--legacy-peer-deps", | ||
| "--only-missing", | ||
| "-d", | ||
| *unpinned_dev_deps, | ||
| ], | ||
| show_status_message="Installing frontend development dependencies", |
There was a problem hiding this comment.
--only-missing is bun-specific but used unconditionally
--only-missing is a bun flag; npm does not recognize it. When primary_package_manager is npm (Windows+OneDrive path, REFLEX_USE_NPM=1, or the new implicit npm detection when only package-lock.json is present) and any unpinned packages or dev-deps are requested, both npm add --legacy-peer-deps --only-missing <pkgs> and the dev-deps variant will fail with an "unknown option" error, breaking the entire install. This is a regression relative to the old code which never passed --only-missing. The fix is to check the package manager before adding this flag.
Avoid adding unpinned packages that are already accounted for, to avoid resetting the version specified in the lock file.
This will avoid conflicts with reflex apps that also host some javascript app in the same directory.
Followup for #6289