From bff0b1f9d65c25fea67294773ce91c47452eac56 Mon Sep 17 00:00:00 2001 From: David Aurelio Date: Mon, 14 Mar 2016 17:20:18 -0700 Subject: [PATCH] Use numeric module IDs for iOS RA-bundles Summary:Use the new numeric module IDs for indexed-file random access bundles, rather than string-based module names This still uses those IDs as strings in the table, to make this bundle format work again. Reviewed By: martinbigio Differential Revision: D3050337 fb-gh-sync-id: f8da69cdbafd1b093a71474698796be5d21fc4f6 shipit-source-id: f8da69cdbafd1b093a71474698796be5d21fc4f6 --- local-cli/bundle/output/unbundle/as-indexed-file.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/local-cli/bundle/output/unbundle/as-indexed-file.js b/local-cli/bundle/output/unbundle/as-indexed-file.js index 870ffdb1f..ea23cf38e 100644 --- a/local-cli/bundle/output/unbundle/as-indexed-file.js +++ b/local-cli/bundle/output/unbundle/as-indexed-file.js @@ -65,9 +65,9 @@ function writeBuffers(stream, buffers) { }); } -function moduleToBuffer(name, code, encoding) { +function moduleToBuffer(id, code, encoding) { return { - name, + id, linesCount: code.split('\n').length, buffer: Buffer.concat([ Buffer(code, encoding), @@ -101,10 +101,10 @@ function buildModuleTable(buffers) { const offsetTable = [tableLengthBuffer]; for (let i = 0; i < numBuffers; i++) { - const {name, linesCount, buffer: {length}} = buffers[i]; + const {id, linesCount, buffer: {length}} = buffers[i]; const entry = Buffer.concat([ - Buffer(i === 0 ? MAGIC_STARTUP_MODULE_ID : name, 'utf8'), + Buffer(i === 0 ? MAGIC_STARTUP_MODULE_ID : id, 'utf8'), nullByteBuffer, uInt32Buffer(currentOffset), uInt32Buffer(currentLine), @@ -126,7 +126,7 @@ function buildModuleBuffers(startupCode, modules, encoding) { [moduleToBuffer('', startupCode, encoding, true)].concat( modules.map(module => moduleToBuffer( - module.name, + String(module.id), module.code + '\n', // each module starts on a newline encoding, )