mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
8b08ee08a1
This commit updates the file locations and bulid configurations for flight in preparation for new static entrypoints. This follows a structure similar to Fizz which has a unified build but exports methods from different top level entrypoints. This PR doesn't actually add the new top level entrypoints however, that will arrive in a later update.
29 lines
842 B
JavaScript
29 lines
842 B
JavaScript
/**
|
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*
|
|
* @flow
|
|
*/
|
|
|
|
const chunkMap: Map<string, string> = new Map();
|
|
|
|
/**
|
|
* We patch the chunk filename function in webpack to insert our own resolution
|
|
* of chunks that come from Flight and may not be known to the webpack runtime
|
|
*/
|
|
const webpackGetChunkFilename = __webpack_require__.u;
|
|
__webpack_require__.u = function (chunkId: string) {
|
|
const flightChunk = chunkMap.get(chunkId);
|
|
if (flightChunk !== undefined) {
|
|
return flightChunk;
|
|
}
|
|
return webpackGetChunkFilename(chunkId);
|
|
};
|
|
|
|
export function loadChunk(chunkId: string, filename: string): Promise<mixed> {
|
|
chunkMap.set(chunkId, filename);
|
|
return __webpack_chunk_load__(chunkId);
|
|
}
|