1. /**
    
  2.  * Copyright (c) Meta Platforms, Inc. and affiliates.
    
  3.  *
    
  4.  * This source code is licensed under the MIT license found in the
    
  5.  * LICENSE file in the root directory of this source tree.
    
  6.  *
    
  7.  * @flow
    
  8.  */
    
  9. 
    
  10. const chunkMap: Map<string, string> = new Map();
    
  11. 
    
  12. /**
    
  13.  * We patch the chunk filename function in webpack to insert our own resolution
    
  14.  * of chunks that come from Flight and may not be known to the webpack runtime
    
  15.  */
    
  16. const webpackGetChunkFilename = __webpack_require__.u;
    
  17. __webpack_require__.u = function (chunkId: string) {
    
  18.   const flightChunk = chunkMap.get(chunkId);
    
  19.   if (flightChunk !== undefined) {
    
  20.     return flightChunk;
    
  21.   }
    
  22.   return webpackGetChunkFilename(chunkId);
    
  23. };
    
  24. 
    
  25. export function loadChunk(chunkId: string, filename: string): Promise<mixed> {
    
  26.   chunkMap.set(chunkId, filename);
    
  27.   return __webpack_chunk_load__(chunkId);
    
  28. }