@@ -57,7 +57,6 @@ async function buildBundle(
5757 } ,
5858 config : ConfigT ,
5959 output = outputBundle ,
60- packagerInstance ,
6160) {
6261 // This is used by a bazillion of npm modules we don't control so we don't
6362 // have other choice than defining it as an env variable here.
@@ -76,60 +75,53 @@ async function buildBundle(
7675 platform : args . platform ,
7776 } ;
7877
79- // If a packager instance was not provided, then just create one for this
80- // bundle command and close it down afterwards.
81- var shouldClosePackager = false ;
82- if ( ! packagerInstance ) {
83- const assetExts = ( config . getAssetExts && config . getAssetExts ( ) ) || [ ] ;
84- const sourceExts = ( config . getSourceExts && config . getSourceExts ( ) ) || [ ] ;
85- const platforms = ( config . getPlatforms && config . getPlatforms ( ) ) || [ ] ;
86-
87- const transformModulePath = args . transformer
88- ? path . resolve ( args . transformer )
89- : config . getTransformModulePath ( ) ;
90-
91- const providesModuleNodeModules =
92- typeof config . getProvidesModuleNodeModules === 'function'
93- ? config . getProvidesModuleNodeModules ( )
94- : defaultProvidesModuleNodeModules ;
95-
96- const terminal = new Terminal ( process . stdout ) ;
97- const options = {
98- assetExts : defaultAssetExts . concat ( assetExts ) ,
99- assetRegistryPath : ASSET_REGISTRY_PATH ,
100- blacklistRE : config . getBlacklistRE ( ) ,
101- extraNodeModules : config . extraNodeModules ,
102- getModulesRunBeforeMainModule : config . getModulesRunBeforeMainModule ,
103- getPolyfills : config . getPolyfills ,
104- getTransformOptions : config . getTransformOptions ,
105- globalTransformCache : null ,
106- hasteImpl : config . hasteImpl ,
107- maxWorkers : args . maxWorkers ,
108- platforms : defaultPlatforms . concat ( platforms ) ,
109- postMinifyProcess : config . postMinifyProcess ,
110- postProcessModules : config . postProcessModules ,
111- postProcessBundleSourcemap : config . postProcessBundleSourcemap ,
112- projectRoots : config . getProjectRoots ( ) ,
113- providesModuleNodeModules : providesModuleNodeModules ,
114- resetCache : args . resetCache ,
115- reporter : new TerminalReporter ( terminal ) ,
116- sourceExts : defaultSourceExts . concat ( sourceExts ) ,
117- transformCache : TransformCaching . useTempDir ( ) ,
118- transformModulePath : transformModulePath ,
119- watch : false ,
120- workerPath : config . getWorkerPath && config . getWorkerPath ( ) ,
121- } ;
122-
123- packagerInstance = new Server ( options ) ;
124- shouldClosePackager = true ;
125- }
78+ const assetExts = ( config . getAssetExts && config . getAssetExts ( ) ) || [ ] ;
79+ const sourceExts = ( config . getSourceExts && config . getSourceExts ( ) ) || [ ] ;
80+ const platforms = ( config . getPlatforms && config . getPlatforms ( ) ) || [ ] ;
81+
82+ const transformModulePath = args . transformer
83+ ? path . resolve ( args . transformer )
84+ : config . getTransformModulePath ( ) ;
85+
86+ const providesModuleNodeModules =
87+ typeof config . getProvidesModuleNodeModules === 'function'
88+ ? config . getProvidesModuleNodeModules ( )
89+ : defaultProvidesModuleNodeModules ;
90+
91+ const terminal = new Terminal ( process . stdout ) ;
92+
93+ const server = new Server ( {
94+ assetExts : defaultAssetExts . concat ( assetExts ) ,
95+ assetRegistryPath : ASSET_REGISTRY_PATH ,
96+ blacklistRE : config . getBlacklistRE ( ) ,
97+ extraNodeModules : config . extraNodeModules ,
98+ getModulesRunBeforeMainModule : config . getModulesRunBeforeMainModule ,
99+ getPolyfills : config . getPolyfills ,
100+ getTransformOptions : config . getTransformOptions ,
101+ globalTransformCache : null ,
102+ hasteImpl : config . hasteImpl ,
103+ maxWorkers : args . maxWorkers ,
104+ platforms : defaultPlatforms . concat ( platforms ) ,
105+ postMinifyProcess : config . postMinifyProcess ,
106+ postProcessModules : config . postProcessModules ,
107+ postProcessBundleSourcemap : config . postProcessBundleSourcemap ,
108+ projectRoots : config . getProjectRoots ( ) ,
109+ providesModuleNodeModules : providesModuleNodeModules ,
110+ resetCache : args . resetCache ,
111+ reporter : new TerminalReporter ( terminal ) ,
112+ sourceExts : defaultSourceExts . concat ( sourceExts ) ,
113+ transformCache : TransformCaching . useTempDir ( ) ,
114+ transformModulePath : transformModulePath ,
115+ watch : false ,
116+ workerPath : config . getWorkerPath && config . getWorkerPath ( ) ,
117+ } ) ;
126118
127- const bundle = await output . build ( packagerInstance , requestOpts ) ;
119+ const bundle = await output . build ( server , requestOpts ) ;
128120
129121 await output . save ( bundle , args , log ) ;
130122
131123 // Save the assets of the bundle
132- const outputAssets = await packagerInstance . getAssets ( {
124+ const outputAssets = await server . getAssets ( {
133125 ...Server . DEFAULT_BUNDLE_OPTIONS ,
134126 ...requestOpts ,
135127 bundleType : 'todo' ,
@@ -142,9 +134,7 @@ async function buildBundle(
142134 args . assetsDest ,
143135 ) ;
144136
145- if ( shouldClosePackager ) {
146- packagerInstance . end ( ) ;
147- }
137+ server . end ( ) ;
148138
149139 return assets ;
150140}
0 commit comments