60
RN_FB_DEV,
61
RN_FB_PROD,
62
RN_FB_PROFILING,
63
+ BROWSER_SCRIPT,
64
} = Bundles.bundleTypes;
65
66
const {getFilename} = Bundles;
94
const syncFBSourcePath = argv['sync-fbsource'];
95
const syncWWWPath = argv['sync-www'];
96
96
-const closureOptions = {
97
- compilation_level: 'SIMPLE',
98
- language_in: 'ECMASCRIPT_2015',
99
- language_out: 'ECMASCRIPT5_STRICT',
100
- env: 'CUSTOM',
101
- warning_level: 'QUIET',
102
- apply_input_source_maps: false,
103
- use_types_for_optimization: false,
104
- process_common_js_modules: false,
105
- rewrite_polyfills: false,
106
- inject_libraries: false,
107
-};
108
-
97
// Non-ES2015 stuff applied before closure compiler.
98
const babelPlugins = [
99
// These plugins filter out non-ES2015.
212
return `cjs`;
213
case NODE_ESM:
214
return `es`;
215
+ case BROWSER_SCRIPT:
216
+ return `iife`;
217
}
218
}
219
237
case RN_OSS_PROFILING:
238
case RN_FB_PROD:
239
case RN_FB_PROFILING:
240
+ case BROWSER_SCRIPT:
241
return true;
242
default:
243
throw new Error(`Unknown type: ${bundleType}`);
258
case RN_OSS_PROD:
259
case UMD_DEV:
260
case UMD_PROD:
261
+ case BROWSER_SCRIPT:
262
return false;
263
case FB_WWW_PROFILING:
264
case NODE_PROFILING:
363
isUMDBundle && entry === 'react-art' && commonjs(),
364
// Apply dead code elimination and/or minification.
365
isProduction &&
374
- closure(
375
- Object.assign({}, closureOptions, {
376
- // Don't let it create global variables in the browser.
377
- // https://github.com/facebook/react/issues/10909
378
- assume_function_wrapper: !isUMDBundle,
379
- renaming: !shouldStayReadable,
380
- })
381
- ),
366
+ closure({
367
+ compilation_level: 'SIMPLE',
368
+ language_in: 'ECMASCRIPT_2015',
369
+ language_out:
370
+ bundleType === BROWSER_SCRIPT ? 'ECMASCRIPT5' : 'ECMASCRIPT5_STRICT',
371
+ env: 'CUSTOM',
372
+ warning_level: 'QUIET',
373
+ apply_input_source_maps: false,
374
+ use_types_for_optimization: false,
375
+ process_common_js_modules: false,
376
+ rewrite_polyfills: false,
377
+ inject_libraries: false,
378
+
379
+ // Don't let it create global variables in the browser.
380
+ // https://github.com/facebook/react/issues/10909
381
+ assume_function_wrapper: !isUMDBundle,
382
+ renaming: !shouldStayReadable,
383
+ }),
384
// HACK to work around the fact that Rollup isn't removing unused, pure-module imports.
385
// Note that this plugin must be called after closure applies DCE.
386
isProduction && stripUnusedImports(pureExternalModules),
584
},
585
};
586
const mainOutputPath = Packaging.getBundleOutputPath(
587
+ bundle,
588
bundleType,
589
filename,
590
packageName
727
[bundle, RN_OSS_PROFILING],
728
[bundle, RN_FB_DEV],
729
[bundle, RN_FB_PROD],
727
- [bundle, RN_FB_PROFILING]
730
+ [bundle, RN_FB_PROFILING],
731
+ [bundle, BROWSER_SCRIPT]
732
);
733
}
734