Skip to content

Commit 7f9c201

Browse files
fix android with webpack (#2925)
1 parent fb869c0 commit 7f9c201

File tree

5 files changed

+23
-4
lines changed

5 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

+17-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,13 +224,17 @@ 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);
234239
this.$projectChangesService.savePrepareInfo(platform, projectData);
235240
} else {
@@ -302,6 +307,16 @@ export class PlatformService extends EventEmitter implements IPlatformService {
302307

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

307322
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;

test/platform-commands.ts

+1
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ function createTestInjector() {
9696
testInjector.register("injector", testInjector);
9797
testInjector.register("hooksService", stubs.HooksServiceStub);
9898
testInjector.register("staticConfig", StaticConfigLib.StaticConfig);
99+
testInjector.register("nodeModulesDependenciesBuilder", {});
99100
testInjector.register('platformService', PlatformServiceLib.PlatformService);
100101
testInjector.register('errors', ErrorsNoFailStub);
101102
testInjector.register('logger', stubs.LoggerStub);

test/platform-service.ts

+1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ function createTestInjector() {
3030
testInjector.register('platformService', PlatformServiceLib.PlatformService);
3131
testInjector.register('errors', stubs.ErrorsStub);
3232
testInjector.register('logger', stubs.LoggerStub);
33+
testInjector.register("nodeModulesDependenciesBuilder", {});
3334
testInjector.register('npmInstallationManager', stubs.NpmInstallationManagerStub);
3435
testInjector.register('projectData', stubs.ProjectDataStub);
3536
testInjector.register('platformsData', stubs.PlatformsDataStub);

0 commit comments

Comments
 (0)