(entryPoint, preModules, graph, options)
| 154 | } |
| 155 | |
| 156 | function metadataSerializer(entryPoint, preModules, graph, options) { |
| 157 | setupHermescWrapper(); |
| 158 | const baseJSBundle = require('metro/src/DeltaBundler/Serializers/baseJSBundle'); |
| 159 | const bundleToString = require('metro/src/lib/bundleToString'); |
| 160 | const bundle = baseJSBundle(entryPoint, preModules, graph, options); |
| 161 | const { code: bundleCode } = bundleToString(bundle); |
| 162 | const contentHash = calculateContentHash(bundleCode); |
| 163 | const metadataInjection = generateMetadataInjection(contentHash); |
| 164 | const metadataComment = generateMetadataComment(contentHash); |
| 165 | const hashFilePath = path.join(PROJECT_ROOT, 'bundle-hash.json'); |
| 166 | |
| 167 | try { |
| 168 | const hashData = { |
| 169 | contentHash, |
| 170 | timestamp: new Date().toISOString(), |
| 171 | }; |
| 172 | fs.writeFileSync(hashFilePath, JSON.stringify(hashData, null, 2)); |
| 173 | console.log(`✅ [Metro] Saved hash to: ${hashFilePath}`); |
| 174 | console.log(`🔐 [Metro] Hash: ${contentHash.slice(0, 16)}...`); |
| 175 | } catch (error) { |
| 176 | console.error('❌ [Metro] Failed to save hash file:', error); |
| 177 | } |
| 178 | |
| 179 | return bundleCode + metadataInjection + metadataComment; |
| 180 | } |
| 181 | |
| 182 | module.exports = { |
| 183 | metadataSerializer, |
nothing calls this directly
no test coverage detected