nativescript 9.0.0-alpha.0 → 9.0.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/.d.ts +3 -3
- package/lib/bootstrap.js +1 -1
- package/lib/common/services/hooks-service.js +22 -5
- package/lib/constants.js +6 -4
- package/lib/controllers/prepare-controller.js +9 -9
- package/lib/definitions/project.d.ts +19 -1
- package/lib/project-data.js +10 -4
- package/lib/services/{webpack/webpack-compiler-service.js → bundler/bundler-compiler-service.js} +130 -75
- package/lib/services/bundler/bundler.js +2 -0
- package/package.json +1 -1
- package/lib/services/webpack/webpack.d.ts +0 -226
package/lib/.d.ts
CHANGED
|
@@ -344,6 +344,8 @@
|
|
|
344
344
|
/// <reference path="services/build-artifacts-service.ts" />
|
|
345
345
|
/// <reference path="services/build-data-service.ts" />
|
|
346
346
|
/// <reference path="services/build-info-file-service.ts" />
|
|
347
|
+
/// <reference path="services/bundler/bundler-compiler-service.ts" />
|
|
348
|
+
/// <reference path="services/bundler/bundler.ts" />
|
|
347
349
|
/// <reference path="services/cleanup-service.ts" />
|
|
348
350
|
/// <reference path="services/cocoapods-platform-manager.ts" />
|
|
349
351
|
/// <reference path="services/cocoapods-service.ts" />
|
|
@@ -419,8 +421,6 @@
|
|
|
419
421
|
/// <reference path="services/user-settings-service.ts" />
|
|
420
422
|
/// <reference path="services/versions-service.ts" />
|
|
421
423
|
/// <reference path="services/watch-ignore-list-service.ts" />
|
|
422
|
-
/// <reference path="services/webpack/webpack-compiler-service.ts" />
|
|
423
|
-
/// <reference path="services/webpack/webpack.d.ts" />
|
|
424
424
|
/// <reference path="services/xcconfig-service.ts" />
|
|
425
425
|
/// <reference path="services/xcproj-service.ts" />
|
|
426
426
|
/// <reference path="shared-event-bus.ts" />
|
|
@@ -465,6 +465,7 @@
|
|
|
465
465
|
/// <reference path="../test/services/android-plugin-build-service.ts" />
|
|
466
466
|
/// <reference path="../test/services/android-project-service.ts" />
|
|
467
467
|
/// <reference path="../test/services/android/gradle-build-args-service.ts" />
|
|
468
|
+
/// <reference path="../test/services/bundler/bundler-compiler-service.ts" />
|
|
468
469
|
/// <reference path="../test/services/doctor-service.ts" />
|
|
469
470
|
/// <reference path="../test/services/extensibility-service.ts" />
|
|
470
471
|
/// <reference path="../test/services/ios-debugger-port-service.ts" />
|
|
@@ -487,7 +488,6 @@
|
|
|
487
488
|
/// <reference path="../test/services/project-data-service.ts" />
|
|
488
489
|
/// <reference path="../test/services/test-execution-service.ts" />
|
|
489
490
|
/// <reference path="../test/services/user-settings-service.ts" />
|
|
490
|
-
/// <reference path="../test/services/webpack/webpack-compiler-service.ts" />
|
|
491
491
|
/// <reference path="../test/stubs.ts" />
|
|
492
492
|
/// <reference path="../test/sys-info.ts" />
|
|
493
493
|
/// <reference path="../test/test-bootstrap.ts" />
|
package/lib/bootstrap.js
CHANGED
|
@@ -185,7 +185,7 @@ yok_1.injector.require("qrCodeTerminalService", "./services/qr-code-terminal-ser
|
|
|
185
185
|
yok_1.injector.require("testInitializationService", "./services/test-initialization-service");
|
|
186
186
|
yok_1.injector.require("networkConnectivityValidator", "./helpers/network-connectivity-validator");
|
|
187
187
|
yok_1.injector.requirePublic("cleanupService", "./services/cleanup-service");
|
|
188
|
-
yok_1.injector.require("
|
|
188
|
+
yok_1.injector.require("bundlerCompilerService", "./services/bundler/bundler-compiler-service");
|
|
189
189
|
yok_1.injector.require("applePortalSessionService", "./services/apple-portal/apple-portal-session-service");
|
|
190
190
|
yok_1.injector.require("applePortalCookieService", "./services/apple-portal/apple-portal-cookie-service");
|
|
191
191
|
yok_1.injector.require("applePortalApplicationService", "./services/apple-portal/apple-portal-application-service");
|
|
@@ -93,24 +93,38 @@ class HooksService {
|
|
|
93
93
|
}
|
|
94
94
|
return _.flatten(results);
|
|
95
95
|
}
|
|
96
|
+
isESModule(hook) {
|
|
97
|
+
const ext = path.extname(hook.fullPath).toLowerCase();
|
|
98
|
+
return ext === ".mjs";
|
|
99
|
+
}
|
|
96
100
|
async executeHook(directoryPath, hookName, hook, hookArguments) {
|
|
97
101
|
hookArguments = hookArguments || {};
|
|
98
102
|
let result;
|
|
99
103
|
const relativePath = path.relative(directoryPath, hook.fullPath);
|
|
100
104
|
const trackId = relativePath.replace(new RegExp("\\" + path.sep, "g"), constants_1.AnalyticsEventLabelDelimiter);
|
|
105
|
+
const isESM = this.isESModule(hook);
|
|
101
106
|
let command = this.getSheBangInterpreter(hook);
|
|
102
107
|
let inProc = false;
|
|
103
108
|
if (!command) {
|
|
104
109
|
command = hook.fullPath;
|
|
105
110
|
if ([".mjs", ".js"].includes(path.extname(hook.fullPath).toLowerCase())) {
|
|
106
111
|
command = process.argv[0];
|
|
107
|
-
inProc =
|
|
112
|
+
inProc = isESM
|
|
113
|
+
? true
|
|
114
|
+
: this.shouldExecuteInProcess(this.$fs.readText(hook.fullPath));
|
|
108
115
|
}
|
|
109
116
|
}
|
|
110
117
|
const startTime = this.$performanceService.now();
|
|
111
118
|
if (inProc) {
|
|
112
119
|
this.$logger.trace("Executing %s hook at location %s in-process", hookName, hook.fullPath);
|
|
113
|
-
|
|
120
|
+
let hookEntryPoint;
|
|
121
|
+
if (isESM) {
|
|
122
|
+
const { default: hookFn } = await Promise.resolve(`${hook.fullPath}`).then(s => require(s));
|
|
123
|
+
hookEntryPoint = hookFn;
|
|
124
|
+
}
|
|
125
|
+
else {
|
|
126
|
+
hookEntryPoint = require(hook.fullPath);
|
|
127
|
+
}
|
|
114
128
|
this.$logger.trace(`Validating ${hookName} arguments.`);
|
|
115
129
|
const invalidArguments = this.validateHookArguments(hookEntryPoint, hook.fullPath);
|
|
116
130
|
if (invalidArguments.length) {
|
|
@@ -119,7 +133,8 @@ class HooksService {
|
|
|
119
133
|
}
|
|
120
134
|
const projectDataHookArg = hookArguments["hookArgs"] && hookArguments["hookArgs"]["projectData"];
|
|
121
135
|
if (projectDataHookArg) {
|
|
122
|
-
hookArguments["projectData"] = hookArguments["$projectData"] =
|
|
136
|
+
hookArguments["projectData"] = hookArguments["$projectData"] =
|
|
137
|
+
projectDataHookArg;
|
|
123
138
|
}
|
|
124
139
|
const maybePromise = this.$injector.resolve(hookEntryPoint, hookArguments);
|
|
125
140
|
if (maybePromise) {
|
|
@@ -215,9 +230,11 @@ class HooksService {
|
|
|
215
230
|
prepareEnvironment(hookFullPath) {
|
|
216
231
|
const clientName = this.$staticConfig.CLIENT_NAME.toUpperCase();
|
|
217
232
|
const environment = {};
|
|
218
|
-
environment[util.format("%s-COMMANDLINE", clientName)] =
|
|
233
|
+
environment[util.format("%s-COMMANDLINE", clientName)] =
|
|
234
|
+
process.argv.join(" ");
|
|
219
235
|
environment[util.format("%s-HOOK_FULL_PATH", clientName)] = hookFullPath;
|
|
220
|
-
environment[util.format("%s-VERSION", clientName)] =
|
|
236
|
+
environment[util.format("%s-VERSION", clientName)] =
|
|
237
|
+
this.$staticConfig.version;
|
|
221
238
|
return {
|
|
222
239
|
cwd: this.$projectHelper.projectDir,
|
|
223
240
|
stdio: "inherit",
|
package/lib/constants.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
exports.
|
|
5
|
-
exports.PackageManagers = exports.EMIT_APPENDER_EVENT_NAME = exports.LoggerConfigData = exports.LoggerLevel = exports.DeviceConnectionType = exports.LoggerAppenders = exports.IOSNativeTargetTypes = exports.IOSNativeTargetProductTypes = exports.IOSDeviceTargets = exports.RunOnDeviceEvents = exports.AndroidAppBundleMessages = exports.AndroidBundleValidatorMessages = exports.BundleValidatorMessages = exports.IosProjectConstants = exports.EXTENSION_PROVISIONING_FILENAME = exports.PODFILE_NAME = exports.PLUGINS_BUILD_DATA_FILENAME = exports.PLUGIN_BUILD_DATA_FILENAME = exports.AddPlaformErrors = exports.PACKAGE_PLACEHOLDER_NAME = exports.AndroidBuildDefaults = exports.Hooks = exports.XcodeDeprecationStringFormat = exports.MacOSDeprecationStringFormat = exports.MacOSVersions = exports.AssetConstants = exports.CLI_RESOURCES_DIR_NAME = exports.NATIVESCRIPT_PROPS_INTERNAL_DELIMITER = exports.AnalyticsEventLabelDelimiter = exports.DebugCommandErrors = exports.
|
|
3
|
+
exports.BUILD_XCCONFIG_FILE_NAME = exports.INCLUDE_GRADLE_NAME = exports.INFO_PLIST_FILE_NAME = exports.APP_GRADLE_FILE_NAME = exports.MANIFEST_FILE_NAME = exports.ANDROID_ANALYTICS_DATA_FILE = exports.ANDROID_ANALYTICS_DATA_DIR = exports.FONTS_DIR = exports.ASSETS_DIR = exports.MAIN_DIR = exports.SRC_DIR = exports.AWAIT_NOTIFICATION_TIMEOUT_SECONDS = exports.CODE_SIGN_ENTITLEMENTS = exports.LIB_DIR_NAME = exports.KARMA_CONFIG_NAME = exports.TSCCONFIG_TNS_JSON_NAME = exports.RSPACK_CONFIG_NAME = exports.WEBPACK_CONFIG_NAME = exports.HOOKS_DIR_NAME = exports.PLATFORMS_DIR_NAME = exports.XML_FILE_EXTENSION = exports.LIVESYNC_EXCLUDED_FILE_PATTERNS = exports.TEST_RUNNER_NAME = exports.TESTING_FRAMEWORKS = exports.LIVESYNC_EXCLUDED_DIRECTORIES = exports.DEFAULT_APP_IDENTIFIER_PREFIX = exports.NODE_MODULE_CACHE_PATH_KEY_NAME = exports.ANDROID_DEVICE_APP_ROOT_TEMPLATE = exports.PACKAGE_LOCK_JSON_FILE_NAME = exports.PACKAGE_JSON_FILE_NAME = exports.SCOPED_VISIONOS_RUNTIME_NAME = exports.SCOPED_IOS_RUNTIME_NAME = exports.SCOPED_ANDROID_RUNTIME_NAME = exports.TNS_IOS_RUNTIME_NAME = exports.TNS_ANDROID_RUNTIME_NAME = exports.UI_MOBILE_BASE_NAME = exports.TNS_CORE_MODULES_WIDGETS_NAME = exports.RSPACK_PLUGIN_NAME = exports.WEBPACK_PLUGIN_NAME = exports.SCOPED_TNS_CORE_THEME_NAME = exports.TNS_CORE_THEME_NAME = exports.SCOPED_TNS_CORE_MODULES = exports.TNS_CORE_MODULES_NAME = exports.TNS_MODULES_FOLDER_NAME = exports.NODE_MODULES_FOLDER_NAME = exports.NATIVESCRIPT_KEY_NAME = exports.NS_BASE_PODFILE = exports.PROJECT_FRAMEWORK_FOLDER_NAME = exports.APP_RESOURCES_FOLDER_NAME = exports.APP_FOLDER_NAME = void 0;
|
|
4
|
+
exports.ProjectTypes = exports.JsFlavorName = exports.TsFlavorName = exports.SvelteFlavorName = exports.SolidFlavorName = exports.ReactFlavorName = exports.VueFlavorName = exports.NgFlavorName = exports.SVELTE_NAME = exports.SOLID_NAME = exports.REACT_NAME = exports.TYPESCRIPT_NAME = exports.JAVASCRIPT_NAME = exports.ANGULAR_NAME = exports.VUE_NAME = exports.ItunesConnectApplicationTypes = exports.androidAppResourcesFolderName = exports.iOSAppResourcesFolderName = exports.ITMSConstants = exports.ANALYTICS_LOCAL_TEMPLATE_PREFIX = exports.RESERVED_TEMPLATE_NAMES = exports.ReleaseType = exports.SaveOptions = exports.TemplatesV2PackageJsonKeysToRemove = exports.PackageJsonKeysToKeep = exports.LiveSyncTrackActionNames = exports.PackageVersion = exports.MetadataFilteringConstants = exports.IOS_WATCHAPP_EXTENSION_FOLDER = exports.IOS_WATCHAPP_FOLDER = exports.NATIVE_EXTENSION_FOLDER = exports.APPLICATION_RESPONSE_TIMEOUT_SECONDS = exports.NATIVE_SOURCE_FOLDER = exports.TNS_NATIVE_SOURCE_GROUP_NAME = exports.HASHES_FILE_NAME = exports.APKS_EXTENSION_NAME = exports.AAB_EXTENSION_NAME = exports.APK_EXTENSION_NAME = exports.DEPENDENCIES_JSON_NAME = exports.CONFIG_FILE_NAME_TS = exports.CONFIG_FILE_NAME_JS = exports.CONFIG_FILE_NAME_DISPLAY = exports.CONFIG_NS_APP_ENTRY = exports.CONFIG_NS_APP_RESOURCES_ENTRY = exports.CONFIG_NS_FILE_NAME = exports.RESOURCES_DIR = exports.BUNDLE_DIR = exports.APK_DIR = exports.OUTPUTS_DIR = exports.BUILD_DIR = void 0;
|
|
5
|
+
exports.PackageManagers = exports.EMIT_APPENDER_EVENT_NAME = exports.LoggerConfigData = exports.LoggerLevel = exports.DeviceConnectionType = exports.LoggerAppenders = exports.IOSNativeTargetTypes = exports.IOSNativeTargetProductTypes = exports.IOSDeviceTargets = exports.RunOnDeviceEvents = exports.AndroidAppBundleMessages = exports.AndroidBundleValidatorMessages = exports.BundleValidatorMessages = exports.IosProjectConstants = exports.EXTENSION_PROVISIONING_FILENAME = exports.PODFILE_NAME = exports.PLUGINS_BUILD_DATA_FILENAME = exports.PLUGIN_BUILD_DATA_FILENAME = exports.AddPlaformErrors = exports.PACKAGE_PLACEHOLDER_NAME = exports.AndroidBuildDefaults = exports.Hooks = exports.XcodeDeprecationStringFormat = exports.MacOSDeprecationStringFormat = exports.MacOSVersions = exports.AssetConstants = exports.CLI_RESOURCES_DIR_NAME = exports.NATIVESCRIPT_PROPS_INTERNAL_DELIMITER = exports.AnalyticsEventLabelDelimiter = exports.DebugCommandErrors = exports.BUNDLER_COMPILATION_COMPLETE = exports.PREPARE_READY_EVENT_NAME = exports.INITIAL_SYNC_EVENT_NAME = exports.FILES_CHANGE_EVENT_NAME = exports.CACACHE_DIRECTORY_NAME = exports.ANDROID_APP_BUNDLE_SIGNING_ERROR_MESSAGE = exports.ANDROID_RELEASE_BUILD_ERROR_MESSAGE = exports.POST_INSTALL_COMMAND_NAME = exports.INSPECTOR_CACHE_DIRNAME = exports.VERSION_STRING = exports.DEBUGGER_DETACHED_EVENT_NAME = exports.DEBUGGER_ATTACHED_EVENT_NAME = exports.USER_INTERACTION_NEEDED_EVENT_NAME = exports.CONNECTION_ERROR_EVENT_NAME = exports.BUILD_OUTPUT_EVENT_NAME = void 0;
|
|
6
6
|
const path_1 = require("path");
|
|
7
7
|
exports.APP_FOLDER_NAME = "app";
|
|
8
8
|
exports.APP_RESOURCES_FOLDER_NAME = "App_Resources";
|
|
@@ -16,6 +16,7 @@ exports.SCOPED_TNS_CORE_MODULES = "@nativescript/core";
|
|
|
16
16
|
exports.TNS_CORE_THEME_NAME = "nativescript-theme-core";
|
|
17
17
|
exports.SCOPED_TNS_CORE_THEME_NAME = "@nativescript/theme";
|
|
18
18
|
exports.WEBPACK_PLUGIN_NAME = "@nativescript/webpack";
|
|
19
|
+
exports.RSPACK_PLUGIN_NAME = "@nativescript/rspack";
|
|
19
20
|
exports.TNS_CORE_MODULES_WIDGETS_NAME = "tns-core-modules-widgets";
|
|
20
21
|
exports.UI_MOBILE_BASE_NAME = "@nativescript/ui-mobile-base";
|
|
21
22
|
exports.TNS_ANDROID_RUNTIME_NAME = "tns-android";
|
|
@@ -36,6 +37,7 @@ exports.XML_FILE_EXTENSION = ".xml";
|
|
|
36
37
|
exports.PLATFORMS_DIR_NAME = "platforms";
|
|
37
38
|
exports.HOOKS_DIR_NAME = "hooks";
|
|
38
39
|
exports.WEBPACK_CONFIG_NAME = "webpack.config.js";
|
|
40
|
+
exports.RSPACK_CONFIG_NAME = "rspack.config.js";
|
|
39
41
|
exports.TSCCONFIG_TNS_JSON_NAME = "tsconfig.tns.json";
|
|
40
42
|
exports.KARMA_CONFIG_NAME = "karma.conf.js";
|
|
41
43
|
exports.LIB_DIR_NAME = "lib";
|
|
@@ -214,7 +216,7 @@ exports.CACACHE_DIRECTORY_NAME = "_cacache";
|
|
|
214
216
|
exports.FILES_CHANGE_EVENT_NAME = "filesChangeEvent";
|
|
215
217
|
exports.INITIAL_SYNC_EVENT_NAME = "initialSyncEvent";
|
|
216
218
|
exports.PREPARE_READY_EVENT_NAME = "prepareReadyEvent";
|
|
217
|
-
exports.
|
|
219
|
+
exports.BUNDLER_COMPILATION_COMPLETE = "bundlerCompilationComplete";
|
|
218
220
|
class DebugCommandErrors {
|
|
219
221
|
}
|
|
220
222
|
exports.DebugCommandErrors = DebugCommandErrors;
|
|
@@ -16,7 +16,7 @@ const helpers_1 = require("../common/helpers");
|
|
|
16
16
|
const yok_1 = require("../common/yok");
|
|
17
17
|
const constants_1 = require("../constants");
|
|
18
18
|
class PrepareController extends events_1.EventEmitter {
|
|
19
|
-
constructor($platformController, $hooksService, $fs, $logger, $options, $mobileHelper, $nodeModulesDependenciesBuilder, $platformsDataService, $pluginsService, $prepareNativePlatformService, $projectChangesService, $projectDataService, $
|
|
19
|
+
constructor($platformController, $hooksService, $fs, $logger, $options, $mobileHelper, $nodeModulesDependenciesBuilder, $platformsDataService, $pluginsService, $prepareNativePlatformService, $projectChangesService, $projectDataService, $bundlerCompilerService, $watchIgnoreListService, $analyticsService, $markingModeService, $projectConfigService, $projectService) {
|
|
20
20
|
super();
|
|
21
21
|
this.$platformController = $platformController;
|
|
22
22
|
this.$hooksService = $hooksService;
|
|
@@ -30,7 +30,7 @@ class PrepareController extends events_1.EventEmitter {
|
|
|
30
30
|
this.$prepareNativePlatformService = $prepareNativePlatformService;
|
|
31
31
|
this.$projectChangesService = $projectChangesService;
|
|
32
32
|
this.$projectDataService = $projectDataService;
|
|
33
|
-
this.$
|
|
33
|
+
this.$bundlerCompilerService = $bundlerCompilerService;
|
|
34
34
|
this.$watchIgnoreListService = $watchIgnoreListService;
|
|
35
35
|
this.$analyticsService = $analyticsService;
|
|
36
36
|
this.$markingModeService = $markingModeService;
|
|
@@ -66,8 +66,8 @@ class PrepareController extends events_1.EventEmitter {
|
|
|
66
66
|
this.watchersData[projectDir] &&
|
|
67
67
|
this.watchersData[projectDir][platformLowerCase] &&
|
|
68
68
|
this.watchersData[projectDir][platformLowerCase].hasWebpackCompilerProcess) {
|
|
69
|
-
await this.$
|
|
70
|
-
this.$
|
|
69
|
+
await this.$bundlerCompilerService.stopBundlerCompiler(platformLowerCase);
|
|
70
|
+
this.$bundlerCompilerService.removeListener(constants_1.BUNDLER_COMPILATION_COMPLETE, this.webpackCompilerHandler);
|
|
71
71
|
this.watchersData[projectDir][platformLowerCase].hasWebpackCompilerProcess = false;
|
|
72
72
|
}
|
|
73
73
|
}
|
|
@@ -89,7 +89,7 @@ class PrepareController extends events_1.EventEmitter {
|
|
|
89
89
|
result = await this.startWatchersWithPrepare(platformData, projectData, prepareData);
|
|
90
90
|
}
|
|
91
91
|
else {
|
|
92
|
-
await this.$
|
|
92
|
+
await this.$bundlerCompilerService.compileWithoutWatch(platformData, projectData, prepareData);
|
|
93
93
|
const hasNativeChanges = await this.$prepareNativePlatformService.prepareNativePlatform(platformData, projectData, prepareData);
|
|
94
94
|
result = {
|
|
95
95
|
hasNativeChanges,
|
|
@@ -149,9 +149,9 @@ class PrepareController extends events_1.EventEmitter {
|
|
|
149
149
|
}
|
|
150
150
|
};
|
|
151
151
|
this.webpackCompilerHandler = handler.bind(this);
|
|
152
|
-
this.$
|
|
152
|
+
this.$bundlerCompilerService.on(constants_1.BUNDLER_COMPILATION_COMPLETE, this.webpackCompilerHandler);
|
|
153
153
|
this.watchersData[projectData.projectDir][platformData.platformNameLowerCase].hasWebpackCompilerProcess = true;
|
|
154
|
-
await this.$
|
|
154
|
+
await this.$bundlerCompilerService.compileWithWatch(platformData, projectData, prepareData);
|
|
155
155
|
}
|
|
156
156
|
}
|
|
157
157
|
async startNativeWatcherWithPrepare(platformData, projectData, prepareData) {
|
|
@@ -293,7 +293,7 @@ class PrepareController extends events_1.EventEmitter {
|
|
|
293
293
|
if (this.pausedFileWatch) {
|
|
294
294
|
for (const watcher of watchers) {
|
|
295
295
|
for (const platform in watcher) {
|
|
296
|
-
await this.$
|
|
296
|
+
await this.$bundlerCompilerService.stopBundlerCompiler(platform);
|
|
297
297
|
watcher[platform].hasWebpackCompilerProcess = false;
|
|
298
298
|
}
|
|
299
299
|
}
|
|
@@ -303,7 +303,7 @@ class PrepareController extends events_1.EventEmitter {
|
|
|
303
303
|
for (const platform in watcher) {
|
|
304
304
|
const args = watcher[platform].prepareArguments;
|
|
305
305
|
watcher[platform].hasWebpackCompilerProcess = true;
|
|
306
|
-
await this.$
|
|
306
|
+
await this.$bundlerCompilerService.compileWithWatch(args.platformData, args.projectData, args.prepareData);
|
|
307
307
|
}
|
|
308
308
|
}
|
|
309
309
|
}
|
|
@@ -121,6 +121,7 @@ export interface IOSLocalSPMPackage extends IOSSPMPackageBase {
|
|
|
121
121
|
}
|
|
122
122
|
|
|
123
123
|
export type IOSSPMPackage = IOSRemoteSPMPackage | IOSLocalSPMPackage;
|
|
124
|
+
export type BundlerType = "webpack" | "rspack" | "vite";
|
|
124
125
|
|
|
125
126
|
interface INsConfigIOS extends INsConfigPlaform {
|
|
126
127
|
discardUncaughtJsExceptions?: boolean;
|
|
@@ -182,6 +183,8 @@ interface INsConfig {
|
|
|
182
183
|
shared?: boolean;
|
|
183
184
|
overridePods?: string;
|
|
184
185
|
webpackConfigPath?: string;
|
|
186
|
+
bundlerConfigPath?: string;
|
|
187
|
+
bundler?: BundlerType;
|
|
185
188
|
ios?: INsConfigIOS;
|
|
186
189
|
android?: INsConfigAndroid;
|
|
187
190
|
visionos?: INSConfigVisionOS;
|
|
@@ -215,13 +218,28 @@ interface IProjectData extends ICreateProjectData {
|
|
|
215
218
|
* Value is true when project has nativescript.config and it has `shared: true` in it.
|
|
216
219
|
*/
|
|
217
220
|
isShared: boolean;
|
|
218
|
-
|
|
219
221
|
/**
|
|
222
|
+
* Specifies the bundler used to build the application.
|
|
223
|
+
*
|
|
224
|
+
* - `"webpack"`: Uses Webpack for traditional bundling.
|
|
225
|
+
* - `"rspack"`: Uses Rspack for fast bundling.
|
|
226
|
+
* - `"vite"`: Uses Vite for fast bundling.
|
|
227
|
+
*
|
|
228
|
+
* @default "webpack"
|
|
229
|
+
*/
|
|
230
|
+
bundler: BundlerType;
|
|
231
|
+
/**
|
|
232
|
+
* @deprecated Use bundlerConfigPath
|
|
220
233
|
* Defines the path to the configuration file passed to webpack process.
|
|
221
234
|
* By default this is the webpack.config.js at the root of the application.
|
|
222
235
|
* The value can be changed by setting `webpackConfigPath` in nativescript.config.
|
|
223
236
|
*/
|
|
224
237
|
webpackConfigPath: string;
|
|
238
|
+
/**
|
|
239
|
+
* Defines the path to the bundler configuration file passed to the compiler.
|
|
240
|
+
* The value can be changed by setting `bundlerConfigPath` in nativescript.config.
|
|
241
|
+
*/
|
|
242
|
+
bundlerConfigPath: string;
|
|
225
243
|
projectName: string;
|
|
226
244
|
|
|
227
245
|
/**
|
package/lib/project-data.js
CHANGED
|
@@ -56,6 +56,7 @@ class ProjectData {
|
|
|
56
56
|
this.errorInvalidProject(projectDir);
|
|
57
57
|
}
|
|
58
58
|
initializeProjectDataFromContent(packageJsonContent, projectDir) {
|
|
59
|
+
var _a, _b;
|
|
59
60
|
projectDir = projectDir || this.$projectHelper.projectDir || "";
|
|
60
61
|
this.projectDir = projectDir;
|
|
61
62
|
const projectFilePath = this.getProjectFilePath(projectDir);
|
|
@@ -92,10 +93,15 @@ class ProjectData {
|
|
|
92
93
|
this.buildXcconfigPath = path.join(this.appResourcesDirectoryPath, this.$devicePlatformsConstants.iOS, constants.BUILD_XCCONFIG_FILE_NAME);
|
|
93
94
|
this.podfilePath = path.join(this.appResourcesDirectoryPath, this.$devicePlatformsConstants.iOS, constants.PODFILE_NAME);
|
|
94
95
|
this.isShared = !!(this.nsConfig && this.nsConfig.shared);
|
|
95
|
-
this.webpackConfigPath
|
|
96
|
-
this.
|
|
97
|
-
|
|
98
|
-
|
|
96
|
+
const webpackConfigPath = this.nsConfig && this.nsConfig.webpackConfigPath
|
|
97
|
+
? path.resolve(this.projectDir, this.nsConfig.webpackConfigPath)
|
|
98
|
+
: path.join(this.projectDir, "webpack.config.js");
|
|
99
|
+
this.webpackConfigPath = webpackConfigPath;
|
|
100
|
+
this.bundlerConfigPath =
|
|
101
|
+
this.nsConfig && this.nsConfig.bundlerConfigPath
|
|
102
|
+
? path.resolve(this.projectDir, this.nsConfig.bundlerConfigPath)
|
|
103
|
+
: webpackConfigPath;
|
|
104
|
+
this.bundler = (_b = (_a = this === null || this === void 0 ? void 0 : this.nsConfig) === null || _a === void 0 ? void 0 : _a.bundler) !== null && _b !== void 0 ? _b : "webpack";
|
|
99
105
|
return;
|
|
100
106
|
}
|
|
101
107
|
this.errorInvalidProject(projectDir);
|
package/lib/services/{webpack/webpack-compiler-service.js → bundler/bundler-compiler-service.js}
RENAMED
|
@@ -6,7 +6,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
6
6
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
7
|
};
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.
|
|
9
|
+
exports.BundlerCompilerService = void 0;
|
|
10
10
|
const path = require("path");
|
|
11
11
|
const semver = require("semver");
|
|
12
12
|
const _ = require("lodash");
|
|
@@ -15,8 +15,8 @@ const decorators_1 = require("../../common/decorators");
|
|
|
15
15
|
const constants_1 = require("../../constants");
|
|
16
16
|
const yok_1 = require("../../common/yok");
|
|
17
17
|
const package_path_helper_1 = require("../../helpers/package-path-helper");
|
|
18
|
-
class
|
|
19
|
-
constructor($options, $errors, $childProcess, $fs, $hooksService, $hostInfo, $logger, $mobileHelper, $cleanupService, $packageManager, $packageInstallationManager) {
|
|
18
|
+
class BundlerCompilerService extends events_1.EventEmitter {
|
|
19
|
+
constructor($options, $errors, $childProcess, $fs, $hooksService, $hostInfo, $logger, $mobileHelper, $cleanupService, $packageManager, $packageInstallationManager, $projectConfigService) {
|
|
20
20
|
super();
|
|
21
21
|
this.$options = $options;
|
|
22
22
|
this.$errors = $errors;
|
|
@@ -29,19 +29,20 @@ class WebpackCompilerService extends events_1.EventEmitter {
|
|
|
29
29
|
this.$cleanupService = $cleanupService;
|
|
30
30
|
this.$packageManager = $packageManager;
|
|
31
31
|
this.$packageInstallationManager = $packageInstallationManager;
|
|
32
|
-
this
|
|
32
|
+
this.$projectConfigService = $projectConfigService;
|
|
33
|
+
this.bundlerProcesses = {};
|
|
33
34
|
this.expectedHashes = {};
|
|
34
35
|
}
|
|
35
36
|
async compileWithWatch(platformData, projectData, prepareData) {
|
|
36
37
|
return new Promise(async (resolve, reject) => {
|
|
37
|
-
if (this.
|
|
38
|
+
if (this.bundlerProcesses[platformData.platformNameLowerCase]) {
|
|
38
39
|
resolve(void 0);
|
|
39
40
|
return;
|
|
40
41
|
}
|
|
41
|
-
let
|
|
42
|
+
let isFirstBundlerWatchCompilation = true;
|
|
42
43
|
prepareData.watch = true;
|
|
43
44
|
try {
|
|
44
|
-
const childProcess = await this.
|
|
45
|
+
const childProcess = await this.startBundleProcess(platformData, projectData, prepareData);
|
|
45
46
|
childProcess.stdout.on("data", function (data) {
|
|
46
47
|
process.stdout.write(data);
|
|
47
48
|
});
|
|
@@ -49,25 +50,26 @@ class WebpackCompilerService extends events_1.EventEmitter {
|
|
|
49
50
|
process.stderr.write(data);
|
|
50
51
|
});
|
|
51
52
|
childProcess.on("message", (message) => {
|
|
52
|
-
this.$logger.trace(
|
|
53
|
+
this.$logger.trace(`Message from ${projectData.bundler}`, message);
|
|
53
54
|
if (typeof message === "object" &&
|
|
54
55
|
"version" in message &&
|
|
55
56
|
"type" in message) {
|
|
56
|
-
if (
|
|
57
|
-
|
|
57
|
+
if (isFirstBundlerWatchCompilation) {
|
|
58
|
+
isFirstBundlerWatchCompilation = false;
|
|
58
59
|
resolve(childProcess);
|
|
59
60
|
return;
|
|
60
61
|
}
|
|
61
62
|
return this.handleHMRMessage(message, platformData, projectData, prepareData);
|
|
62
63
|
}
|
|
63
|
-
if (message ===
|
|
64
|
-
|
|
64
|
+
if (message ===
|
|
65
|
+
`${capitalizeFirstLetter(projectData.bundler)} compilation complete.`) {
|
|
66
|
+
this.$logger.info(`${capitalizeFirstLetter(projectData.bundler)} build done!`);
|
|
65
67
|
resolve(childProcess);
|
|
66
68
|
}
|
|
67
69
|
message = message;
|
|
68
70
|
if (message.emittedFiles) {
|
|
69
|
-
if (
|
|
70
|
-
|
|
71
|
+
if (isFirstBundlerWatchCompilation) {
|
|
72
|
+
isFirstBundlerWatchCompilation = false;
|
|
71
73
|
this.expectedHashes[platformData.platformNameLowerCase] =
|
|
72
74
|
prepareData.hmr ? message.hash : "";
|
|
73
75
|
return;
|
|
@@ -95,27 +97,40 @@ class WebpackCompilerService extends events_1.EventEmitter {
|
|
|
95
97
|
},
|
|
96
98
|
platform: platformData.platformNameLowerCase,
|
|
97
99
|
};
|
|
98
|
-
this.$logger.trace(
|
|
100
|
+
this.$logger.trace(`Generated data from ${projectData.bundler} message:`, data);
|
|
99
101
|
if (data.hasOnlyHotUpdateFiles && previousHash === message.hash) {
|
|
100
102
|
return;
|
|
101
103
|
}
|
|
102
104
|
if (data.files.length) {
|
|
103
|
-
this.emit(constants_1.
|
|
105
|
+
this.emit(constants_1.BUNDLER_COMPILATION_COMPLETE, data);
|
|
104
106
|
}
|
|
105
107
|
}
|
|
106
108
|
});
|
|
107
109
|
childProcess.on("error", (err) => {
|
|
108
|
-
this.$logger.trace(`Unable to start
|
|
109
|
-
delete this.
|
|
110
|
+
this.$logger.trace(`Unable to start ${projectData.bundler} process in watch mode. Error is: ${err}`);
|
|
111
|
+
delete this.bundlerProcesses[platformData.platformNameLowerCase];
|
|
110
112
|
reject(err);
|
|
111
113
|
});
|
|
112
114
|
childProcess.on("close", async (arg) => {
|
|
113
|
-
await this.$cleanupService.removeKillProcess(childProcess.pid.toString());
|
|
114
115
|
const exitCode = typeof arg === "number" ? arg : arg && arg.code;
|
|
115
|
-
this.$logger.trace(
|
|
116
|
-
|
|
116
|
+
this.$logger.trace(`${capitalizeFirstLetter(projectData.bundler)} process exited with code ${exitCode} when we expected it to be long living with watch.`);
|
|
117
|
+
if (this.getBundler() === "vite" && exitCode === 0) {
|
|
118
|
+
const bundlePath = path.join(projectData.projectDir, "dist/bundle.js");
|
|
119
|
+
console.log("bundlePath:", bundlePath);
|
|
120
|
+
const data = {
|
|
121
|
+
files: [bundlePath],
|
|
122
|
+
hasOnlyHotUpdateFiles: false,
|
|
123
|
+
hmrData: {},
|
|
124
|
+
platform: platformData.platformNameLowerCase,
|
|
125
|
+
};
|
|
126
|
+
this.emit(constants_1.BUNDLER_COMPILATION_COMPLETE, data);
|
|
127
|
+
resolve(1);
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
await this.$cleanupService.removeKillProcess(childProcess.pid.toString());
|
|
131
|
+
const error = new Error(`Executing ${projectData.bundler} failed with exit code ${exitCode}.`);
|
|
117
132
|
error.code = exitCode;
|
|
118
|
-
delete this.
|
|
133
|
+
delete this.bundlerProcesses[platformData.platformNameLowerCase];
|
|
119
134
|
reject(error);
|
|
120
135
|
});
|
|
121
136
|
}
|
|
@@ -126,26 +141,26 @@ class WebpackCompilerService extends events_1.EventEmitter {
|
|
|
126
141
|
}
|
|
127
142
|
async compileWithoutWatch(platformData, projectData, prepareData) {
|
|
128
143
|
return new Promise(async (resolve, reject) => {
|
|
129
|
-
if (this.
|
|
144
|
+
if (this.bundlerProcesses[platformData.platformNameLowerCase]) {
|
|
130
145
|
resolve();
|
|
131
146
|
return;
|
|
132
147
|
}
|
|
133
148
|
try {
|
|
134
|
-
const childProcess = await this.
|
|
149
|
+
const childProcess = await this.startBundleProcess(platformData, projectData, prepareData);
|
|
135
150
|
childProcess.on("error", (err) => {
|
|
136
|
-
this.$logger.trace(`Unable to start
|
|
137
|
-
delete this.
|
|
151
|
+
this.$logger.trace(`Unable to start ${projectData.bundler} process in non-watch mode. Error is: ${err}`);
|
|
152
|
+
delete this.bundlerProcesses[platformData.platformNameLowerCase];
|
|
138
153
|
reject(err);
|
|
139
154
|
});
|
|
140
155
|
childProcess.on("close", async (arg) => {
|
|
141
156
|
await this.$cleanupService.removeKillProcess(childProcess.pid.toString());
|
|
142
|
-
delete this.
|
|
157
|
+
delete this.bundlerProcesses[platformData.platformNameLowerCase];
|
|
143
158
|
const exitCode = typeof arg === "number" ? arg : arg && arg.code;
|
|
144
159
|
if (exitCode === 0) {
|
|
145
160
|
resolve();
|
|
146
161
|
}
|
|
147
162
|
else {
|
|
148
|
-
const error = new Error(`Executing
|
|
163
|
+
const error = new Error(`Executing ${projectData.bundler} failed with exit code ${exitCode}.`);
|
|
149
164
|
error.code = exitCode;
|
|
150
165
|
reject(error);
|
|
151
166
|
}
|
|
@@ -156,14 +171,14 @@ class WebpackCompilerService extends events_1.EventEmitter {
|
|
|
156
171
|
}
|
|
157
172
|
});
|
|
158
173
|
}
|
|
159
|
-
async
|
|
174
|
+
async stopBundlerCompiler(platform) {
|
|
160
175
|
if (platform) {
|
|
161
|
-
await this.
|
|
176
|
+
await this.stopBundlerForPlatform(platform);
|
|
162
177
|
}
|
|
163
178
|
else {
|
|
164
|
-
const
|
|
165
|
-
for (let i = 0; i <
|
|
166
|
-
await this.
|
|
179
|
+
const bundlerPlatforms = Object.keys(this.bundlerProcesses);
|
|
180
|
+
for (let i = 0; i < bundlerPlatforms.length; i++) {
|
|
181
|
+
await this.stopBundlerForPlatform(bundlerPlatforms[i]);
|
|
167
182
|
}
|
|
168
183
|
}
|
|
169
184
|
}
|
|
@@ -172,12 +187,23 @@ class WebpackCompilerService extends events_1.EventEmitter {
|
|
|
172
187
|
const res = currentPackageManager !== constants_1.PackageManagers.pnpm;
|
|
173
188
|
return res;
|
|
174
189
|
}
|
|
175
|
-
async
|
|
176
|
-
if (
|
|
177
|
-
this.$
|
|
190
|
+
async startBundleProcess(platformData, projectData, prepareData) {
|
|
191
|
+
if (projectData.bundlerConfigPath) {
|
|
192
|
+
if (!this.$fs.exists(projectData.bundlerConfigPath)) {
|
|
193
|
+
this.$errors.fail(`The bundler configuration file ${projectData.bundlerConfigPath} does not exist. Ensure the file exists, or update the path in ${constants_1.CONFIG_FILE_NAME_DISPLAY}.`);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
else {
|
|
197
|
+
if (!this.$fs.exists(projectData.bundlerConfigPath)) {
|
|
198
|
+
this.$errors.fail(`The ${projectData.bundler} configuration file ${projectData.bundlerConfigPath} does not exist. Ensure the file exists, or update the path in ${constants_1.CONFIG_FILE_NAME_DISPLAY}.`);
|
|
199
|
+
}
|
|
178
200
|
}
|
|
179
201
|
const envData = this.buildEnvData(platformData.platformNameLowerCase, projectData, prepareData);
|
|
180
|
-
const
|
|
202
|
+
const isVite = this.getBundler() === "vite";
|
|
203
|
+
const cliArgs = await this.buildEnvCommandLineParams(envData, platformData, projectData, prepareData);
|
|
204
|
+
const envParams = isVite
|
|
205
|
+
? [`--mode=${platformData.platformNameLowerCase}`, "--", ...cliArgs]
|
|
206
|
+
: cliArgs;
|
|
181
207
|
const additionalNodeArgs = semver.major(process.version) <= 8 ? ["--harmony"] : [];
|
|
182
208
|
if (await this.shouldUsePreserveSymlinksOption()) {
|
|
183
209
|
additionalNodeArgs.push("--preserve-symlinks");
|
|
@@ -187,13 +213,15 @@ class WebpackCompilerService extends events_1.EventEmitter {
|
|
|
187
213
|
}
|
|
188
214
|
const args = [
|
|
189
215
|
...additionalNodeArgs,
|
|
190
|
-
this.
|
|
191
|
-
this.
|
|
192
|
-
`--config=${projectData.
|
|
216
|
+
this.getBundlerExecutablePath(projectData),
|
|
217
|
+
this.isModernBundler(projectData) ? `build` : null,
|
|
218
|
+
`--config=${projectData.bundlerConfigPath}`,
|
|
193
219
|
...envParams,
|
|
194
220
|
].filter(Boolean);
|
|
195
|
-
if (
|
|
196
|
-
|
|
221
|
+
if (!isVite) {
|
|
222
|
+
if (prepareData.watch) {
|
|
223
|
+
args.push("--watch");
|
|
224
|
+
}
|
|
197
225
|
}
|
|
198
226
|
const stdio = prepareData.watch ? ["ipc"] : "inherit";
|
|
199
227
|
const options = {
|
|
@@ -201,7 +229,9 @@ class WebpackCompilerService extends events_1.EventEmitter {
|
|
|
201
229
|
stdio,
|
|
202
230
|
};
|
|
203
231
|
options.env = {
|
|
232
|
+
...process.env,
|
|
204
233
|
NATIVESCRIPT_WEBPACK_ENV: JSON.stringify(envData),
|
|
234
|
+
NATIVESCRIPT_BUNDLER_ENV: JSON.stringify(envData),
|
|
205
235
|
};
|
|
206
236
|
if (this.$hostInfo.isWindows) {
|
|
207
237
|
Object.assign(options.env, { APPDATA: process.env.appData });
|
|
@@ -213,8 +243,9 @@ class WebpackCompilerService extends events_1.EventEmitter {
|
|
|
213
243
|
USER_PROJECT_PLATFORMS_IOS: this.$options.hostProjectPath,
|
|
214
244
|
});
|
|
215
245
|
}
|
|
246
|
+
console.log("args:", args);
|
|
216
247
|
const childProcess = this.$childProcess.spawn(process.execPath, args, options);
|
|
217
|
-
this.
|
|
248
|
+
this.bundlerProcesses[platformData.platformNameLowerCase] = childProcess;
|
|
218
249
|
await this.$cleanupService.addKillProcess(childProcess.pid.toString());
|
|
219
250
|
return childProcess;
|
|
220
251
|
}
|
|
@@ -259,13 +290,15 @@ class WebpackCompilerService extends events_1.EventEmitter {
|
|
|
259
290
|
envFlagNames.splice(envFlagNames.indexOf("snapshot"), 1);
|
|
260
291
|
}
|
|
261
292
|
else if (this.$hostInfo.isWindows) {
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
293
|
+
if (projectData.bundler === "webpack") {
|
|
294
|
+
const minWebpackPluginWithWinSnapshotsVersion = "1.3.0";
|
|
295
|
+
const installedWebpackPluginVersion = await this.$packageInstallationManager.getInstalledDependencyVersion(constants_1.WEBPACK_PLUGIN_NAME, projectData.projectDir);
|
|
296
|
+
const hasWebpackPluginWithWinSnapshotsSupport = !!installedWebpackPluginVersion
|
|
297
|
+
? semver.gte(semver.coerce(installedWebpackPluginVersion), minWebpackPluginWithWinSnapshotsVersion)
|
|
298
|
+
: true;
|
|
299
|
+
if (!hasWebpackPluginWithWinSnapshotsSupport) {
|
|
300
|
+
this.$errors.fail(`In order to generate Snapshots on Windows, please upgrade your Webpack plugin version (npm i ${constants_1.WEBPACK_PLUGIN_NAME}@latest).`);
|
|
301
|
+
}
|
|
269
302
|
}
|
|
270
303
|
}
|
|
271
304
|
}
|
|
@@ -316,21 +349,21 @@ class WebpackCompilerService extends events_1.EventEmitter {
|
|
|
316
349
|
}
|
|
317
350
|
return hotHash || "";
|
|
318
351
|
}
|
|
319
|
-
async
|
|
320
|
-
this.$logger.trace(`Stopping
|
|
321
|
-
const
|
|
322
|
-
await this.$cleanupService.removeKillProcess(
|
|
323
|
-
if (
|
|
324
|
-
|
|
325
|
-
delete this.
|
|
352
|
+
async stopBundlerForPlatform(platform) {
|
|
353
|
+
this.$logger.trace(`Stopping ${this.getBundler()} watch for platform ${platform}.`);
|
|
354
|
+
const bundlerProcess = this.bundlerProcesses[platform];
|
|
355
|
+
await this.$cleanupService.removeKillProcess(bundlerProcess.pid.toString());
|
|
356
|
+
if (bundlerProcess) {
|
|
357
|
+
bundlerProcess.kill("SIGINT");
|
|
358
|
+
delete this.bundlerProcesses[platform];
|
|
326
359
|
}
|
|
327
360
|
}
|
|
328
361
|
handleHMRMessage(message, platformData, projectData, prepareData) {
|
|
329
|
-
this.$logger.trace(
|
|
362
|
+
this.$logger.trace(`Received message from ${projectData.bundler} process:`, message);
|
|
330
363
|
if (message.type !== "compilation") {
|
|
331
364
|
return;
|
|
332
365
|
}
|
|
333
|
-
this.$logger.trace(
|
|
366
|
+
this.$logger.trace(`${capitalizeFirstLetter(projectData.bundler)} build done!`);
|
|
334
367
|
const files = message.data.emittedAssets.map((asset) => path.join(platformData.appDestinationDirectoryPath, this.$options.hostProjectModuleName, asset));
|
|
335
368
|
const staleFiles = message.data.staleAssets.map((asset) => path.join(platformData.appDestinationDirectoryPath, this.$options.hostProjectModuleName, asset));
|
|
336
369
|
const lastHash = (() => {
|
|
@@ -347,7 +380,7 @@ class WebpackCompilerService extends events_1.EventEmitter {
|
|
|
347
380
|
if (!files.length) {
|
|
348
381
|
return;
|
|
349
382
|
}
|
|
350
|
-
this.emit(constants_1.
|
|
383
|
+
this.emit(constants_1.BUNDLER_COMPILATION_COMPLETE, {
|
|
351
384
|
files,
|
|
352
385
|
staleFiles,
|
|
353
386
|
hasOnlyHotUpdateFiles: prepareData.hmr,
|
|
@@ -358,9 +391,18 @@ class WebpackCompilerService extends events_1.EventEmitter {
|
|
|
358
391
|
platform: platformData.platformNameLowerCase,
|
|
359
392
|
});
|
|
360
393
|
}
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
394
|
+
getBundlerExecutablePath(projectData) {
|
|
395
|
+
const bundler = this.getBundler();
|
|
396
|
+
if (bundler === "vite") {
|
|
397
|
+
const packagePath = (0, package_path_helper_1.resolvePackagePath)(`vite`, {
|
|
398
|
+
paths: [projectData.projectDir],
|
|
399
|
+
});
|
|
400
|
+
if (packagePath) {
|
|
401
|
+
return path.resolve(packagePath, "bin", "vite.js");
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
else if (this.isModernBundler(projectData)) {
|
|
405
|
+
const packagePath = (0, package_path_helper_1.resolvePackagePath)(`@nativescript/${bundler}`, {
|
|
364
406
|
paths: [projectData.projectDir],
|
|
365
407
|
});
|
|
366
408
|
if (packagePath) {
|
|
@@ -375,22 +417,35 @@ class WebpackCompilerService extends events_1.EventEmitter {
|
|
|
375
417
|
}
|
|
376
418
|
return path.resolve(packagePath, "bin", "webpack.js");
|
|
377
419
|
}
|
|
378
|
-
|
|
379
|
-
const
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
if (packageJSONPath) {
|
|
383
|
-
const packageData = this.$fs.readJson(packageJSONPath);
|
|
384
|
-
const ver = semver.coerce(packageData.version);
|
|
385
|
-
if (semver.satisfies(ver, ">= 5.0.0")) {
|
|
420
|
+
isModernBundler(projectData) {
|
|
421
|
+
const bundler = this.getBundler();
|
|
422
|
+
switch (bundler) {
|
|
423
|
+
case "rspack":
|
|
386
424
|
return true;
|
|
387
|
-
|
|
425
|
+
default:
|
|
426
|
+
const packageJSONPath = (0, package_path_helper_1.resolvePackageJSONPath)(constants_1.WEBPACK_PLUGIN_NAME, {
|
|
427
|
+
paths: [projectData.projectDir],
|
|
428
|
+
});
|
|
429
|
+
if (packageJSONPath) {
|
|
430
|
+
const packageData = this.$fs.readJson(packageJSONPath);
|
|
431
|
+
const ver = semver.coerce(packageData.version);
|
|
432
|
+
if (semver.satisfies(ver, ">= 5.0.0")) {
|
|
433
|
+
return true;
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
break;
|
|
388
437
|
}
|
|
389
438
|
return false;
|
|
390
439
|
}
|
|
440
|
+
getBundler() {
|
|
441
|
+
return this.$projectConfigService.getValue(`bundler`, "webpack");
|
|
442
|
+
}
|
|
391
443
|
}
|
|
392
|
-
exports.
|
|
444
|
+
exports.BundlerCompilerService = BundlerCompilerService;
|
|
393
445
|
__decorate([
|
|
394
446
|
(0, decorators_1.performanceLog)()
|
|
395
|
-
],
|
|
396
|
-
|
|
447
|
+
], BundlerCompilerService.prototype, "startBundleProcess", null);
|
|
448
|
+
function capitalizeFirstLetter(val) {
|
|
449
|
+
return String(val).charAt(0).toUpperCase() + String(val).slice(1);
|
|
450
|
+
}
|
|
451
|
+
yok_1.injector.register("bundlerCompilerService", BundlerCompilerService);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nativescript",
|
|
3
3
|
"main": "./lib/nativescript-cli-lib.js",
|
|
4
|
-
"version": "9.0.0-alpha.
|
|
4
|
+
"version": "9.0.0-alpha.2",
|
|
5
5
|
"author": "NativeScript <oss@nativescript.org>",
|
|
6
6
|
"description": "Command-line interface for building NativeScript projects",
|
|
7
7
|
"bin": {
|
|
@@ -1,226 +0,0 @@
|
|
|
1
|
-
import { EventEmitter } from "events";
|
|
2
|
-
import { BuildData } from "../../data/build-data";
|
|
3
|
-
import { PrepareData } from "../../data/prepare-data";
|
|
4
|
-
import {
|
|
5
|
-
IPlatformProjectServiceBase,
|
|
6
|
-
IProjectData,
|
|
7
|
-
IValidatePlatformOutput,
|
|
8
|
-
} from "../../definitions/project";
|
|
9
|
-
import { IOptions, IDependencyData } from "../../declarations";
|
|
10
|
-
import { IPlatformData } from "../../definitions/platform";
|
|
11
|
-
import { IPluginData } from "../../definitions/plugins";
|
|
12
|
-
import { IRelease, ISpawnResult } from "../../common/declarations";
|
|
13
|
-
import {
|
|
14
|
-
IProjectChangesInfo,
|
|
15
|
-
IPrepareInfo,
|
|
16
|
-
IAddedNativePlatform,
|
|
17
|
-
} from "../../definitions/project-changes";
|
|
18
|
-
import { INotConfiguredEnvOptions } from "../../common/definitions/commands";
|
|
19
|
-
|
|
20
|
-
declare global {
|
|
21
|
-
interface IWebpackCompilerService extends EventEmitter {
|
|
22
|
-
compileWithWatch(
|
|
23
|
-
platformData: IPlatformData,
|
|
24
|
-
projectData: IProjectData,
|
|
25
|
-
prepareData: IPrepareData
|
|
26
|
-
): Promise<any>;
|
|
27
|
-
compileWithoutWatch(
|
|
28
|
-
platformData: IPlatformData,
|
|
29
|
-
projectData: IProjectData,
|
|
30
|
-
prepareData: IPrepareData
|
|
31
|
-
): Promise<void>;
|
|
32
|
-
stopWebpackCompiler(platform: string): Promise<void>;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
interface IWebpackEnvOptions {
|
|
36
|
-
sourceMap?: boolean;
|
|
37
|
-
uglify?: boolean;
|
|
38
|
-
production?: boolean;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
interface IProjectChangesService {
|
|
42
|
-
checkForChanges(
|
|
43
|
-
platformData: IPlatformData,
|
|
44
|
-
projectData: IProjectData,
|
|
45
|
-
prepareData: IPrepareData
|
|
46
|
-
): Promise<IProjectChangesInfo>;
|
|
47
|
-
getPrepareInfoFilePath(platformData: IPlatformData): string;
|
|
48
|
-
getPrepareInfo(platformData: IPlatformData): IPrepareInfo;
|
|
49
|
-
savePrepareInfo(
|
|
50
|
-
platformData: IPlatformData,
|
|
51
|
-
projectData: IProjectData,
|
|
52
|
-
prepareData: IPrepareData
|
|
53
|
-
): Promise<void>;
|
|
54
|
-
setNativePlatformStatus(
|
|
55
|
-
platformData: IPlatformData,
|
|
56
|
-
projectData: IProjectData,
|
|
57
|
-
addedPlatform: IAddedNativePlatform
|
|
58
|
-
): void;
|
|
59
|
-
currentChanges: IProjectChangesInfo;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
interface IFilesChangeEventData {
|
|
63
|
-
platform: string;
|
|
64
|
-
files: string[];
|
|
65
|
-
staleFiles: string[];
|
|
66
|
-
hmrData: IPlatformHmrData;
|
|
67
|
-
hasOnlyHotUpdateFiles: boolean;
|
|
68
|
-
hasNativeChanges: boolean;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
interface IWebpackEmitMessage {
|
|
72
|
-
emittedFiles: string[];
|
|
73
|
-
chunkFiles: string[];
|
|
74
|
-
hash: string;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
interface IPlatformProjectService
|
|
78
|
-
extends NodeJS.EventEmitter,
|
|
79
|
-
IPlatformProjectServiceBase {
|
|
80
|
-
getPlatformData(projectData: IProjectData): IPlatformData;
|
|
81
|
-
validate(
|
|
82
|
-
projectData: IProjectData,
|
|
83
|
-
options: IOptions,
|
|
84
|
-
notConfiguredEnvOptions?: INotConfiguredEnvOptions
|
|
85
|
-
): Promise<IValidatePlatformOutput>;
|
|
86
|
-
createProject(
|
|
87
|
-
frameworkDir: string,
|
|
88
|
-
frameworkVersion: string,
|
|
89
|
-
projectData: IProjectData
|
|
90
|
-
): Promise<void>;
|
|
91
|
-
interpolateData(projectData: IProjectData): Promise<void>;
|
|
92
|
-
interpolateConfigurationFile(projectData: IProjectData): void;
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* Executes additional actions after native project is created.
|
|
96
|
-
* @param {string} projectRoot Path to the real NativeScript project.
|
|
97
|
-
* @param {IProjectData} projectData DTO with information about the project.
|
|
98
|
-
* @returns {void}
|
|
99
|
-
*/
|
|
100
|
-
afterCreateProject(projectRoot: string, projectData: IProjectData): void;
|
|
101
|
-
|
|
102
|
-
/**
|
|
103
|
-
* Gets first chance to validate the options provided as command line arguments.
|
|
104
|
-
* @param {string} projectId Project identifier - for example org.nativescript.test.
|
|
105
|
-
* @param {any} provision UUID of the provisioning profile used in iOS option validation.
|
|
106
|
-
* @returns {void}
|
|
107
|
-
*/
|
|
108
|
-
validateOptions(
|
|
109
|
-
projectId?: string,
|
|
110
|
-
provision?: true | string,
|
|
111
|
-
teamId?: true | string
|
|
112
|
-
): Promise<boolean>;
|
|
113
|
-
|
|
114
|
-
buildProject<T extends BuildData>(
|
|
115
|
-
projectRoot: string,
|
|
116
|
-
projectData: IProjectData,
|
|
117
|
-
buildConfig: T
|
|
118
|
-
): Promise<void>;
|
|
119
|
-
|
|
120
|
-
/**
|
|
121
|
-
* Prepares images in Native project (for iOS).
|
|
122
|
-
* @param {IProjectData} projectData DTO with information about the project.
|
|
123
|
-
* @param {any} platformSpecificData Platform specific data required for project preparation.
|
|
124
|
-
* @returns {void}
|
|
125
|
-
*/
|
|
126
|
-
prepareProject<T extends PrepareData>(
|
|
127
|
-
projectData: IProjectData,
|
|
128
|
-
prepareData: T
|
|
129
|
-
): Promise<void>;
|
|
130
|
-
|
|
131
|
-
/**
|
|
132
|
-
* Prepares App_Resources in the native project by clearing data from other platform and applying platform specific rules.
|
|
133
|
-
* @param {string} appResourcesDirectoryPath The place in the native project where the App_Resources are copied first.
|
|
134
|
-
* @param {IProjectData} projectData DTO with information about the project.
|
|
135
|
-
* @returns {void}
|
|
136
|
-
*/
|
|
137
|
-
prepareAppResources(projectData: IProjectData): void;
|
|
138
|
-
|
|
139
|
-
/**
|
|
140
|
-
* Defines if current platform is prepared (i.e. if <project dir>/platforms/<platform> dir exists).
|
|
141
|
-
* @param {string} projectRoot The project directory (path where root's package.json is located).
|
|
142
|
-
* @param {IProjectData} projectData DTO with information about the project.
|
|
143
|
-
* @returns {boolean} True in case platform is prepare (i.e. if <project dir>/platforms/<platform> dir exists), false otherwise.
|
|
144
|
-
*/
|
|
145
|
-
isPlatformPrepared(projectRoot: string, projectData: IProjectData): boolean;
|
|
146
|
-
|
|
147
|
-
preparePluginNativeCode(
|
|
148
|
-
pluginData: IPluginData,
|
|
149
|
-
options?: any
|
|
150
|
-
): Promise<void>;
|
|
151
|
-
|
|
152
|
-
/**
|
|
153
|
-
* Removes native code of a plugin (CocoaPods, jars, libs, src).
|
|
154
|
-
* @param {IPluginData} Plugins data describing the plugin which should be cleaned.
|
|
155
|
-
* @param {IProjectData} projectData DTO with information about the project.
|
|
156
|
-
* @returns {void}
|
|
157
|
-
*/
|
|
158
|
-
removePluginNativeCode(
|
|
159
|
-
pluginData: IPluginData,
|
|
160
|
-
projectData: IProjectData
|
|
161
|
-
): Promise<void>;
|
|
162
|
-
|
|
163
|
-
beforePrepareAllPlugins(
|
|
164
|
-
projectData: IProjectData,
|
|
165
|
-
dependencies?: IDependencyData[]
|
|
166
|
-
): Promise<IDependencyData[]>;
|
|
167
|
-
|
|
168
|
-
handleNativeDependenciesChange(
|
|
169
|
-
projectData: IProjectData,
|
|
170
|
-
opts: IRelease
|
|
171
|
-
): Promise<void>;
|
|
172
|
-
|
|
173
|
-
/**
|
|
174
|
-
* Gets the path wheren App_Resources should be copied.
|
|
175
|
-
* @returns {string} Path to native project, where App_Resources should be copied.
|
|
176
|
-
*/
|
|
177
|
-
getAppResourcesDestinationDirectoryPath(projectData: IProjectData): string;
|
|
178
|
-
|
|
179
|
-
cleanDeviceTempFolder(
|
|
180
|
-
deviceIdentifier: string,
|
|
181
|
-
projectData: IProjectData
|
|
182
|
-
): Promise<void>;
|
|
183
|
-
processConfigurationFilesFromAppResources(
|
|
184
|
-
projectData: IProjectData,
|
|
185
|
-
opts: { release: boolean }
|
|
186
|
-
): Promise<void>;
|
|
187
|
-
|
|
188
|
-
/**
|
|
189
|
-
* Ensures there is configuration file (AndroidManifest.xml, Info.plist) in app/App_Resources.
|
|
190
|
-
* @param {IProjectData} projectData DTO with information about the project.
|
|
191
|
-
* @returns {void}
|
|
192
|
-
*/
|
|
193
|
-
ensureConfigurationFileInAppResources(projectData: IProjectData): void;
|
|
194
|
-
|
|
195
|
-
/**
|
|
196
|
-
* Stops all running processes that might hold a lock on the filesystem.
|
|
197
|
-
* Android: Gradle daemon processes are terminated.
|
|
198
|
-
* @param {IPlatformData} platformData The data for the specified platform.
|
|
199
|
-
* @returns {void}
|
|
200
|
-
*/
|
|
201
|
-
stopServices?(projectRoot: string): Promise<ISpawnResult>;
|
|
202
|
-
|
|
203
|
-
/**
|
|
204
|
-
* Removes build artifacts specific to the platform
|
|
205
|
-
* @param {string} projectRoot The root directory of the native project.
|
|
206
|
-
* @returns {void}
|
|
207
|
-
*/
|
|
208
|
-
cleanProject?(projectRoot: string): Promise<void>;
|
|
209
|
-
|
|
210
|
-
/**
|
|
211
|
-
* Check the current state of the project, and validate against the options.
|
|
212
|
-
* If there are parts in the project that are inconsistent with the desired options, marks them in the changeset flags.
|
|
213
|
-
*/
|
|
214
|
-
checkForChanges<T extends PrepareData>(
|
|
215
|
-
changeset: IProjectChangesInfo,
|
|
216
|
-
prepareData: T,
|
|
217
|
-
projectData: IProjectData
|
|
218
|
-
): Promise<void>;
|
|
219
|
-
|
|
220
|
-
/**
|
|
221
|
-
* Get the deployment target's version
|
|
222
|
-
* Currently implemented only for iOS -> returns the value of IPHONEOS_DEPLOYMENT_TARGET property from xcconfig file
|
|
223
|
-
*/
|
|
224
|
-
getDeploymentTarget?(projectData: IProjectData): any;
|
|
225
|
-
}
|
|
226
|
-
}
|