diff --git a/lib/controllers/prepare-controller.ts b/lib/controllers/prepare-controller.ts index 7d42212afd..2cebc5ff38 100644 --- a/lib/controllers/prepare-controller.ts +++ b/lib/controllers/prepare-controller.ts @@ -22,7 +22,7 @@ import { TrackActionNames, WEBPACK_COMPILATION_COMPLETE, } from "../constants"; -import { IWatchIgnoreListService } from "../declarations"; +import { IOptions, IWatchIgnoreListService } from "../declarations"; import { INodeModulesDependenciesBuilder, IPlatformController, @@ -59,6 +59,7 @@ export class PrepareController extends EventEmitter { public $hooksService: IHooksService, private $fs: IFileSystem, private $logger: ILogger, + private $options: IOptions, private $mobileHelper: Mobile.IMobileHelper, private $nodeModulesDependenciesBuilder: INodeModulesDependenciesBuilder, private $platformsDataService: IPlatformsDataService, @@ -134,10 +135,13 @@ export class PrepareController extends EventEmitter { projectData: IProjectData ): Promise { await this.$projectService.ensureAppResourcesExist(projectData.projectDir); - await this.$platformController.addPlatformIfNeeded( - prepareData, - projectData - ); + if (!this.$options.nativeHost) { + await this.$platformController.addPlatformIfNeeded( + prepareData, + projectData + ); + } + await this.trackRuntimeVersion(prepareData.platform, projectData); this.$logger.info("Preparing project..."); @@ -479,9 +483,9 @@ export class PrepareController extends EventEmitter { console.log("!!!!! VM: proj root: " + platformData.projectRoot); packagePath = path.join( platformData.projectRoot, - "app", + this.$options.nativeHostModule, "src", - "main", + this.$options.nativeHost ? "nativescript" : "main", "assets", "app", "package.json" diff --git a/lib/declarations.d.ts b/lib/declarations.d.ts index f9efebb592..c523134b5a 100644 --- a/lib/declarations.d.ts +++ b/lib/declarations.d.ts @@ -578,16 +578,18 @@ interface IAndroidBundleOptions { aab: boolean; } -interface IAndroidOptions { - gradlePath: string; - gradleArgs: string; +interface IEmbedOptions { nativeHost: string; + nativeHostModule: string; } -interface IIOSOptions { - nativeHost: string; +interface IAndroidOptions extends IEmbedOptions { + gradlePath: string; + gradleArgs: string; } +interface IIOSOptions extends IEmbedOptions {} + interface ITypingsOptions { jar: string; aar: string; diff --git a/lib/helpers/platform-command-helper.ts b/lib/helpers/platform-command-helper.ts index 175d3a6eb4..91b9f41417 100644 --- a/lib/helpers/platform-command-helper.ts +++ b/lib/helpers/platform-command-helper.ts @@ -39,6 +39,11 @@ export class PlatformCommandHelper implements IPlatformCommandHelper { frameworkPath: string, nativeHost?: string ): Promise { + if (this.$options.nativeHost) { + this.$logger.info("Ignoring platform add becuase of --android-host flag"); + return; + } + const platformsDir = projectData.platformsDir; this.$fs.ensureDirectoryExists(platformsDir); @@ -86,6 +91,13 @@ export class PlatformCommandHelper implements IPlatformCommandHelper { platforms: string[], projectData: IProjectData ): Promise { + if (this.$options.nativeHost) { + this.$logger.info( + "Ignoring platform remove becuase of --android-host flag" + ); + return; + } + for (const platform of platforms) { this.$platformValidationService.validatePlatformInstalled( platform, diff --git a/lib/options.ts b/lib/options.ts index 02ee710822..fce4efc907 100644 --- a/lib/options.ts +++ b/lib/options.ts @@ -10,6 +10,7 @@ import { ISettingsService, } from "./common/declarations"; import { injector } from "./common/yok"; +import { APP_FOLDER_NAME } from "./constants"; export class Options { private static DASHED_OPTION_REGEX = /(.+?)([A-Z])(.*)/; private static NONDASHED_OPTION_REGEX = /(.+?)[-]([a-zA-Z])(.*)/; @@ -228,6 +229,11 @@ export class Options { gradlePath: { type: OptionType.String, hasSensitiveValue: false }, gradleArgs: { type: OptionType.String, hasSensitiveValue: false }, nativeHost: { type: OptionType.String, hasSensitiveValue: false }, + nativeHostModule: { + type: OptionType.String, + hasSensitiveValue: false, + default: APP_FOLDER_NAME, + }, aab: { type: OptionType.Boolean, hasSensitiveValue: false }, performance: { type: OptionType.Object, hasSensitiveValue: true }, appleApplicationSpecificPassword: { diff --git a/lib/providers/project-files-provider.ts b/lib/providers/project-files-provider.ts index 1f3337f906..6ce80f787f 100644 --- a/lib/providers/project-files-provider.ts +++ b/lib/providers/project-files-provider.ts @@ -54,7 +54,7 @@ export class ProjectFilesProvider extends ProjectFilesProviderBase { ); mappedFilePath = path.join( platformData.appDestinationDirectoryPath, - constants.APP_FOLDER_NAME, + this.$options.nativeHostModule, relativePath ); } diff --git a/lib/services/android-plugin-build-service.ts b/lib/services/android-plugin-build-service.ts index 84757adbd1..97dfa4bc24 100644 --- a/lib/services/android-plugin-build-service.ts +++ b/lib/services/android-plugin-build-service.ts @@ -15,6 +15,7 @@ import { INodePackageManager, IAndroidToolsInfo, IWatchIgnoreListService, + IOptions, } from "../declarations"; import { IPlatformsDataService } from "../definitions/platform"; import { IProjectData, IProjectDataService } from "../definitions/project"; @@ -37,6 +38,7 @@ import { IInjector } from "../common/definitions/yok"; import { injector } from "../common/yok"; import * as _ from "lodash"; import { resolvePackageJSONPath } from "@rigor789/resolve-package-path"; +import { cwd } from "process"; export class AndroidPluginBuildService implements IAndroidPluginBuildService { private get $platformsDataService(): IPlatformsDataService { @@ -47,6 +49,7 @@ export class AndroidPluginBuildService implements IAndroidPluginBuildService { private $fs: IFileSystem, private $childProcess: IChildProcess, private $hostInfo: IHostInfo, + private $options: IOptions, private $androidToolsInfo: IAndroidToolsInfo, private $logger: ILogger, private $packageManager: INodePackageManager, @@ -803,6 +806,7 @@ export class AndroidPluginBuildService implements IAndroidPluginBuildService { `-PappPath=${this.$projectData.getAppDirectoryPath()}`, `-PappResourcesPath=${this.$projectData.getAppResourcesDirectoryPath()}`, ]; + if (pluginBuildSettings.gradleArgs) { localArgs.push(pluginBuildSettings.gradleArgs); } @@ -811,12 +815,29 @@ export class AndroidPluginBuildService implements IAndroidPluginBuildService { localArgs.push("--quiet"); } + const opts: any = { + cwd: pluginBuildSettings.pluginDir, + stdio: "inherit", + shell: this.$hostInfo.isWindows, + }; + + if (this.$options.nativeHost) { + opts.env = { + USER_PROJECT_PLATFORMS_ANDROID: path.resolve( + cwd(), + this.$options.nativeHost + ), // TODO: couldn't `nativeHost` have an absolute path already? + ...process.env, // TODO: any other way to pass automatically the current process.env? + }; + } + try { - await this.$childProcess.spawnFromEvent(gradlew, localArgs, "close", { - cwd: pluginBuildSettings.pluginDir, - stdio: "inherit", - shell: this.$hostInfo.isWindows, - }); + await this.$childProcess.spawnFromEvent( + gradlew, + localArgs, + "close", + opts + ); } catch (err) { this.$errors.fail( `Failed to build plugin ${pluginBuildSettings.pluginName} : \n${err}` diff --git a/lib/services/android-project-service.ts b/lib/services/android-project-service.ts index 6a76e0f790..42b3c26cdb 100644 --- a/lib/services/android-project-service.ts +++ b/lib/services/android-project-service.ts @@ -173,21 +173,21 @@ export class AndroidProjectService extends projectServiceBaseLib.PlatformProject const appDestinationDirectoryArr = [ projectRoot, - constants.APP_FOLDER_NAME, + this.$options.nativeHostModule, constants.SRC_DIR, constants.MAIN_DIR, constants.ASSETS_DIR, ]; const configurationsDirectoryArr = [ projectRoot, - constants.APP_FOLDER_NAME, + this.$options.nativeHostModule, constants.SRC_DIR, constants.MAIN_DIR, constants.MANIFEST_FILE_NAME, ]; const deviceBuildOutputArr = [ projectRoot, - constants.APP_FOLDER_NAME, + this.$options.nativeHostModule, constants.BUILD_DIR, constants.OUTPUTS_DIR, constants.APK_DIR, @@ -210,7 +210,7 @@ export class AndroidProjectService extends projectServiceBaseLib.PlatformProject if (buildOptions.androidBundle) { return path.join( projectRoot, - constants.APP_FOLDER_NAME, + this.$options.nativeHostModule, constants.BUILD_DIR, constants.OUTPUTS_DIR, constants.BUNDLE_DIR @@ -229,8 +229,8 @@ export class AndroidProjectService extends projectServiceBaseLib.PlatformProject if (buildOptions.androidBundle) { return { packageNames: [ - `${constants.APP_FOLDER_NAME}${constants.AAB_EXTENSION_NAME}`, - `${constants.APP_FOLDER_NAME}-${buildMode}${constants.AAB_EXTENSION_NAME}`, + `${this.$options.nativeHostModule}${constants.AAB_EXTENSION_NAME}`, + `${this.$options.nativeHostModule}-${buildMode}${constants.AAB_EXTENSION_NAME}`, ], }; } @@ -240,11 +240,11 @@ export class AndroidProjectService extends projectServiceBaseLib.PlatformProject `${packageName}-${buildMode}${constants.APK_EXTENSION_NAME}`, `${projectData.projectName}-${buildMode}${constants.APK_EXTENSION_NAME}`, `${projectData.projectName}${constants.APK_EXTENSION_NAME}`, - `${constants.APP_FOLDER_NAME}-${buildMode}${constants.APK_EXTENSION_NAME}`, + `${this.$options.nativeHostModule}-${buildMode}${constants.APK_EXTENSION_NAME}`, ], regexes: [ new RegExp( - `(${packageName}|${constants.APP_FOLDER_NAME})-.*-(${Configurations.Debug}|${Configurations.Release})(-unsigned)?${constants.APK_EXTENSION_NAME}`, + `(${packageName}|${this.$options.nativeHostModule})-.*-(${Configurations.Debug}|${Configurations.Release})(-unsigned)?${constants.APK_EXTENSION_NAME}`, "i" ), ], @@ -570,7 +570,7 @@ export class AndroidProjectService extends projectServiceBaseLib.PlatformProject return this.$fs.exists( path.join( this.getPlatformData(projectData).appDestinationDirectoryPath, - constants.APP_FOLDER_NAME + this.$options.nativeHostModule ) ); } @@ -879,7 +879,7 @@ export class AndroidProjectService extends projectServiceBaseLib.PlatformProject projectData: IProjectData ): string { const resourcePath: string[] = [ - constants.APP_FOLDER_NAME, + this.$options.nativeHostModule, constants.SRC_DIR, constants.MAIN_DIR, constants.RESOURCES_DIR, @@ -895,7 +895,7 @@ export class AndroidProjectService extends projectServiceBaseLib.PlatformProject projectData: IProjectData ): string { const resourcePath: string[] = [ - constants.APP_FOLDER_NAME, + this.$options.nativeHostModule, constants.SRC_DIR, ]; diff --git a/lib/services/files-hash-service.ts b/lib/services/files-hash-service.ts index a29881f227..50758e4533 100644 --- a/lib/services/files-hash-service.ts +++ b/lib/services/files-hash-service.ts @@ -1,15 +1,20 @@ import { executeActionByChunks } from "../common/helpers"; import { DEFAULT_CHUNK_SIZE } from "../common/constants"; -import { APP_FOLDER_NAME, HASHES_FILE_NAME } from "../constants"; +import { HASHES_FILE_NAME } from "../constants"; import * as path from "path"; import * as _ from "lodash"; import { IFilesHashService } from "../definitions/files-hash-service"; import { IPlatformData } from "../definitions/platform"; import { IFileSystem, IStringDictionary } from "../common/declarations"; import { injector } from "../common/yok"; +import { IOptions } from "../declarations"; export class FilesHashService implements IFilesHashService { - constructor(private $fs: IFileSystem, private $logger: ILogger) {} + constructor( + private $fs: IFileSystem, + private $logger: ILogger, + private $options: IOptions + ) {} public async generateHashes(files: string[]): Promise { const result: IStringDictionary = {}; @@ -37,7 +42,7 @@ export class FilesHashService implements IFilesHashService { ): Promise { const appFilesPath = path.join( platformData.appDestinationDirectoryPath, - APP_FOLDER_NAME + this.$options.nativeHostModule ); const files = this.$fs.enumerateFilesInDirectorySync(appFilesPath); const hashes = await this.generateHashes(files); diff --git a/lib/services/livesync/android-device-livesync-sockets-service.ts b/lib/services/livesync/android-device-livesync-sockets-service.ts index 14dc23693a..037145b05a 100644 --- a/lib/services/livesync/android-device-livesync-sockets-service.ts +++ b/lib/services/livesync/android-device-livesync-sockets-service.ts @@ -1,5 +1,4 @@ import { AndroidDeviceLiveSyncServiceBase } from "./android-device-livesync-service-base"; -import { APP_FOLDER_NAME } from "../../constants"; import { LiveSyncPaths } from "../../common/constants"; import { AndroidLivesyncTool } from "./android-livesync-tool"; import * as path from "path"; @@ -19,7 +18,8 @@ export class AndroidDeviceSocketsLiveSyncService extends AndroidDeviceLiveSyncServiceBase implements IAndroidNativeScriptDeviceLiveSyncService, - INativeScriptDeviceLiveSyncService { + INativeScriptDeviceLiveSyncService +{ private livesyncTool: IAndroidLivesyncTool; private static STATUS_UPDATE_INTERVAL = 10000; private static MINIMAL_VERSION_LONG_LIVING_CONNECTION = "0.2.0"; @@ -279,7 +279,7 @@ export class AndroidDeviceSocketsLiveSyncService ); const projectFilesPath = path.join( platformData.appDestinationDirectoryPath, - APP_FOLDER_NAME + this.$options.nativeHostModule ); if (!this.livesyncTool.hasConnection()) { await this.livesyncTool.connect({ diff --git a/lib/services/livesync/android-livesync-service.ts b/lib/services/livesync/android-livesync-service.ts index 366c121cb0..8ff185ca0d 100644 --- a/lib/services/livesync/android-livesync-service.ts +++ b/lib/services/livesync/android-livesync-service.ts @@ -13,10 +13,12 @@ import { } from "../../common/declarations"; import { IInjector } from "../../common/definitions/yok"; import { injector } from "../../common/yok"; +import { IOptions } from "../../declarations"; export class AndroidLiveSyncService extends PlatformLiveSyncServiceBase - implements IPlatformLiveSyncService { + implements IPlatformLiveSyncService +{ private static MIN_SOCKETS_LIVESYNC_RUNTIME_VERSION = "4.2.0-2018-07-20-02"; constructor( protected $platformsDataService: IPlatformsDataService, @@ -24,14 +26,16 @@ export class AndroidLiveSyncService private $injector: IInjector, $devicePathProvider: IDevicePathProvider, $fs: IFileSystem, - $logger: ILogger + $logger: ILogger, + $options: IOptions ) { super( $fs, $logger, $platformsDataService, $projectFilesManager, - $devicePathProvider + $devicePathProvider, + $options ); } diff --git a/lib/services/livesync/ios-livesync-service.ts b/lib/services/livesync/ios-livesync-service.ts index 6ea6b6e2e1..2ead95e8ac 100644 --- a/lib/services/livesync/ios-livesync-service.ts +++ b/lib/services/livesync/ios-livesync-service.ts @@ -13,10 +13,12 @@ import { import { IInjector } from "../../common/definitions/yok"; import { injector } from "../../common/yok"; import { ITempService } from "../../definitions/temp-service"; +import { IOptions } from "../../declarations"; export class IOSLiveSyncService extends PlatformLiveSyncServiceBase - implements IPlatformLiveSyncService { + implements IPlatformLiveSyncService +{ constructor( protected $fs: IFileSystem, protected $platformsDataService: IPlatformsDataService, @@ -24,14 +26,16 @@ export class IOSLiveSyncService private $injector: IInjector, private $tempService: ITempService, $devicePathProvider: IDevicePathProvider, - $logger: ILogger + $logger: ILogger, + $options: IOptions ) { super( $fs, $logger, $platformsDataService, $projectFilesManager, - $devicePathProvider + $devicePathProvider, + $options ); } @@ -59,9 +63,8 @@ export class IOSLiveSyncService }); this.$logger.trace("Creating zip file: " + tempZip); - const filesToTransfer = this.$fs.enumerateFilesInDirectorySync( - projectFilesPath - ); + const filesToTransfer = + this.$fs.enumerateFilesInDirectorySync(projectFilesPath); await this.$fs.zipFiles(tempZip, filesToTransfer, (res) => { return path.join(APP_FOLDER_NAME, path.relative(projectFilesPath, res)); diff --git a/lib/services/livesync/platform-livesync-service-base.ts b/lib/services/livesync/platform-livesync-service-base.ts index 099334c0df..37293cf7ba 100644 --- a/lib/services/livesync/platform-livesync-service-base.ts +++ b/lib/services/livesync/platform-livesync-service-base.ts @@ -12,18 +12,19 @@ import { IProjectFilesManager, } from "../../common/declarations"; import { color } from "../../color"; +import { IOptions } from "../../declarations"; export abstract class PlatformLiveSyncServiceBase { - private _deviceLiveSyncServicesCache: IDictionary< - INativeScriptDeviceLiveSyncService - > = {}; + private _deviceLiveSyncServicesCache: IDictionary = + {}; constructor( protected $fs: IFileSystem, protected $logger: ILogger, protected $platformsDataService: IPlatformsDataService, protected $projectFilesManager: IProjectFilesManager, - private $devicePathProvider: IDevicePathProvider + private $devicePathProvider: IDevicePathProvider, + private $options: IOptions ) {} public getDeviceLiveSyncService( @@ -35,9 +36,8 @@ export abstract class PlatformLiveSyncServiceBase { device.deviceInfo.platform, projectData ); - const frameworkVersion = platformData.platformProjectService.getFrameworkVersion( - projectData - ); + const frameworkVersion = + platformData.platformProjectService.getFrameworkVersion(projectData); const key = getHash( `${device.deviceInfo.identifier}${projectData.projectIdentifiers[platform]}${projectData.projectDir}${frameworkVersion}` ); @@ -135,14 +135,15 @@ export abstract class PlatformLiveSyncServiceBase { const projectFilesPath = path.join( platformData.appDestinationDirectoryPath, - APP_FOLDER_NAME - ); - const localToDevicePaths = await this.$projectFilesManager.createLocalToDevicePaths( - deviceAppData, - projectFilesPath, - null, - [] + this.$options.nativeHostModule ); + const localToDevicePaths = + await this.$projectFilesManager.createLocalToDevicePaths( + deviceAppData, + projectFilesPath, + null, + [] + ); const modifiedFilesData = await this.transferFiles( deviceAppData, localToDevicePaths, @@ -200,14 +201,15 @@ export abstract class PlatformLiveSyncServiceBase { ); const projectFilesPath = path.join( platformData.appDestinationDirectoryPath, - APP_FOLDER_NAME - ); - const localToDevicePaths = await this.$projectFilesManager.createLocalToDevicePaths( - deviceAppData, - projectFilesPath, - existingFiles, - [] + this.$options.nativeHostModule ); + const localToDevicePaths = + await this.$projectFilesManager.createLocalToDevicePaths( + deviceAppData, + projectFilesPath, + existingFiles, + [] + ); modifiedLocalToDevicePaths.push(...localToDevicePaths); modifiedLocalToDevicePaths = await this.transferFiles( deviceAppData, @@ -235,12 +237,13 @@ export abstract class PlatformLiveSyncServiceBase { platformData.appDestinationDirectoryPath, APP_FOLDER_NAME ); - const localToDevicePaths = await this.$projectFilesManager.createLocalToDevicePaths( - deviceAppData, - projectFilesPath, - mappedFiles, - [] - ); + const localToDevicePaths = + await this.$projectFilesManager.createLocalToDevicePaths( + deviceAppData, + projectFilesPath, + mappedFiles, + [] + ); modifiedLocalToDevicePaths.push(...localToDevicePaths); await deviceLiveSyncService.removeFiles( diff --git a/lib/services/log-source-map-service.ts b/lib/services/log-source-map-service.ts index ebac80ed5e..df119c398d 100644 --- a/lib/services/log-source-map-service.ts +++ b/lib/services/log-source-map-service.ts @@ -20,6 +20,7 @@ import { } from "../common/declarations"; import { IInjector } from "../common/definitions/yok"; import { injector } from "../common/yok"; +import { IOptions } from "../declarations"; interface IParsedMessage { filePath?: string; @@ -53,6 +54,7 @@ export class LogSourceMapService implements Mobile.ILogSourceMapService { private $fs: IFileSystem, private $projectDataService: IProjectDataService, private $injector: IInjector, + private $options: IOptions, private $devicePlatformsConstants: Mobile.IDevicePlatformsConstants, private $logger: ILogger ) { @@ -200,7 +202,7 @@ export class LogSourceMapService implements Mobile.ILogSourceMapService { ): IFileLocation { const fileLocation = path.join( this.getFilesLocation(platform, projectData), - APP_FOLDER_NAME + this.$options.nativeHostModule ); if (parsedLine && parsedLine.filePath) { diff --git a/lib/services/plugins-service.ts b/lib/services/plugins-service.ts index b1dc3a5a63..e8defc5178 100644 --- a/lib/services/plugins-service.ts +++ b/lib/services/plugins-service.ts @@ -803,7 +803,7 @@ This framework comes from ${dependencyName} plugin, which is installed multiple ); const pluginDestinationPath = path.join( platformData.appDestinationDirectoryPath, - constants.APP_FOLDER_NAME, + this.$options.nativeHostModule, "tns_modules" ); await action( @@ -876,6 +876,9 @@ This framework comes from ${dependencyName} plugin, which is installed multiple private getAllPluginsNativeHashes( pathToPluginsBuildFile: string ): IDictionary { + if (this.$options.nativeHost) { + return {}; // TODO: force rebuild plugins for now until we decide where to put .ns-plugins-build-data.json when embedding + } let data: IDictionary = {}; if (this.$fs.exists(pathToPluginsBuildFile)) { data = this.$fs.readJson(pathToPluginsBuildFile); @@ -890,6 +893,10 @@ This framework comes from ${dependencyName} plugin, which is installed multiple currentPluginNativeHashes: IStringDictionary; allPluginsNativeHashes: IDictionary; }): void { + if (this.$options.nativeHost) { + return; // TODO: force rebuild plugins for now until we decide where to put .ns-plugins-build-data.json when embedding + } + opts.allPluginsNativeHashes[opts.pluginData.name] = opts.currentPluginNativeHashes; this.$fs.writeJson( diff --git a/lib/services/project-changes-service.ts b/lib/services/project-changes-service.ts index 5ffa09c3bf..10ada01108 100644 --- a/lib/services/project-changes-service.ts +++ b/lib/services/project-changes-service.ts @@ -23,6 +23,7 @@ import { } from "../definitions/project-changes"; import * as _ from "lodash"; import { injector } from "../common/yok"; +import { IOptions } from "../declarations"; const prepareInfoFileName = ".nsprepareinfo"; @@ -62,6 +63,7 @@ export class ProjectChangesService implements IProjectChangesService { private $devicePlatformsConstants: Mobile.IDevicePlatformsConstants, private $fs: IFileSystem, private $logger: ILogger, + private $options: IOptions, public $hooksService: IHooksService, private $nodeModulesDependenciesBuilder: INodeModulesDependenciesBuilder ) {} @@ -235,6 +237,10 @@ export class ProjectChangesService implements IProjectChangesService { } public getPrepareInfo(platformData: IPlatformData): IPrepareInfo { + if (this.$options.nativeHost) { + return null; // TODO: always prepare for now until we decide where to keep the .nsprepareinfo file when embedding + } + const prepareInfoFilePath = this.getPrepareInfoFilePath(platformData); let prepareInfo: IPrepareInfo = null; if (this.$fs.exists(prepareInfoFilePath)) { @@ -257,6 +263,10 @@ export class ProjectChangesService implements IProjectChangesService { await this.ensurePrepareInfo(platformData, projectData, prepareData); } + if (this.$options.nativeHost) { + return null; // TODO: do not save for now until we decide where to keep the .nsprepareinfo file when embedding + } + const prepareInfoFilePath = this.getPrepareInfoFilePath(platformData); this.$fs.writeJson(prepareInfoFilePath, this._prepareInfo); } diff --git a/lib/services/webpack/webpack-compiler-service.ts b/lib/services/webpack/webpack-compiler-service.ts index 4db73fa408..b528db2867 100644 --- a/lib/services/webpack/webpack-compiler-service.ts +++ b/lib/services/webpack/webpack-compiler-service.ts @@ -163,10 +163,18 @@ export class WebpackCompilerService }; } const files = result.emittedFiles.map((file: string) => - path.join(platformData.appDestinationDirectoryPath, "app", file) + path.join( + platformData.appDestinationDirectoryPath, + this.$options.nativeHostModule, + file + ) ); const fallbackFiles = result.fallbackFiles.map((file: string) => - path.join(platformData.appDestinationDirectoryPath, "app", file) + path.join( + platformData.appDestinationDirectoryPath, + this.$options.nativeHostModule, + file + ) ); const data = { @@ -350,6 +358,7 @@ export class WebpackCompilerService if (this.$options.nativeHost) { options.env = { USER_PROJECT_PLATFORMS_ANDROID: this.$options.nativeHost, + USER_PROJECT_PLATFORMS_ANDROID_MODULE: this.$options.nativeHostModule, USER_PROJECT_PLATFORMS_IOS: this.$options.nativeHost, }; } @@ -568,10 +577,18 @@ export class WebpackCompilerService this.$logger.trace("Webpack build done!"); const files = message.data.emittedAssets.map((asset: string) => - path.join(platformData.appDestinationDirectoryPath, "app", asset) + path.join( + platformData.appDestinationDirectoryPath, + this.$options.nativeHostModule, + asset + ) ); const staleFiles = message.data.staleAssets.map((asset: string) => - path.join(platformData.appDestinationDirectoryPath, "app", asset) + path.join( + platformData.appDestinationDirectoryPath, + this.$options.nativeHostModule, + asset + ) ); // extract last hash from emitted filenames diff --git a/package-lock.json b/package-lock.json index 84bb5f1aea..bed3716113 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1728,6 +1728,15 @@ "node": ">=14" } }, + "node_modules/@pkgjs/parseargs": { + "version": "0.11.0", + "resolved": "https://registry.npmjs.org/@pkgjs/parseargs/-/parseargs-0.11.0.tgz", + "integrity": "sha512-+1VkjdD0QBLPodGrJUeqarH8VAIvQODIbwh9XpP5Syisf7YoQgsJKPNFoqqLQlu+VQ/tVSshMR6loPMn8U+dPg==", + "optional": true, + "engines": { + "node": ">=14" + } + }, "node_modules/@prettier/plugin-xml": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/@prettier/plugin-xml/-/plugin-xml-2.2.0.tgz", @@ -2427,6 +2436,20 @@ "form-data": "^4.0.0" } }, + "node_modules/@types/node-fetch/node_modules/form-data": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-3.0.1.tgz", + "integrity": "sha512-RHkBKtLWUVwd7SqRIvCZMEvAMoGUp0XU+seQiZejj0COz3RI3hWP4sCv3gZWWLjJTd7rGwcsF5eKZGii0r/hbg==", + "dev": true, + "dependencies": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.8", + "mime-types": "^2.1.12" + }, + "engines": { + "node": ">= 6" + } + }, "node_modules/@types/normalize-package-data": { "version": "2.4.4", "resolved": "https://registry.npmjs.org/@types/normalize-package-data/-/normalize-package-data-2.4.4.tgz", @@ -9258,6 +9281,11 @@ "integrity": "sha512-xyFwyhro/JEof6Ghe2iz2NcXoj2sloNsWr/XsERDK/oiPCfaNhl5ONfp+jQdAZRQQ0IJWNzH9zIZF7li91kh2w==", "license": "MIT" }, + "node_modules/meow/node_modules/json-parse-even-better-errors": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/json-parse-even-better-errors/-/json-parse-even-better-errors-2.3.1.tgz", + "integrity": "sha512-xyFwyhro/JEof6Ghe2iz2NcXoj2sloNsWr/XsERDK/oiPCfaNhl5ONfp+jQdAZRQQ0IJWNzH9zIZF7li91kh2w==" + }, "node_modules/meow/node_modules/locate-path": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz",