@@ -64,15 +64,15 @@ export class WebpackCompilerService
64
64
private $mobileHelper : Mobile . IMobileHelper ,
65
65
private $cleanupService : ICleanupService ,
66
66
private $packageManager : IPackageManager ,
67
- private $packageInstallationManager : IPackageInstallationManager // private $sharedEventBus: ISharedEventBus
67
+ private $packageInstallationManager : IPackageInstallationManager , // private $sharedEventBus: ISharedEventBus
68
68
) {
69
69
super ( ) ;
70
70
}
71
71
72
72
public async compileWithWatch (
73
73
platformData : IPlatformData ,
74
74
projectData : IProjectData ,
75
- prepareData : IPrepareData
75
+ prepareData : IPrepareData ,
76
76
) : Promise < any > {
77
77
return new Promise ( async ( resolve , reject ) => {
78
78
if ( this . webpackProcesses [ platformData . platformNameLowerCase ] ) {
@@ -86,7 +86,7 @@ export class WebpackCompilerService
86
86
const childProcess = await this . startWebpackProcess (
87
87
platformData ,
88
88
projectData ,
89
- prepareData
89
+ prepareData ,
90
90
) ;
91
91
92
92
childProcess . stdout . on ( "data" , function ( data ) {
@@ -125,7 +125,7 @@ export class WebpackCompilerService
125
125
message as IWebpackMessage < IWebpackCompilation > ,
126
126
platformData ,
127
127
projectData ,
128
- prepareData
128
+ prepareData ,
129
129
) ;
130
130
}
131
131
@@ -153,7 +153,7 @@ export class WebpackCompilerService
153
153
message . emittedFiles ,
154
154
message . chunkFiles ,
155
155
message . hash ,
156
- platformData . platformNameLowerCase
156
+ platformData . platformNameLowerCase ,
157
157
) ;
158
158
} else {
159
159
result = {
@@ -166,21 +166,21 @@ export class WebpackCompilerService
166
166
path . join (
167
167
platformData . appDestinationDirectoryPath ,
168
168
this . $options . hostProjectModuleName ,
169
- file
170
- )
169
+ file ,
170
+ ) ,
171
171
) ;
172
172
const fallbackFiles = result . fallbackFiles . map ( ( file : string ) =>
173
173
path . join (
174
174
platformData . appDestinationDirectoryPath ,
175
175
this . $options . hostProjectModuleName ,
176
- file
177
- )
176
+ file ,
177
+ ) ,
178
178
) ;
179
179
180
180
const data = {
181
181
files,
182
182
hasOnlyHotUpdateFiles : files . every (
183
- ( f ) => f . indexOf ( "hot-update" ) > - 1
183
+ ( f ) => f . indexOf ( "hot-update" ) > - 1 ,
184
184
) ,
185
185
hmrData : {
186
186
hash : result . hash ,
@@ -204,23 +204,23 @@ export class WebpackCompilerService
204
204
205
205
childProcess . on ( "error" , ( err ) => {
206
206
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 } ` ,
208
208
) ;
209
209
delete this . webpackProcesses [ platformData . platformNameLowerCase ] ;
210
210
reject ( err ) ;
211
211
} ) ;
212
212
213
213
childProcess . on ( "close" , async ( arg : any ) => {
214
214
await this . $cleanupService . removeKillProcess (
215
- childProcess . pid . toString ( )
215
+ childProcess . pid . toString ( ) ,
216
216
) ;
217
217
218
218
const exitCode = typeof arg === "number" ? arg : arg && arg . code ;
219
219
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.` ,
221
221
) ;
222
222
const error : any = new Error (
223
- `Executing webpack failed with exit code ${ exitCode } .`
223
+ `Executing webpack failed with exit code ${ exitCode } .` ,
224
224
) ;
225
225
error . code = exitCode ;
226
226
delete this . webpackProcesses [ platformData . platformNameLowerCase ] ;
@@ -235,7 +235,7 @@ export class WebpackCompilerService
235
235
public async compileWithoutWatch (
236
236
platformData : IPlatformData ,
237
237
projectData : IProjectData ,
238
- prepareData : IPrepareData
238
+ prepareData : IPrepareData ,
239
239
) : Promise < void > {
240
240
return new Promise ( async ( resolve , reject ) => {
241
241
if ( this . webpackProcesses [ platformData . platformNameLowerCase ] ) {
@@ -247,20 +247,20 @@ export class WebpackCompilerService
247
247
const childProcess = await this . startWebpackProcess (
248
248
platformData ,
249
249
projectData ,
250
- prepareData
250
+ prepareData ,
251
251
) ;
252
252
253
253
childProcess . on ( "error" , ( err ) => {
254
254
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 } ` ,
256
256
) ;
257
257
delete this . webpackProcesses [ platformData . platformNameLowerCase ] ;
258
258
reject ( err ) ;
259
259
} ) ;
260
260
261
261
childProcess . on ( "close" , async ( arg : any ) => {
262
262
await this . $cleanupService . removeKillProcess (
263
- childProcess . pid . toString ( )
263
+ childProcess . pid . toString ( ) ,
264
264
) ;
265
265
266
266
delete this . webpackProcesses [ platformData . platformNameLowerCase ] ;
@@ -269,7 +269,7 @@ export class WebpackCompilerService
269
269
resolve ( ) ;
270
270
} else {
271
271
const error : any = new Error (
272
- `Executing webpack failed with exit code ${ exitCode } .`
272
+ `Executing webpack failed with exit code ${ exitCode } .` ,
273
273
) ;
274
274
error . code = exitCode ;
275
275
reject ( error ) ;
@@ -307,24 +307,24 @@ export class WebpackCompilerService
307
307
private async startWebpackProcess (
308
308
platformData : IPlatformData ,
309
309
projectData : IProjectData ,
310
- prepareData : IPrepareData
310
+ prepareData : IPrepareData ,
311
311
) : Promise < child_process . ChildProcess > {
312
312
if ( ! this . $fs . exists ( projectData . webpackConfigPath ) ) {
313
313
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 } .` ,
315
315
) ;
316
316
}
317
317
318
318
const envData = this . buildEnvData (
319
319
platformData . platformNameLowerCase ,
320
320
projectData ,
321
- prepareData
321
+ prepareData ,
322
322
) ;
323
323
const envParams = await this . buildEnvCommandLineParams (
324
324
envData ,
325
325
platformData ,
326
326
projectData ,
327
- prepareData
327
+ prepareData ,
328
328
) ;
329
329
const additionalNodeArgs =
330
330
semver . major ( process . version ) <= 8 ? [ "--harmony" ] : [ ] ;
@@ -355,8 +355,8 @@ export class WebpackCompilerService
355
355
stdio,
356
356
} ;
357
357
options . env = {
358
- NATIVESCRIPT_WEBPACK_ENV : JSON . stringify ( envData ) ,
359
358
...process . env ,
359
+ NATIVESCRIPT_WEBPACK_ENV : JSON . stringify ( envData ) ,
360
360
} ;
361
361
if ( this . $hostInfo . isWindows ) {
362
362
Object . assign ( options . env , { APPDATA : process . env . appData } ) ;
@@ -373,7 +373,7 @@ export class WebpackCompilerService
373
373
const childProcess = this . $childProcess . spawn (
374
374
process . execPath ,
375
375
args ,
376
- options
376
+ options ,
377
377
) ;
378
378
379
379
this . webpackProcesses [ platformData . platformNameLowerCase ] = childProcess ;
@@ -385,7 +385,7 @@ export class WebpackCompilerService
385
385
private buildEnvData (
386
386
platform : string ,
387
387
projectData : IProjectData ,
388
- prepareData : IPrepareData
388
+ prepareData : IPrepareData ,
389
389
) {
390
390
const { env } = prepareData ;
391
391
const envData = Object . assign ( { } , env , { [ platform . toLowerCase ( ) ] : true } ) ;
@@ -404,9 +404,9 @@ export class WebpackCompilerService
404
404
__dirname ,
405
405
".." ,
406
406
".." ,
407
- "nativescript-cli-lib.js"
407
+ "nativescript-cli-lib.js" ,
408
408
) ,
409
- }
409
+ } ,
410
410
) ;
411
411
412
412
envData . verbose = envData . verbose || this . $logger . isVerbose ( ) ;
@@ -453,7 +453,7 @@ export class WebpackCompilerService
453
453
envData : any ,
454
454
platformData : IPlatformData ,
455
455
projectData : IProjectData ,
456
- prepareData : IPrepareData
456
+ prepareData : IPrepareData ,
457
457
) {
458
458
const envFlagNames = Object . keys ( envData ) ;
459
459
const canSnapshot =
@@ -463,26 +463,26 @@ export class WebpackCompilerService
463
463
if ( ! canSnapshot ) {
464
464
this . $logger . warn (
465
465
"Stripping the snapshot flag. " +
466
- "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." ,
467
467
) ;
468
468
envFlagNames . splice ( envFlagNames . indexOf ( "snapshot" ) , 1 ) ;
469
469
} else if ( this . $hostInfo . isWindows ) {
470
470
const minWebpackPluginWithWinSnapshotsVersion = "1.3.0" ;
471
471
const installedWebpackPluginVersion =
472
472
await this . $packageInstallationManager . getInstalledDependencyVersion (
473
473
WEBPACK_PLUGIN_NAME ,
474
- projectData . projectDir
474
+ projectData . projectDir ,
475
475
) ;
476
476
const hasWebpackPluginWithWinSnapshotsSupport =
477
477
! ! installedWebpackPluginVersion
478
478
? semver . gte (
479
479
semver . coerce ( installedWebpackPluginVersion ) ,
480
- minWebpackPluginWithWinSnapshotsVersion
481
- )
480
+ minWebpackPluginWithWinSnapshotsVersion ,
481
+ )
482
482
: true ;
483
483
if ( ! hasWebpackPluginWithWinSnapshotsSupport ) {
484
484
this . $errors . fail (
485
- `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).` ,
486
486
) ;
487
487
}
488
488
}
@@ -514,7 +514,7 @@ export class WebpackCompilerService
514
514
allEmittedFiles : string [ ] ,
515
515
chunkFiles : string [ ] ,
516
516
nextHash : string ,
517
- platform : string
517
+ platform : string ,
518
518
) {
519
519
const currentHash = this . getCurrentHotUpdateHash ( allEmittedFiles ) ;
520
520
@@ -536,7 +536,7 @@ export class WebpackCompilerService
536
536
? _ . difference ( allEmittedFiles , chunkFiles )
537
537
: allEmittedFiles ;
538
538
const fallbackFiles = chunkFiles . concat (
539
- emittedHotUpdatesAndAssets . filter ( ( f ) => f . indexOf ( "hot-update" ) === - 1 )
539
+ emittedHotUpdatesAndAssets . filter ( ( f ) => f . indexOf ( "hot-update" ) === - 1 ) ,
540
540
) ;
541
541
542
542
return {
@@ -549,7 +549,7 @@ export class WebpackCompilerService
549
549
private getCurrentHotUpdateHash ( emittedFiles : string [ ] ) {
550
550
let hotHash ;
551
551
const hotUpdateScripts = emittedFiles . filter ( ( x ) =>
552
- x . endsWith ( ".hot-update.js" )
552
+ x . endsWith ( ".hot-update.js" ) ,
553
553
) ;
554
554
if ( hotUpdateScripts && hotUpdateScripts . length ) {
555
555
// the hash is the same for each hot update in the current compilation
@@ -576,7 +576,7 @@ export class WebpackCompilerService
576
576
message : IWebpackMessage ,
577
577
platformData : IPlatformData ,
578
578
projectData : IProjectData ,
579
- prepareData : IPrepareData
579
+ prepareData : IPrepareData ,
580
580
) {
581
581
// handle new webpack hmr packets
582
582
this . $logger . trace ( "Received message from webpack process:" , message ) ;
@@ -591,21 +591,21 @@ export class WebpackCompilerService
591
591
path . join (
592
592
platformData . appDestinationDirectoryPath ,
593
593
this . $options . hostProjectModuleName ,
594
- asset
595
- )
594
+ asset ,
595
+ ) ,
596
596
) ;
597
597
const staleFiles = message . data . staleAssets . map ( ( asset : string ) =>
598
598
path . join (
599
599
platformData . appDestinationDirectoryPath ,
600
600
this . $options . hostProjectModuleName ,
601
- asset
602
- )
601
+ asset ,
602
+ ) ,
603
603
) ;
604
604
605
605
// extract last hash from emitted filenames
606
606
const lastHash = ( ( ) => {
607
607
const absoluteFileNameWithLastHash = files . find ( ( fileName : string ) =>
608
- fileName . endsWith ( "hot-update.js" )
608
+ fileName . endsWith ( "hot-update.js" ) ,
609
609
) ;
610
610
611
611
if ( ! absoluteFileNameWithLastHash ) {
0 commit comments