Conversation
…alls `App._get_frontend_package_name` split everything after `package@` at the first slash, treating the leading segment as a version and the rest as a package subpath. That is right for `@scope/pkg@1.0.0/dist/style.css`, but wrong for specifiers that name a *location* rather than a version: a local path like `@masenf/hello-react@../hello-react` was truncated to `@masenf/hello-react@..`, which bun then rejected with "Could not find package.json for 'file:..' dependency". The `:`-in-version check only saved protocol forms such as `file:` and `github:`. Split off the version only when the specifier is not a location: any protocol form, a git ref (`#`), or a relative/absolute/home-relative path now reaches the package manager unmodified. The `package_name == library_name` branch it replaced produced a string identical to the generic one, so it is folded in. Verified end-to-end with a wrapped local package: both `@masenf/hello-react@../hello-react` and `@masenf/hello-react@../masenf-hello-react-0.1.0.tgz` now install and build. Documented that a local *directory* dependency is linked in place, so its own runtime dependencies must be installed inside that directory (or a packed archive used instead). Fixes reflex-dev#7117 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LwE92843n9iYDVR7yfjwJX
Contributor
|
Merging this PR will not alter performance
Comparing Footnotes
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
closes #7117
All Submissions:
Type of change
Changes To Core Features:
The bug
App._get_frontend_package_namesplit everything afterpackage@at the first slash, treating the leading segment as a version and the remainder as a package subpath. That is correct for@scope/pkg@1.0.0/dist/style.css, but wrong for specifiers that name a location rather than a version. A:-in-version check rescued protocol forms (file:,github:), leaving bare paths to be truncated:@masenf/hello-react@../hello-react@masenf/hello-react@..@masenf/hello-react@../hello-react.tgz@masenf/hello-react@..@masenf/hello-react@/opt/hello-react@masenf/hello-react@bun then failed with exactly what the issue reports:
The change
A new
_is_location_specifierhelper: the leading segment is split off as a version only when the specifier is not a location — i.e. not a protocol form (:), not a git ref (#), and not a relative/absolute/home-relative path. Locations now reach the package manager unmodified.The
package_name == library_namebranch this replaces produced a string identical to the generic one, so it is folded in. Version+subpath imports (react-map-gl@1.0.0/maplibre), protocol forms, URLs and plain subpath imports all resolve exactly as before.Verification
Three regression tests added to
tests/units/test_app.py(all fail before the fix). Beyond unit tests, this was verified end-to-end with an app wrapping@masenf/hello-reactviareflex export --frontend-only:@masenf/hello-react@../masenf-hello-react-0.1.0.tgz— installs, production build succeeds,Counterin the bundle.@masenf/hello-react@../hello-react—.web/package.jsonrecords"@masenf/hello-react": "../hello-react", lockfile resolvesfile:../hello-react, build succeeds.uv run ruff check ./ruff format .clean,uv run pyright reflex testsreports 0 errors, and the unit suite passes (6904 passed; the two failures intests/units/utils/test_processes.py::test_is_process_on_port_*are pre-existing and environment-dependent — they inspect real listening ports — and are untouched by this change).Docs
For a local directory dependency, bun links the package's files in place, so the bundler resolves that package's own runtime dependencies from the source directory rather than from
.web/node_modules(the first e2e run failed onRolldown failed to resolve import "lodash"untilhello-react/node_modulesexisted). That is package-manager/bundler behavior rather than a Reflex bug, sodocs/wrapping-react/local-packages.mdnow notes it: runnpm installinside the local package directory, or reference a packed archive.Known limitation (unchanged)
The bare GitHub shorthand
@scope/pkg@user/repois genuinely ambiguous with@scope/pkg@dist-tag/subpathand still resolves to@scope/pkg@user. The documented formgithub:user/repoworks; disambiguating the shorthand would require guessing, so it is left alone.🤖 Generated with Claude Code
https://claude.ai/code/session_01LwE92843n9iYDVR7yfjwJX