Skip to content

Commit 52d34e3

Browse files
committed
Fix android with webpack
1 parent a8763db commit 52d34e3

File tree

3 files changed

+23
-4
lines changed

3 files changed

+23
-4
lines changed

lib/definitions/plugins.d.ts

+2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ interface IPluginsService {
1212
*/
1313
getDependenciesFromPackageJson(projectDir: string): IPackageJsonDepedenciesResult;
1414
validate(platformData: IPlatformData, projectData: IProjectData): Promise<void>;
15+
preparePluginNativeCode(pluginData: IPluginData, platform: string, projectData: IProjectData): Promise<void>;
16+
convertToPluginData(cacheData: any, projectDir: string): IPluginData;
1517
}
1618

1719
interface IPackageJsonDepedenciesResult {

lib/services/platform-service.ts

+19-2
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ export class PlatformService extends EventEmitter implements IPlatformService {
3939
private $npm: INodePackageManager,
4040
private $devicePlatformsConstants: Mobile.IDevicePlatformsConstants,
4141
private $projectChangesService: IProjectChangesService,
42-
private $analyticsService: IAnalyticsService) {
42+
private $analyticsService: IAnalyticsService,
43+
private $nodeModulesDependenciesBuilder: INodeModulesDependenciesBuilder) {
4344
super();
4445
}
4546

@@ -223,14 +224,20 @@ export class PlatformService extends EventEmitter implements IPlatformService {
223224
let platformData = this.$platformsData.getPlatformData(platform, projectData);
224225
await this.$pluginsService.validate(platformData, projectData);
225226

227+
const bundle = appFilesUpdaterOptions.bundle;
228+
226229
await this.ensurePlatformInstalled(platform, platformTemplate, projectData, config);
227-
let changesInfo = this.$projectChangesService.checkForChanges(platform, projectData, { bundle: appFilesUpdaterOptions.bundle, release: appFilesUpdaterOptions.release, provision: config.provision });
230+
let changesInfo = this.$projectChangesService.checkForChanges(platform, projectData, { bundle, release: appFilesUpdaterOptions.release, provision: config.provision });
228231

229232
this.$logger.trace("Changes info in prepare platform:", changesInfo);
230233

231234
if (changesInfo.hasChanges) {
232235
await this.cleanProject(platform, appFilesUpdaterOptions, platformData, projectData);
236+
}
237+
if (changesInfo.hasChanges || bundle) {
233238
await this.preparePlatformCore(platform, appFilesUpdaterOptions, projectData, config, changesInfo, filesToSync);
239+
}
240+
if (changesInfo.hasChanges) {
234241
this.$projectChangesService.savePrepareInfo(platform, projectData);
235242
} else {
236243
this.$logger.out("Skipping prepare.");
@@ -302,6 +309,16 @@ export class PlatformService extends EventEmitter implements IPlatformService {
302309

303310
if (!changesInfo || changesInfo.modulesChanged) {
304311
await this.copyTnsModules(platform, projectData);
312+
} else if (appFilesUpdaterOptions.bundle) {
313+
let dependencies = this.$nodeModulesDependenciesBuilder.getProductionDependencies(projectData.projectDir);
314+
for (let dependencyKey in dependencies) {
315+
const dependency = dependencies[dependencyKey];
316+
let isPlugin = !!dependency.nativescript;
317+
if (isPlugin) {
318+
let pluginData = this.$pluginsService.convertToPluginData(dependency, projectData.projectDir);
319+
await this.$pluginsService.preparePluginNativeCode(pluginData, platform, projectData);
320+
}
321+
}
305322
}
306323

307324
let directoryPath = path.join(platformData.appDestinationDirectoryPath, constants.APP_FOLDER_NAME);

lib/services/plugins-service.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ export class PluginsService implements IPluginsService {
139139
this.$projectFilesManager.processPlatformSpecificFiles(pluginScriptsDestinationPath, platform);
140140
}
141141

142-
private async preparePluginNativeCode(pluginData: IPluginData, platform: string, projectData: IProjectData): Promise<void> {
142+
public async preparePluginNativeCode(pluginData: IPluginData, platform: string, projectData: IProjectData): Promise<void> {
143143
let platformData = this.$platformsData.getPlatformData(platform, projectData);
144144

145145
pluginData.pluginPlatformsFolderPath = (_platform: string) => path.join(pluginData.fullPath, "platforms", _platform);
@@ -228,7 +228,7 @@ export class PluginsService implements IPluginsService {
228228
};
229229
}
230230

231-
private convertToPluginData(cacheData: any, projectDir: string): IPluginData {
231+
public convertToPluginData(cacheData: any, projectDir: string): IPluginData {
232232
let pluginData: any = {};
233233
pluginData.name = cacheData.name;
234234
pluginData.version = cacheData.version;

0 commit comments

Comments
 (0)