nativescript 9.0.0-alpha.1 → 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.
|
@@ -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",
|
|
@@ -200,9 +200,10 @@ class BundlerCompilerService extends events_1.EventEmitter {
|
|
|
200
200
|
}
|
|
201
201
|
const envData = this.buildEnvData(platformData.platformNameLowerCase, projectData, prepareData);
|
|
202
202
|
const isVite = this.getBundler() === "vite";
|
|
203
|
+
const cliArgs = await this.buildEnvCommandLineParams(envData, platformData, projectData, prepareData);
|
|
203
204
|
const envParams = isVite
|
|
204
|
-
? [`--mode=${platformData.platformNameLowerCase}
|
|
205
|
-
:
|
|
205
|
+
? [`--mode=${platformData.platformNameLowerCase}`, "--", ...cliArgs]
|
|
206
|
+
: cliArgs;
|
|
206
207
|
const additionalNodeArgs = semver.major(process.version) <= 8 ? ["--harmony"] : [];
|
|
207
208
|
if (await this.shouldUsePreserveSymlinksOption()) {
|
|
208
209
|
additionalNodeArgs.push("--preserve-symlinks");
|
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": {
|