Skip to content

Commit 2abae5f

Browse files
author
Dimitar Tachev
authored
Merge pull request #3907 from NativeScript/tachev/preview-hmr
Pass the HMR option to the hooks and preview URL
2 parents 3c77d2a + c2a47b9 commit 2abae5f

25 files changed

+178
-47
lines changed

lib/commands/appstore-upload.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,11 @@ export class PublishIOS implements ICommand {
5656
if (!ipaFilePath) {
5757
const platform = this.$devicePlatformsConstants.iOS;
5858
// No .ipa path provided, build .ipa on out own.
59-
const appFilesUpdaterOptions: IAppFilesUpdaterOptions = { bundle: !!this.$options.bundle, release: this.$options.release };
59+
const appFilesUpdaterOptions: IAppFilesUpdaterOptions = {
60+
bundle: !!this.$options.bundle,
61+
release: this.$options.release,
62+
useHotModuleReload: false
63+
};
6064
const platformInfo: IPreparePlatformInfo = {
6165
platform,
6266
appFilesUpdaterOptions,

lib/commands/build.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,11 @@ export abstract class BuildCommandBase extends ValidatePlatformCommandBase {
1515

1616
public async executeCore(args: string[]): Promise<void> {
1717
const platform = args[0].toLowerCase();
18-
const appFilesUpdaterOptions: IAppFilesUpdaterOptions = { bundle: !!this.$options.bundle, release: this.$options.release };
18+
const appFilesUpdaterOptions: IAppFilesUpdaterOptions = {
19+
bundle: !!this.$options.bundle,
20+
release: this.$options.release,
21+
useHotModuleReload: this.$options.hmr
22+
};
1923
const platformInfo: IPreparePlatformInfo = {
2024
platform,
2125
appFilesUpdaterOptions,

lib/commands/clean-app.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,11 @@ export class CleanAppCommandBase extends ValidatePlatformCommandBase implements
1616
}
1717

1818
public async execute(args: string[]): Promise<void> {
19-
const appFilesUpdaterOptions: IAppFilesUpdaterOptions = { bundle: !!this.$options.bundle, release: this.$options.release };
19+
const appFilesUpdaterOptions: IAppFilesUpdaterOptions = {
20+
bundle: !!this.$options.bundle,
21+
release: this.$options.release,
22+
useHotModuleReload: false
23+
};
2024
const platformInfo: IPreparePlatformInfo = {
2125
appFilesUpdaterOptions,
2226
platform: this.platform.toLowerCase(),

lib/commands/prepare.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,11 @@ export class PrepareCommand extends ValidatePlatformCommandBase implements IComm
1313
}
1414

1515
public async execute(args: string[]): Promise<void> {
16-
const appFilesUpdaterOptions: IAppFilesUpdaterOptions = { bundle: !!this.$options.bundle, release: this.$options.release };
16+
const appFilesUpdaterOptions: IAppFilesUpdaterOptions = {
17+
bundle: !!this.$options.bundle,
18+
release: this.$options.release,
19+
useHotModuleReload: this.$options.hmr
20+
};
1721
const platformInfo: IPreparePlatformInfo = {
1822
platform: args[0],
1923
appFilesUpdaterOptions,

lib/commands/preview.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,11 @@ export class PreviewCommand implements ICommand {
2121
bundle: !!this.$options.bundle,
2222
release: this.$options.release,
2323
env: this.$options.env,
24-
timeout: this.$options.timeout
24+
timeout: this.$options.timeout,
25+
useHotModuleReload: this.$options.hmr
2526
});
2627

27-
await this.$playgroundQrCodeGenerator.generateQrCodeForCurrentApp();
28+
await this.$playgroundQrCodeGenerator.generateQrCodeForCurrentApp({ useHotModuleReload: this.$options.hmr });
2829
}
2930

3031
public async canExecute(args: string[]): Promise<boolean> {

lib/declarations.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,7 @@ interface IEnvOptions {
486486

487487
interface IAndroidBuildOptionsSettings extends IAndroidReleaseOptions, IRelease { }
488488

489-
interface IAppFilesUpdaterOptions extends IBundle, IRelease, IOptionalWatchAllFiles { }
489+
interface IAppFilesUpdaterOptions extends IBundle, IRelease, IOptionalWatchAllFiles, IHasUseHotModuleReloadOption { }
490490

491491
interface IPlatformBuildData extends IAppFilesUpdaterOptions, IBuildConfig, IEnvOptions { }
492492

lib/definitions/livesync.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ interface IHasUseHotModuleReloadOption {
180180
/**
181181
* Defines if the hot module reload should be used.
182182
*/
183-
useHotModuleReload?: boolean;
183+
useHotModuleReload: boolean;
184184
}
185185

186186
interface ILatestAppPackageInstalledSettings extends IDictionary<IDictionary<boolean>> { /* empty */ }

lib/definitions/preview-app-livesync.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ declare global {
1010
interface IPreviewAppLiveSyncData extends IProjectDir, IAppFilesUpdaterOptionsComposition, IEnvOptions { }
1111

1212
interface IPreviewSdkService {
13-
qrCodeUrl: string;
13+
getQrCodeUrl(options: IHasUseHotModuleReloadOption): string;
1414
connectedDevices: Device[];
1515
initialize(getInitialFiles: (device: Device) => Promise<FilesPayload>): void;
1616
applyChanges(filesPayload: FilesPayload): Promise<void>;
@@ -29,6 +29,6 @@ declare global {
2929
interface IPlaygroundQrCodeGenerator {
3030
generateQrCodeForiOS(): Promise<void>;
3131
generateQrCodeForAndroid(): Promise<void>;
32-
generateQrCodeForCurrentApp(): Promise<void>;
32+
generateQrCodeForCurrentApp(options: IHasUseHotModuleReloadOption): Promise<void>;
3333
}
3434
}

lib/helpers/deploy-command-helper.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,11 @@ export class DeployCommandHelper implements IDeployCommandHelper {
77
}
88

99
public getDeployPlatformInfo(platform: string): IDeployPlatformInfo {
10-
const appFilesUpdaterOptions: IAppFilesUpdaterOptions = { bundle: !!this.$options.bundle, release: this.$options.release };
10+
const appFilesUpdaterOptions: IAppFilesUpdaterOptions = {
11+
bundle: !!this.$options.bundle,
12+
release: this.$options.release,
13+
useHotModuleReload: this.$options.hmr
14+
};
1115
const deployOptions: IDeployPlatformOptions = {
1216
clean: this.$options.clean,
1317
device: this.$options.device,

lib/helpers/livesync-command-helper.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,8 @@ export class LiveSyncCommandHelper implements ILiveSyncCommandHelper {
156156
platform: currentPlatform,
157157
appFilesUpdaterOptions: {
158158
bundle: !!this.$options.bundle,
159-
release: this.$options.release
159+
release: this.$options.release,
160+
useHotModuleReload: this.$options.hmr
160161
},
161162
deployOptions,
162163
buildPlatform: this.$platformService.buildPlatform.bind(this.$platformService),

0 commit comments

Comments
 (0)