Skip to content

Commit 0f3f603

Browse files
committed
Added hmr mode
1 parent f50d34c commit 0f3f603

6 files changed

+18
-9
lines changed

lib/declarations.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -472,6 +472,7 @@ interface IOptions extends ICommonOptions, IBundleString, IPlatformTemplate, IHa
472472
chrome: boolean;
473473
inspector: boolean; // the counterpart to --chrome
474474
background: string;
475+
hmr: boolean;
475476
}
476477

477478
interface IEnvOptions {

lib/options.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ export class Options extends commonOptionsLibPath.OptionsBase {
4141
watch: { type: OptionType.Boolean, default: true },
4242
background: { type: OptionType.String },
4343
username: { type: OptionType.String },
44-
pluginName: { type: OptionType.String }
44+
pluginName: { type: OptionType.String },
45+
hmr: {type: OptionType.Boolean}
4546
},
4647
$errors, $staticConfig, $settingsService);
4748

@@ -50,6 +51,10 @@ export class Options extends commonOptionsLibPath.OptionsBase {
5051
if (that.justlaunch) {
5152
that.watch = false;
5253
}
54+
55+
if (that.hmr) {
56+
that.bundle = "webpack";
57+
}
5358
}
5459
}
5560
$injector.register("options", Options);

lib/services/livesync/android-device-livesync-service.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@ export class AndroidDeviceLiveSyncService extends DeviceLiveSyncServiceBase impl
1616
private $injector: IInjector,
1717
private $androidProcessService: Mobile.IAndroidProcessService,
1818
protected $platformsData: IPlatformsData,
19-
protected device: Mobile.IAndroidDevice) {
20-
super($platformsData, device);
19+
protected device: Mobile.IAndroidDevice,
20+
protected $options: IOptions) {
21+
super($platformsData, device, $options);
2122
}
2223

2324
public async refreshApplication(projectData: IProjectData, liveSyncInfo: ILiveSyncResultInfo): Promise<void> {

lib/services/livesync/android-device-livesync-sockets-service.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ export class AndroidDeviceSocketsLiveSyncService extends DeviceLiveSyncServiceBa
2020
protected $staticConfig: Config.IStaticConfig,
2121
private $logger: ILogger,
2222
protected device: Mobile.IAndroidDevice,
23-
private $options: ICommonOptions,
23+
protected $options: IOptions,
2424
private $processService: IProcessService,
2525
private $fs: IFileSystem,
2626
private $devicePlatformsConstants: Mobile.IDevicePlatformsConstants) {
27-
super($platformsData, device);
27+
super($platformsData, device, $options);
2828
this.livesyncTool = this.$injector.resolve(AndroidLivesyncTool);
2929
}
3030

lib/services/livesync/device-livesync-service-base.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,13 @@ export abstract class DeviceLiveSyncServiceBase {
66

77
constructor(
88
protected $platformsData: IPlatformsData,
9-
protected device: Mobile.IDevice
9+
protected device: Mobile.IDevice,
10+
protected $options: IOptions
1011
) { }
1112

1213
public canExecuteFastSync(filePath: string, projectData: IProjectData, platform: string): boolean {
1314
const fastSyncFileExtensions = this.getFastLiveSyncFileExtensions(platform, projectData);
14-
return _.includes(fastSyncFileExtensions, path.extname(filePath));
15+
return this.$options.hmr || _.includes(fastSyncFileExtensions, path.extname(filePath));
1516
}
1617

1718
protected canExecuteFastSyncForPaths(localToDevicePaths: Mobile.ILocalToDevicePathData[], projectData: IProjectData, platform: string) {

lib/services/livesync/ios-device-livesync-service.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@ export class IOSDeviceLiveSyncService extends DeviceLiveSyncServiceBase implemen
1717
private $fs: IFileSystem,
1818
private $processService: IProcessService,
1919
protected $platformsData: IPlatformsData,
20-
protected device: Mobile.IiOSDevice) {
21-
super($platformsData, device);
20+
protected device: Mobile.IiOSDevice,
21+
protected $options: IOptions) {
22+
super($platformsData, device, $options);
2223
}
2324

2425
private async setupSocketIfNeeded(projectData: IProjectData): Promise<boolean> {

0 commit comments

Comments
 (0)