Commit 70957aa
fix(constants): inline
## Description
`src/constants/resourceFetcher.ts` reads the library version with a
runtime `require('../../package.json').version`. That path resolves
correctly from `src/constants/`, but `react-native-builder-bob` emits
the file at `lib/module/constants/` — one level deeper — and babel
leaves the relative `require` literal unchanged. From the compiled
location it points at a non-existent `lib/package.json`, so any consumer
that resolves via `main`/`module` (web, Node) fails to bundle.
iOS/Android Metro is unaffected because the package's `"react-native":
"src/index"` entry reads source directly.
Replace the JSON `require` with a literal `LIB_VERSION` in
`constants/versions.ts`, derive the current-release tag from it, and
re-export `LIB_VERSION` from `resourceFetcher.ts` for existing callers.
While here, rename the version constants to match what they actually
mean at the call site: `VERSION_TAG` is now the current release (derived
from `LIB_VERSION`) and `PREVIOUS_VERSION_TAG` is the manual
previous-release string — kept manual because the previous release isn't
reliably derivable from `LIB_VERSION` across major bumps. All consumers
in `src/constants` are updated; hosted URLs are unchanged.
### Introduces a breaking change?
- [ ] Yes
- [x] No
### Type of change
- [x] Bug fix (change which fixes an issue)
- [ ] New feature (change which adds functionality)
- [ ] Documentation update (improves or adds clarity to existing
documentation)
- [ ] Other (chores, tests, code style improvements etc.)
### Tested on
- [x] iOS
- [x] Android
### Testing instructions
1. `yarn workspace react-native-executorch run prepare`.
2. Inspect
`packages/react-native-executorch/lib/module/constants/resourceFetcher.js`
— it should re-export `LIB_VERSION` from `./versions` with no
`require('../../package.json')` left.
3. `yarn typecheck` passes — covers the rename across `versions.ts`,
`modelUrls.ts`, `ocr/models.ts`, `tts/models.ts`, `tts/voices.ts`.
4. In a fresh Expo app with `react-native-web`, install the package from
this branch and run `npx expo start --web` — the bundler no longer
errors on the missing `lib/package.json`.
5. iOS/Android demo apps continue to build and report the expected
version. Exercise a model pinned to `PREVIOUS_VERSION_TAG` (e.g. any
Llama-3.2 / Qwen-3 / Whisper download) and one pinned to `VERSION_TAG`
(e.g. Qwen-3.5, YOLO26-pose, distiluse multilingual, privacy-filter) —
both should resolve to the same HuggingFace URLs as before the rename.
### Screenshots
### Related issues
Fixes #1138.
### Checklist
- [x] I have performed a self-review of my code
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have updated the documentation accordingly
- [x] My changes generate no new warnings
### Additional notes
`LIB_VERSION` is hardcoded next to the other version constants, so it
must be bumped manually alongside `package.json#version` (same release
step that already touches `PREVIOUS_VERSION_TAG`). `VERSION_TAG` is
derived from `LIB_VERSION`, so it updates automatically. A codegen
approach was considered but not adopted to keep the fix minimal.
---------
Co-authored-by: Mateusz Słuszniak <mateusz.sluszniak@swmansion.com>LIB_VERSION via codegen to fix compiled output (#1139)1 parent 51a4e91 commit 70957aa
6 files changed
Lines changed: 187 additions & 185 deletions
File tree
- packages/react-native-executorch/src/constants
- ocr
- tts
Lines changed: 173 additions & 173 deletions
Large diffs are not rendered by default.
Lines changed: 3 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
| 8 | + | |
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| |||
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
1 | 3 | | |
2 | 4 | | |
3 | | - | |
4 | | - | |
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
| 4 | + | |
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| |||
Lines changed: 3 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
| 2 | + | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
20 | | - | |
| 20 | + | |
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| |||
Lines changed: 4 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
1 | 3 | | |
2 | 4 | | |
3 | | - | |
4 | | - | |
| 5 | + | |
| 6 | + | |
0 commit comments