Fix HMR when adding/renaming assets
Summary: The HMR logic used to try to calculate the dependencies of every new added (or modified) file, including assets. This resulted in a TransformError. This commit adds a check that stops the HMR bundling once it finds out that the updated file is an asset Reviewed By: cpojer Differential Revision: D5697391 fbshipit-source-id: faf7ccad76ac4922b70ed1c7ce8ce32b03c4e8ee
This commit is contained in:
parent
b6e0f4a12d
commit
79fdb91bb7
|
@ -239,6 +239,12 @@ function attachHMRServer<TModule: Moduleish>(
|
|||
client: Client,
|
||||
filename: string,
|
||||
): Promise<?HMRBundle> {
|
||||
// If the main file is an asset, do not generate a bundle.
|
||||
const moduleToUpdate = await packagerServer.getModuleForPath(filename);
|
||||
if (moduleToUpdate.isAsset()) {
|
||||
return;
|
||||
}
|
||||
|
||||
const deps = await packagerServer.getShallowDependencies({
|
||||
dev: true,
|
||||
minify: false,
|
||||
|
@ -269,9 +275,9 @@ function attachHMRServer<TModule: Moduleish>(
|
|||
recursive: true,
|
||||
});
|
||||
|
||||
const module = await packagerServer.getModuleForPath(filename);
|
||||
|
||||
resolutionResponse = await response.copy({dependencies: [module]});
|
||||
resolutionResponse = await response.copy({
|
||||
dependencies: [moduleToUpdate]},
|
||||
);
|
||||
} else {
|
||||
// if there're new dependencies compare the full list of
|
||||
// dependencies we used to have with the one we now have
|
||||
|
@ -283,8 +289,6 @@ function attachHMRServer<TModule: Moduleish>(
|
|||
resolutionResponse: myResolutionReponse,
|
||||
} = await getDependencies(client.platform, client.bundleEntry);
|
||||
|
||||
const moduleToUpdate = await packagerServer.getModuleForPath(filename);
|
||||
|
||||
// build list of modules for which we'll send HMR updates
|
||||
const modulesToUpdate = [moduleToUpdate];
|
||||
Object.keys(depsModulesCache).forEach(module => {
|
||||
|
|
Loading…
Reference in New Issue