Skip to content

Commit cbfe8c2

Browse files
committed
Merge remote-tracking branch 'origin/main' into feat/hooks-esm-support
2 parents 312db9e + 067ffd9 commit cbfe8c2

File tree

3 files changed

+55
-44
lines changed

3 files changed

+55
-44
lines changed

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
## [8.9.3](https://github.com/NativeScript/nativescript-cli/compare/v8.9.2...v8.9.3) (2025-07-16)
2+
3+
4+
### Bug Fixes
5+
6+
* **bundler:** include process.env first ([4df139d](https://github.com/NativeScript/nativescript-cli/commit/4df139dc83456ac98dc4cdae765b72a47a945f91))
7+
* pass down process environment to webpack process ([#5844](https://github.com/NativeScript/nativescript-cli/issues/5844)) ([1e8b93f](https://github.com/NativeScript/nativescript-cli/commit/1e8b93fb0b8c5ac3080fdb5eecec5b7326859c81))
8+
9+
10+
111
## [8.9.2](https://github.com/NativeScript/nativescript-cli/compare/v8.9.1...v8.9.2) (2025-03-25)
212

313

lib/services/webpack/webpack-compiler-service.ts

Lines changed: 43 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -64,15 +64,15 @@ export class WebpackCompilerService
6464
private $mobileHelper: Mobile.IMobileHelper,
6565
private $cleanupService: ICleanupService,
6666
private $packageManager: IPackageManager,
67-
private $packageInstallationManager: IPackageInstallationManager // private $sharedEventBus: ISharedEventBus
67+
private $packageInstallationManager: IPackageInstallationManager, // private $sharedEventBus: ISharedEventBus
6868
) {
6969
super();
7070
}
7171

7272
public async compileWithWatch(
7373
platformData: IPlatformData,
7474
projectData: IProjectData,
75-
prepareData: IPrepareData
75+
prepareData: IPrepareData,
7676
): Promise<any> {
7777
return new Promise(async (resolve, reject) => {
7878
if (this.webpackProcesses[platformData.platformNameLowerCase]) {
@@ -86,7 +86,7 @@ export class WebpackCompilerService
8686
const childProcess = await this.startWebpackProcess(
8787
platformData,
8888
projectData,
89-
prepareData
89+
prepareData,
9090
);
9191

9292
childProcess.stdout.on("data", function (data) {
@@ -125,7 +125,7 @@ export class WebpackCompilerService
125125
message as IWebpackMessage<IWebpackCompilation>,
126126
platformData,
127127
projectData,
128-
prepareData
128+
prepareData,
129129
);
130130
}
131131

@@ -153,7 +153,7 @@ export class WebpackCompilerService
153153
message.emittedFiles,
154154
message.chunkFiles,
155155
message.hash,
156-
platformData.platformNameLowerCase
156+
platformData.platformNameLowerCase,
157157
);
158158
} else {
159159
result = {
@@ -166,21 +166,21 @@ export class WebpackCompilerService
166166
path.join(
167167
platformData.appDestinationDirectoryPath,
168168
this.$options.hostProjectModuleName,
169-
file
170-
)
169+
file,
170+
),
171171
);
172172
const fallbackFiles = result.fallbackFiles.map((file: string) =>
173173
path.join(
174174
platformData.appDestinationDirectoryPath,
175175
this.$options.hostProjectModuleName,
176-
file
177-
)
176+
file,
177+
),
178178
);
179179

180180
const data = {
181181
files,
182182
hasOnlyHotUpdateFiles: files.every(
183-
(f) => f.indexOf("hot-update") > -1
183+
(f) => f.indexOf("hot-update") > -1,
184184
),
185185
hmrData: {
186186
hash: result.hash,
@@ -204,23 +204,23 @@ export class WebpackCompilerService
204204

205205
childProcess.on("error", (err) => {
206206
this.$logger.trace(
207-
`Unable to start webpack process in watch mode. Error is: ${err}`
207+
`Unable to start webpack process in watch mode. Error is: ${err}`,
208208
);
209209
delete this.webpackProcesses[platformData.platformNameLowerCase];
210210
reject(err);
211211
});
212212

213213
childProcess.on("close", async (arg: any) => {
214214
await this.$cleanupService.removeKillProcess(
215-
childProcess.pid.toString()
215+
childProcess.pid.toString(),
216216
);
217217

218218
const exitCode = typeof arg === "number" ? arg : arg && arg.code;
219219
this.$logger.trace(
220-
`Webpack process exited with code ${exitCode} when we expected it to be long living with watch.`
220+
`Webpack process exited with code ${exitCode} when we expected it to be long living with watch.`,
221221
);
222222
const error: any = new Error(
223-
`Executing webpack failed with exit code ${exitCode}.`
223+
`Executing webpack failed with exit code ${exitCode}.`,
224224
);
225225
error.code = exitCode;
226226
delete this.webpackProcesses[platformData.platformNameLowerCase];
@@ -235,7 +235,7 @@ export class WebpackCompilerService
235235
public async compileWithoutWatch(
236236
platformData: IPlatformData,
237237
projectData: IProjectData,
238-
prepareData: IPrepareData
238+
prepareData: IPrepareData,
239239
): Promise<void> {
240240
return new Promise(async (resolve, reject) => {
241241
if (this.webpackProcesses[platformData.platformNameLowerCase]) {
@@ -247,20 +247,20 @@ export class WebpackCompilerService
247247
const childProcess = await this.startWebpackProcess(
248248
platformData,
249249
projectData,
250-
prepareData
250+
prepareData,
251251
);
252252

253253
childProcess.on("error", (err) => {
254254
this.$logger.trace(
255-
`Unable to start webpack process in non-watch mode. Error is: ${err}`
255+
`Unable to start webpack process in non-watch mode. Error is: ${err}`,
256256
);
257257
delete this.webpackProcesses[platformData.platformNameLowerCase];
258258
reject(err);
259259
});
260260

261261
childProcess.on("close", async (arg: any) => {
262262
await this.$cleanupService.removeKillProcess(
263-
childProcess.pid.toString()
263+
childProcess.pid.toString(),
264264
);
265265

266266
delete this.webpackProcesses[platformData.platformNameLowerCase];
@@ -269,7 +269,7 @@ export class WebpackCompilerService
269269
resolve();
270270
} else {
271271
const error: any = new Error(
272-
`Executing webpack failed with exit code ${exitCode}.`
272+
`Executing webpack failed with exit code ${exitCode}.`,
273273
);
274274
error.code = exitCode;
275275
reject(error);
@@ -307,24 +307,24 @@ export class WebpackCompilerService
307307
private async startWebpackProcess(
308308
platformData: IPlatformData,
309309
projectData: IProjectData,
310-
prepareData: IPrepareData
310+
prepareData: IPrepareData,
311311
): Promise<child_process.ChildProcess> {
312312
if (!this.$fs.exists(projectData.webpackConfigPath)) {
313313
this.$errors.fail(
314-
`The webpack configuration file ${projectData.webpackConfigPath} does not exist. Ensure the file exists, or update the path in ${CONFIG_FILE_NAME_DISPLAY}.`
314+
`The webpack configuration file ${projectData.webpackConfigPath} does not exist. Ensure the file exists, or update the path in ${CONFIG_FILE_NAME_DISPLAY}.`,
315315
);
316316
}
317317

318318
const envData = this.buildEnvData(
319319
platformData.platformNameLowerCase,
320320
projectData,
321-
prepareData
321+
prepareData,
322322
);
323323
const envParams = await this.buildEnvCommandLineParams(
324324
envData,
325325
platformData,
326326
projectData,
327-
prepareData
327+
prepareData,
328328
);
329329
const additionalNodeArgs =
330330
semver.major(process.version) <= 8 ? ["--harmony"] : [];
@@ -355,6 +355,7 @@ export class WebpackCompilerService
355355
stdio,
356356
};
357357
options.env = {
358+
...process.env,
358359
NATIVESCRIPT_WEBPACK_ENV: JSON.stringify(envData),
359360
};
360361
if (this.$hostInfo.isWindows) {
@@ -372,7 +373,7 @@ export class WebpackCompilerService
372373
const childProcess = this.$childProcess.spawn(
373374
process.execPath,
374375
args,
375-
options
376+
options,
376377
);
377378

378379
this.webpackProcesses[platformData.platformNameLowerCase] = childProcess;
@@ -384,7 +385,7 @@ export class WebpackCompilerService
384385
private buildEnvData(
385386
platform: string,
386387
projectData: IProjectData,
387-
prepareData: IPrepareData
388+
prepareData: IPrepareData,
388389
) {
389390
const { env } = prepareData;
390391
const envData = Object.assign({}, env, { [platform.toLowerCase()]: true });
@@ -403,9 +404,9 @@ export class WebpackCompilerService
403404
__dirname,
404405
"..",
405406
"..",
406-
"nativescript-cli-lib.js"
407+
"nativescript-cli-lib.js",
407408
),
408-
}
409+
},
409410
);
410411

411412
envData.verbose = envData.verbose || this.$logger.isVerbose();
@@ -452,7 +453,7 @@ export class WebpackCompilerService
452453
envData: any,
453454
platformData: IPlatformData,
454455
projectData: IProjectData,
455-
prepareData: IPrepareData
456+
prepareData: IPrepareData,
456457
) {
457458
const envFlagNames = Object.keys(envData);
458459
const canSnapshot =
@@ -462,26 +463,26 @@ export class WebpackCompilerService
462463
if (!canSnapshot) {
463464
this.$logger.warn(
464465
"Stripping the snapshot flag. " +
465-
"Bear in mind that snapshot is only available in Android release builds."
466+
"Bear in mind that snapshot is only available in Android release builds.",
466467
);
467468
envFlagNames.splice(envFlagNames.indexOf("snapshot"), 1);
468469
} else if (this.$hostInfo.isWindows) {
469470
const minWebpackPluginWithWinSnapshotsVersion = "1.3.0";
470471
const installedWebpackPluginVersion =
471472
await this.$packageInstallationManager.getInstalledDependencyVersion(
472473
WEBPACK_PLUGIN_NAME,
473-
projectData.projectDir
474+
projectData.projectDir,
474475
);
475476
const hasWebpackPluginWithWinSnapshotsSupport =
476477
!!installedWebpackPluginVersion
477478
? semver.gte(
478479
semver.coerce(installedWebpackPluginVersion),
479-
minWebpackPluginWithWinSnapshotsVersion
480-
)
480+
minWebpackPluginWithWinSnapshotsVersion,
481+
)
481482
: true;
482483
if (!hasWebpackPluginWithWinSnapshotsSupport) {
483484
this.$errors.fail(
484-
`In order to generate Snapshots on Windows, please upgrade your Webpack plugin version (npm i ${WEBPACK_PLUGIN_NAME}@latest).`
485+
`In order to generate Snapshots on Windows, please upgrade your Webpack plugin version (npm i ${WEBPACK_PLUGIN_NAME}@latest).`,
485486
);
486487
}
487488
}
@@ -513,7 +514,7 @@ export class WebpackCompilerService
513514
allEmittedFiles: string[],
514515
chunkFiles: string[],
515516
nextHash: string,
516-
platform: string
517+
platform: string,
517518
) {
518519
const currentHash = this.getCurrentHotUpdateHash(allEmittedFiles);
519520

@@ -535,7 +536,7 @@ export class WebpackCompilerService
535536
? _.difference(allEmittedFiles, chunkFiles)
536537
: allEmittedFiles;
537538
const fallbackFiles = chunkFiles.concat(
538-
emittedHotUpdatesAndAssets.filter((f) => f.indexOf("hot-update") === -1)
539+
emittedHotUpdatesAndAssets.filter((f) => f.indexOf("hot-update") === -1),
539540
);
540541

541542
return {
@@ -548,7 +549,7 @@ export class WebpackCompilerService
548549
private getCurrentHotUpdateHash(emittedFiles: string[]) {
549550
let hotHash;
550551
const hotUpdateScripts = emittedFiles.filter((x) =>
551-
x.endsWith(".hot-update.js")
552+
x.endsWith(".hot-update.js"),
552553
);
553554
if (hotUpdateScripts && hotUpdateScripts.length) {
554555
// the hash is the same for each hot update in the current compilation
@@ -575,7 +576,7 @@ export class WebpackCompilerService
575576
message: IWebpackMessage,
576577
platformData: IPlatformData,
577578
projectData: IProjectData,
578-
prepareData: IPrepareData
579+
prepareData: IPrepareData,
579580
) {
580581
// handle new webpack hmr packets
581582
this.$logger.trace("Received message from webpack process:", message);
@@ -590,21 +591,21 @@ export class WebpackCompilerService
590591
path.join(
591592
platformData.appDestinationDirectoryPath,
592593
this.$options.hostProjectModuleName,
593-
asset
594-
)
594+
asset,
595+
),
595596
);
596597
const staleFiles = message.data.staleAssets.map((asset: string) =>
597598
path.join(
598599
platformData.appDestinationDirectoryPath,
599600
this.$options.hostProjectModuleName,
600-
asset
601-
)
601+
asset,
602+
),
602603
);
603604

604605
// extract last hash from emitted filenames
605606
const lastHash = (() => {
606607
const absoluteFileNameWithLastHash = files.find((fileName: string) =>
607-
fileName.endsWith("hot-update.js")
608+
fileName.endsWith("hot-update.js"),
608609
);
609610

610611
if (!absoluteFileNameWithLastHash) {

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)