@gfean/react-native-bundle-drop 0.2.1 â 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/scripts/bundle.js +25 -0
- package/package.json +1 -1
package/lib/scripts/bundle.js
CHANGED
|
@@ -101,6 +101,31 @@ console.log(`đĻ Bundling React Native code for platform: ${platform}...`);
|
|
|
101
101
|
--bundle-output ${bundlePath} \
|
|
102
102
|
--assets-dest ${assetsDir}`, { stdio: 'inherit' });
|
|
103
103
|
console.log('â
Bundle created:', bundlePath);
|
|
104
|
+
// đĨ Compile to Hermes bytecode if hermesc is available.
|
|
105
|
+
// The presence of the hermesc binary is the most reliable indicator that the
|
|
106
|
+
// project uses Hermes â config flag locations vary across RN versions.
|
|
107
|
+
// If hermesc is not found, the plain JS bundle is used (works on JSC).
|
|
108
|
+
const osBin = process.platform === 'darwin' ? 'osx-bin' : process.platform === 'win32' ? 'win64-bin' : 'linux64-bin';
|
|
109
|
+
const hermesLocations = [
|
|
110
|
+
path.join(projectRoot, 'node_modules', 'react-native', 'sdks', 'hermesc', osBin, 'hermesc'),
|
|
111
|
+
path.join(projectRoot, 'node_modules', 'hermes-engine', osBin, 'hermesc'),
|
|
112
|
+
];
|
|
113
|
+
const hermescPath = hermesLocations.find(p => fs.existsSync(p));
|
|
114
|
+
if (hermescPath) {
|
|
115
|
+
console.log(`đĨ Compiling to Hermes bytecode (${platform})...`);
|
|
116
|
+
const hbcPath = bundlePath + '.hbc';
|
|
117
|
+
try {
|
|
118
|
+
(0, child_process_1.execSync)(`"${hermescPath}" -emit-binary -out "${hbcPath}" "${bundlePath}"`, { stdio: 'inherit' });
|
|
119
|
+
fs.renameSync(hbcPath, bundlePath);
|
|
120
|
+
console.log('â
Hermes bytecode compiled successfully');
|
|
121
|
+
}
|
|
122
|
+
catch (e) {
|
|
123
|
+
console.warn('â ī¸ Hermes compilation failed, falling back to plain JS bundle:', e.message);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
else {
|
|
127
|
+
console.log('âšī¸ hermesc not found â bundling plain JS (JSC or older RN)');
|
|
128
|
+
}
|
|
104
129
|
// đ Create metadata
|
|
105
130
|
const bundleBuffer = fs.readFileSync(bundlePath);
|
|
106
131
|
const hash = (0, crypto_1.createHash)('sha256').update(bundleBuffer).digest('hex');
|