Skip to content

Fix android with webpack #2925

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 27, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/definitions/plugins.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ interface IPluginsService {
*/
getDependenciesFromPackageJson(projectDir: string): IPackageJsonDepedenciesResult;
validate(platformData: IPlatformData, projectData: IProjectData): Promise<void>;
preparePluginNativeCode(pluginData: IPluginData, platform: string, projectData: IProjectData): Promise<void>;
convertToPluginData(cacheData: any, projectDir: string): IPluginData;
}

interface IPackageJsonDepedenciesResult {
Expand Down
19 changes: 17 additions & 2 deletions lib/services/platform-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ export class PlatformService extends EventEmitter implements IPlatformService {
private $npm: INodePackageManager,
private $devicePlatformsConstants: Mobile.IDevicePlatformsConstants,
private $projectChangesService: IProjectChangesService,
private $analyticsService: IAnalyticsService) {
private $analyticsService: IAnalyticsService,
private $nodeModulesDependenciesBuilder: INodeModulesDependenciesBuilder) {
super();
}

Expand Down Expand Up @@ -223,13 +224,17 @@ export class PlatformService extends EventEmitter implements IPlatformService {
let platformData = this.$platformsData.getPlatformData(platform, projectData);
await this.$pluginsService.validate(platformData, projectData);

const bundle = appFilesUpdaterOptions.bundle;

await this.ensurePlatformInstalled(platform, platformTemplate, projectData, config);
let changesInfo = this.$projectChangesService.checkForChanges(platform, projectData, { bundle: appFilesUpdaterOptions.bundle, release: appFilesUpdaterOptions.release, provision: config.provision });
let changesInfo = this.$projectChangesService.checkForChanges(platform, projectData, { bundle, release: appFilesUpdaterOptions.release, provision: config.provision });

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

if (changesInfo.hasChanges) {
await this.cleanProject(platform, appFilesUpdaterOptions, platformData, projectData);
}
if (changesInfo.hasChanges || bundle) {
await this.preparePlatformCore(platform, appFilesUpdaterOptions, projectData, config, changesInfo, filesToSync);
this.$projectChangesService.savePrepareInfo(platform, projectData);
} else {
Expand Down Expand Up @@ -302,6 +307,16 @@ export class PlatformService extends EventEmitter implements IPlatformService {

if (!changesInfo || changesInfo.modulesChanged) {
await this.copyTnsModules(platform, projectData);
} else if (appFilesUpdaterOptions.bundle) {
let dependencies = this.$nodeModulesDependenciesBuilder.getProductionDependencies(projectData.projectDir);
for (let dependencyKey in dependencies) {
const dependency = dependencies[dependencyKey];
let isPlugin = !!dependency.nativescript;
if (isPlugin) {
let pluginData = this.$pluginsService.convertToPluginData(dependency, projectData.projectDir);
await this.$pluginsService.preparePluginNativeCode(pluginData, platform, projectData);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of exposing preparePluginNativeCode and convertToPluginData can't we just call this.$pluginsService.prepare... ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, it will move scripts to app/tns_modules I think, and we need to avoid that :(

}
}
}

let directoryPath = path.join(platformData.appDestinationDirectoryPath, constants.APP_FOLDER_NAME);
Expand Down
4 changes: 2 additions & 2 deletions lib/services/plugins-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ export class PluginsService implements IPluginsService {
this.$projectFilesManager.processPlatformSpecificFiles(pluginScriptsDestinationPath, platform);
}

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

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

private convertToPluginData(cacheData: any, projectDir: string): IPluginData {
public convertToPluginData(cacheData: any, projectDir: string): IPluginData {
let pluginData: any = {};
pluginData.name = cacheData.name;
pluginData.version = cacheData.version;
Expand Down
1 change: 1 addition & 0 deletions test/platform-commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ function createTestInjector() {
testInjector.register("injector", testInjector);
testInjector.register("hooksService", stubs.HooksServiceStub);
testInjector.register("staticConfig", StaticConfigLib.StaticConfig);
testInjector.register("nodeModulesDependenciesBuilder", {});
testInjector.register('platformService', PlatformServiceLib.PlatformService);
testInjector.register('errors', ErrorsNoFailStub);
testInjector.register('logger', stubs.LoggerStub);
Expand Down
1 change: 1 addition & 0 deletions test/platform-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ function createTestInjector() {
testInjector.register('platformService', PlatformServiceLib.PlatformService);
testInjector.register('errors', stubs.ErrorsStub);
testInjector.register('logger', stubs.LoggerStub);
testInjector.register("nodeModulesDependenciesBuilder", {});
testInjector.register('npmInstallationManager', stubs.NpmInstallationManagerStub);
testInjector.register('projectData', stubs.ProjectDataStub);
testInjector.register('platformsData', stubs.PlatformsDataStub);
Expand Down