Write tt-native package.json under both bundle key shapes on Windows
CI / Build & Test (push) Successful in 3m49s

After unmount, the runtime may resolve #package with or without a
leading slash. Write the same content to both keys so the .json
loader never gets an empty entry and the host no longer crashes with
"Unexpected end of JSON input" on Windows.
This commit is contained in:
Raven Scott
2026-03-06 19:05:51 -05:00
parent 0e0822aa81
commit fe8930b1fd
+5 -1
View File
@@ -183,9 +183,13 @@ function patchBundle(bundle, hosts) {
// Ensure tt-native package.json has content in the bundle. On Windows the runtime
// can end up reading empty content for this key (path/bundle handling), causing
// "Unexpected end of JSON input" when the .json loader runs. Explicitly write it.
// Write to both key shapes (with and without leading slash) so the runtime finds
// it regardless of how the bundle protocol normalizes keys after unmount.
const pkgPath = path.join(NATIVE_HOST_DIR, 'node_modules', 'tt-native', 'package.json')
if (fs.existsSync(pkgPath)) {
bundle.write(ttNativePkgKey, fs.readFileSync(pkgPath))
const pkgContent = fs.readFileSync(pkgPath)
bundle.write(ttNativePkgKey, pkgContent)
bundle.write(ttNativePkgKey.slice(1), pkgContent)
}
console.log(' Patched tt-native binding (host-specific resolutions)')
}