From c359d666c5a46126553bc8dd420c8828cfff65d0 Mon Sep 17 00:00:00 2001 From: Anton Nikolaev Date: Mon, 22 Jun 2020 02:39:30 -0700 Subject: [PATCH] Use default Metro implementation of source module ID mappings for "flipper-pkg bundle" Summary: Use default Metro implementation of source module ID mappings for "flipper-pkg bundle". The problem with the custom implementation we used before is that it is not deterministic, i.e. produced bundles are different on different machines. We need deterministic bundles to reliably detect if the version changed from the last deployment to Marketplace. Reviewed By: mweststrate Differential Revision: D22158794 fbshipit-source-id: ae4b4b05e020489c0900423107a938a5b670e7d8 --- desktop/pkg-lib/src/runBuild.ts | 27 --------------------------- 1 file changed, 27 deletions(-) diff --git a/desktop/pkg-lib/src/runBuild.ts b/desktop/pkg-lib/src/runBuild.ts index 67a0eacaf..a5c8b91aa 100644 --- a/desktop/pkg-lib/src/runBuild.ts +++ b/desktop/pkg-lib/src/runBuild.ts @@ -29,32 +29,6 @@ async function getMetroDir() { return __dirname; } -function hash(string: string) { - let hash = 0; - if (string.length === 0) { - return hash; - } - let chr; - for (let i = 0; i < string.length; i++) { - chr = string.charCodeAt(i); - hash = (hash << 5) - hash + chr; - hash |= 0; - } - return hash; -} -const fileToIdMap = new Map(); -const createModuleIdFactory = () => (filePath: string) => { - if (filePath === '__prelude__') { - return 0; - } - let id = fileToIdMap.get(filePath); - if (typeof id !== 'number') { - id = hash(filePath); - fileToIdMap.set(filePath, id); - } - return id; -}; - export default async function runBuild( inputDirectory: string, entry: string, @@ -72,7 +46,6 @@ export default async function runBuild( ...baseConfig.serializer, getRunModuleStatement: (moduleID: string) => `module.exports = global.__r(${moduleID}).default;`, - createModuleIdFactory, }, transformer: { ...baseConfig.transformer,