@@ -39,10 +39,12 @@ const {
3939 UMD_PROD ,
4040 NODE_DEV ,
4141 NODE_PROD ,
42+ NODE_PROFILING ,
4243 FB_WWW_DEV ,
4344 FB_WWW_PROD ,
4445 RN_OSS_DEV ,
4546 RN_OSS_PROD ,
47+ RN_OSS_PROFILING ,
4648 RN_FB_DEV ,
4749 RN_FB_PROD ,
4850} = Bundles . bundleTypes ;
@@ -95,6 +97,7 @@ function getBabelConfig(updateBabelOptions, bundleType, filename) {
9597 } ) ;
9698 case RN_OSS_DEV :
9799 case RN_OSS_PROD :
100+ case RN_OSS_PROFILING :
98101 case RN_FB_DEV :
99102 case RN_FB_PROD :
100103 return Object . assign ( { } , options , {
@@ -107,6 +110,7 @@ function getBabelConfig(updateBabelOptions, bundleType, filename) {
107110 case UMD_PROD :
108111 case NODE_DEV :
109112 case NODE_PROD :
113+ case NODE_PROFILING :
110114 return Object . assign ( { } , options , {
111115 plugins : options . plugins . concat ( [
112116 // Use object-assign polyfill in open source
@@ -152,10 +156,12 @@ function getFormat(bundleType) {
152156 return `umd` ;
153157 case NODE_DEV :
154158 case NODE_PROD :
159+ case NODE_PROFILING :
155160 case FB_WWW_DEV :
156161 case FB_WWW_PROD :
157162 case RN_OSS_DEV :
158163 case RN_OSS_PROD :
164+ case RN_OSS_PROFILING :
159165 case RN_FB_DEV :
160166 case RN_FB_PROD :
161167 return `cjs` ;
@@ -174,6 +180,8 @@ function getFilename(name, globalName, bundleType) {
174180 return `${ name } .development.js` ;
175181 case NODE_PROD :
176182 return `${ name } .production.min.js` ;
183+ case NODE_PROFILING :
184+ return `${ name } .profiling.min.js` ;
177185 case FB_WWW_DEV :
178186 case RN_OSS_DEV :
179187 case RN_FB_DEV :
@@ -182,6 +190,8 @@ function getFilename(name, globalName, bundleType) {
182190 case RN_OSS_PROD :
183191 case RN_FB_PROD :
184192 return `${ globalName } -prod.js` ;
193+ case RN_OSS_PROFILING :
194+ return `${ globalName } -profiling.js` ;
185195 }
186196}
187197
@@ -195,15 +205,38 @@ function isProductionBundleType(bundleType) {
195205 return false ;
196206 case UMD_PROD :
197207 case NODE_PROD :
208+ case NODE_PROFILING :
198209 case FB_WWW_PROD :
199210 case RN_OSS_PROD :
211+ case RN_OSS_PROFILING :
200212 case RN_FB_PROD :
201213 return true ;
202214 default :
203215 throw new Error ( `Unknown type: ${ bundleType } ` ) ;
204216 }
205217}
206218
219+ function isProfilingBundleType ( bundleType ) {
220+ switch ( bundleType ) {
221+ case FB_WWW_DEV :
222+ case FB_WWW_PROD :
223+ case NODE_DEV :
224+ case NODE_PROD :
225+ case RN_FB_DEV :
226+ case RN_FB_PROD :
227+ case RN_OSS_DEV :
228+ case RN_OSS_PROD :
229+ case UMD_DEV :
230+ case UMD_PROD :
231+ return false ;
232+ case NODE_PROFILING :
233+ case RN_OSS_PROFILING :
234+ return true ;
235+ default :
236+ throw new Error ( `Unknown type: ${ bundleType } ` ) ;
237+ }
238+ }
239+
207240function getPlugins (
208241 entry ,
209242 externals ,
@@ -218,11 +251,13 @@ function getPlugins(
218251 const findAndRecordErrorCodes = extractErrorCodes ( errorCodeOpts ) ;
219252 const forks = Modules . getForks ( bundleType , entry , moduleType ) ;
220253 const isProduction = isProductionBundleType ( bundleType ) ;
254+ const isProfiling = isProfilingBundleType ( bundleType ) ;
221255 const isInGlobalScope = bundleType === UMD_DEV || bundleType === UMD_PROD ;
222256 const isFBBundle = bundleType === FB_WWW_DEV || bundleType === FB_WWW_PROD ;
223257 const isRNBundle =
224258 bundleType === RN_OSS_DEV ||
225259 bundleType === RN_OSS_PROD ||
260+ bundleType === RN_OSS_PROFILING ||
226261 bundleType === RN_FB_DEV ||
227262 bundleType === RN_FB_PROD ;
228263 const shouldStayReadable = isFBBundle || isRNBundle || forcePrettyOutput ;
@@ -255,6 +290,7 @@ function getPlugins(
255290 // Turn __DEV__ and process.env checks into constants.
256291 replace ( {
257292 __DEV__ : isProduction ? 'false' : 'true' ,
293+ __PROFILE__ : isProfiling || ! isProduction ? 'true' : 'false' ,
258294 'process.env.NODE_ENV' : isProduction ? "'production'" : "'development'" ,
259295 } ) ,
260296 // We still need CommonJS for external deps like object-assign.
@@ -508,10 +544,12 @@ async function buildEverything() {
508544 await createBundle ( bundle , UMD_PROD ) ;
509545 await createBundle ( bundle , NODE_DEV ) ;
510546 await createBundle ( bundle , NODE_PROD ) ;
547+ await createBundle ( bundle , NODE_PROFILING ) ;
511548 await createBundle ( bundle , FB_WWW_DEV ) ;
512549 await createBundle ( bundle , FB_WWW_PROD ) ;
513550 await createBundle ( bundle , RN_OSS_DEV ) ;
514551 await createBundle ( bundle , RN_OSS_PROD ) ;
552+ await createBundle ( bundle , RN_OSS_PROFILING ) ;
515553 await createBundle ( bundle , RN_FB_DEV ) ;
516554 await createBundle ( bundle , RN_FB_PROD ) ;
517555 }
0 commit comments