Skip to content
Open
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
3 changes: 2 additions & 1 deletion packages/react-native-executorch/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@
"typecheck": "tsc --noEmit",
"lint": "eslint \"**/*.{js,ts,tsx}\"",
"clean": "del-cli android/build example/android/build example/android/app/build example/ios/build lib",
"prepare": "bob build",
"prepare": "node scripts/sync-version.cjs && bob build",
"version": "node scripts/sync-version.cjs && git add src/constants/libVersion.ts",
"prepack": "cp ../../README.md ./README.md",
"postpack": "rm ./README.md"
},
Expand Down
24 changes: 24 additions & 0 deletions packages/react-native-executorch/scripts/sync-version.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env node
// Reads this package's package.json#version and writes it into
// src/constants/libVersion.ts as a literal export. We do this so the
// compiled output (lib/module/constants/libVersion.js) does not need
// a runtime require('../../package.json') — that path is correct from
// src/constants/ but wrong from lib/module/constants/ after bob's output
// nesting, and breaks any consumer that resolves through the "main"/
// "module" fields instead of the "react-native" field (e.g. web/Node).

const { readFileSync, writeFileSync } = require('node:fs');
const { resolve } = require('node:path');

const pkgPath = resolve(__dirname, '..', 'package.json');
const outPath = resolve(__dirname, '..', 'src', 'constants', 'libVersion.ts');

const { version } = JSON.parse(readFileSync(pkgPath, 'utf8'));

const body =
'// AUTO-GENERATED by scripts/sync-version.cjs — do not edit by hand.\n' +
'// Source of truth: package.json#version.\n' +
`export const LIB_VERSION: string = '${version}';\n`;

writeFileSync(outPath, body, 'utf8');
console.log(`[sync-version] wrote ${outPath} (LIB_VERSION=${version})`);
3 changes: 3 additions & 0 deletions packages/react-native-executorch/src/constants/libVersion.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// AUTO-GENERATED by scripts/sync-version.cjs — do not edit by hand.
// Source of truth: package.json#version.
export const LIB_VERSION: string = '0.9.0';
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const DOWNLOAD_EVENT_ENDPOINT =
'https://ai.swmansion.com/telemetry/downloads/api/downloads';

export const LIB_VERSION: string = require('../../package.json').version;
export { LIB_VERSION } from './libVersion';
Loading