Skip to content

Commit 373593a

Browse files
committed
fix: sync all files instead of the hmrFallbackFiles in --no-hmr flow
1 parent b1dba61 commit 373593a

File tree

1 file changed

+23
-13
lines changed

1 file changed

+23
-13
lines changed

lib/controllers/preview-app-controller.ts

+23-13
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ export class PreviewAppController extends EventEmitter implements IPreviewAppCon
1515
private devicesCanExecuteHmr: IDictionary<boolean> = {};
1616
// holds HMR files per device in order to execute batch upload on fast updates
1717
private devicesHmrFiles: IDictionary<string[]> = {};
18+
// holds app files per device in order to execute batch upload on fast updates on failed HMR or --no-hmr
19+
private devicesAppFiles: IDictionary<string[]> = {};
1820
// holds the current HMR hash per device in order to watch the proper hash status on fast updates
1921
private devicesCurrentHmrHash: IDictionary<string> = {};
2022

@@ -148,30 +150,38 @@ export class PreviewAppController extends EventEmitter implements IPreviewAppCon
148150
const currentSyncDeferPromise = deferPromise<void>();
149151
this.devicesLiveSyncChain[device.id] = currentSyncDeferPromise.promise;
150152
this.devicesCurrentHmrHash[device.id] = this.devicesCurrentHmrHash[device.id] || platformHmrData.hash;
151-
this.devicesHmrFiles[device.id] = this.devicesHmrFiles[device.id] || [];
152-
this.devicesHmrFiles[device.id].push(...files);
153-
await previousSync;
154-
if (!this.devicesHmrFiles[device.id] || !this.devicesHmrFiles[device.id].length) {
155-
this.$logger.info("Skipping files sync. The changes are already batch transferred in a previous sync.");
156-
currentSyncDeferPromise.resolve();
157-
return;
153+
if (data.useHotModuleReload) {
154+
this.devicesHmrFiles[device.id] = this.devicesHmrFiles[device.id] || [];
155+
this.devicesHmrFiles[device.id].push(...files);
156+
this.devicesAppFiles[device.id] = platformHmrData.fallbackFiles;
157+
} else {
158+
this.devicesHmrFiles[device.id] = [];
159+
this.devicesAppFiles[device.id] = files;
158160
}
159161

160-
try {
162+
await previousSync;
161163

162-
let executeHmrSync = false;
164+
try {
165+
let canExecuteHmrSync = false;
163166
const hmrHash = this.devicesCurrentHmrHash[device.id];
164167
this.devicesCurrentHmrHash[device.id] = null;
165168
if (data.useHotModuleReload && hmrHash) {
166169
if (this.devicesCanExecuteHmr[device.id]) {
167-
executeHmrSync = true;
168-
this.$hmrStatusService.watchHmrStatus(device.id, hmrHash);
170+
canExecuteHmrSync = true;
169171
}
170172
}
171173

172-
const filesToSync = executeHmrSync ? this.devicesHmrFiles[device.id] : platformHmrData.fallbackFiles;
174+
const filesToSync = canExecuteHmrSync ? this.devicesHmrFiles[device.id] : this.devicesAppFiles[device.id];
175+
if (!filesToSync || !filesToSync.length) {
176+
this.$logger.info(`Skipping files sync for device ${this.getDeviceDisplayName(device)}. The changes are already batch transferred in a previous sync.`);
177+
currentSyncDeferPromise.resolve();
178+
return;
179+
}
180+
173181
this.devicesHmrFiles[device.id] = [];
174-
if (executeHmrSync) {
182+
this.devicesAppFiles[device.id] = [];
183+
if (canExecuteHmrSync) {
184+
this.$hmrStatusService.watchHmrStatus(device.id, hmrHash);
175185
await this.syncFilesForPlatformSafe(data, { filesToSync }, platform, device);
176186
const status = await this.$hmrStatusService.getHmrStatus(device.id, hmrHash);
177187
if (!status) {

0 commit comments

Comments
 (0)