@@ -16,11 +16,14 @@ export interface BundleStreamFactory {
1616 ( src : Readable , name : string ) : Stream ;
1717}
1818
19+ export type BundleType = "style" | "script" ;
20+
1921/**
2022 * Represents a bundle to be bundled, assists in process.
2123 */
2224export class Bundle {
2325 public readonly name : string ;
26+ private readonly type : BundleType ;
2427 private readonly initialPaths : readonly string [ ] ;
2528 private remainingPaths : string [ ] ;
2629 private readonly files : Map < string , Vinyl > = new Map ( ) ;
@@ -34,11 +37,13 @@ export class Bundle {
3437 */
3538 constructor (
3639 name : string ,
40+ type : BundleType ,
3741 paths : string [ ] ,
3842 streamFactory : BundleStreamFactory ,
3943 logger : Logger
4044 ) {
4145 this . name = name ;
46+ this . type = type ;
4247 this . initialPaths = paths . slice ( 0 ) ;
4348 this . remainingPaths = paths . slice ( 0 ) ;
4449 this . streamFactory = streamFactory ;
@@ -47,6 +52,7 @@ export class Bundle {
4752 "Bundle tracker created" ,
4853 {
4954 bundleName : this . name ,
55+ type : this . type ,
5056 files : this . initialPaths ,
5157 }
5258 ) ;
@@ -69,6 +75,7 @@ export class Bundle {
6975 "Retaining file for later bundling" ,
7076 {
7177 bundleName : this . name ,
78+ type : this . type ,
7279 path : file . path ,
7380 }
7481 ) ;
@@ -78,6 +85,7 @@ export class Bundle {
7885 "Ignoring unused file" ,
7986 {
8087 bundleName : this . name ,
88+ type : this . type ,
8189 path : file . path ,
8290 }
8391 ) ;
@@ -97,10 +105,11 @@ export class Bundle {
97105 "Creating bundle stream" ,
98106 {
99107 bundleName : this . name ,
108+ type : this . type ,
100109 inFiles : this . initialPaths ,
101110 }
102111 ) ;
103- this . logger . info ( "Started bundling" , { bundleName : this . name } ) ;
112+ this . logger . info ( "Started bundling" , { bundleName : this . name , type : this . type } ) ;
104113 const chunks = await getStream . array (
105114 this . streamFactory (
106115 intoStream . object ( orderedFiles ) ,
@@ -115,6 +124,7 @@ export class Bundle {
115124 "Chunk returned by bundle stream is not a Vinyl instance" ,
116125 {
117126 bundleName : this . name ,
127+ type : this . type ,
118128 chunk,
119129 }
120130 ) ;
@@ -123,8 +133,8 @@ export class Bundle {
123133 }
124134
125135 // Perform bundling, and collect results
126- this . logger . trace ( "Bundle stream completed" , { bundleName : this . name } ) ;
127- this . logger . info ( "Finished bundling" , { bundleName : this . name } ) ;
136+ this . logger . trace ( "Bundle stream completed" , { bundleName : this . name , type : this . type } ) ;
137+ this . logger . info ( "Finished bundling" , { bundleName : this . name , type : this . type } ) ;
128138
129139 return chunks as Vinyl [ ] ;
130140 }
0 commit comments