Skip to content

Commit 41ba075

Browse files
committed
Pass externals to sync-preview hook
1 parent 0310ef0 commit 41ba075

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

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

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ declare global {
2020

2121
interface IPreviewAppPluginsService {
2222
comparePluginsOnDevice(device: Device): Promise<void>;
23+
getExternalPlugins(device: Device): string[];
2324
}
2425

2526
interface IPreviewCommandHelper {

lib/services/livesync/playground/preview-app-livesync-service.ts

+1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ export class PreviewAppLiveSyncService implements IPreviewAppLiveSyncService {
4444
platform: device.platform,
4545
appFilesUpdaterOptions: data.appFilesUpdaterOptions,
4646
},
47+
externals: this.$previewAppPluginsService.getExternalPlugins(device),
4748
filesToSyncMap,
4849
  startSyncFilesTimeout: startSyncFilesTimeout.bind(this)
4950
}

lib/services/livesync/playground/preview-app-plugins-service.ts

+13
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,19 @@ export class PreviewAppPluginsService implements IPreviewAppPluginsService {
3636
});
3737
}
3838

39+
public getExternalPlugins(device: Device): any[] {
40+
const devicePlugins = this.getDevicePlugins(device);
41+
const result = _.keys(devicePlugins)
42+
.filter(plugin => plugin.indexOf("nativescript") !== -1)
43+
.filter(plugin => !_.includes(["nativescript-angular", "nativescript-vue", "nativescript-intl"], plugin));
44+
45+
// HACK: We need this in order to work around the following code https://github.com/NativeScript/template-hello-world/blob/master/app/app.js#L7
46+
// If we need to remove this, the code above should be changed to: "var application = require("tns-core-modules/application")"
47+
result.push(...[ "application"]);
48+
49+
return result;
50+
}
51+
3952
private getDevicePlugins(device: Device): IStringDictionary {
4053
try {
4154
return JSON.parse(device.plugins);

0 commit comments

Comments
 (0)