mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-24 04:16:00 +08:00
Move polyfills to react-native
Summary:
React Native bundler (aka Metro Bundler) was splitted from the main codebase some time ago (now it lives [[https://github.com/facebook/metro-bundler|here]]). To make it more agnostic, polyfills will be moved out from it, so people who doesn't need them does not include them. However, RN will still need them, so the first step is to copy them back to RN so that we can provide them to Metro Bundler later.
We also include a way of passing the list of polyfills to include, as an `Array<string>`. The field is called `polyfills`, and defaults to the traditional list that is currently included in the package manager [see here](be1843cddc/packages/metro-bundler/src/defaults.js (L27-L37)).
In future commits, `metro-bundler` will be able to manage the `polyfills` array passed to it, and use it, instead of the pre-defined ones.
Reviewed By: davidaurelio
Differential Revision: D5381614
fbshipit-source-id: 749d536b781843ecb3067803e44398cd6df941f1
This commit is contained in:
committed by
Facebook Github Bot
parent
88fb45ddf9
commit
ad0fe15e2e
@@ -90,6 +90,12 @@ export type ConfigT = {
|
||||
*/
|
||||
getWorkerPath: () => ?string,
|
||||
|
||||
/**
|
||||
* An optional list of polyfills to include in the bundle. The list defaults
|
||||
* to a set of common polyfills for Number, String, Array, Object...
|
||||
*/
|
||||
polyfills: Array<string>,
|
||||
|
||||
/**
|
||||
* An optional function that can modify the code and source map of bundle
|
||||
* after the minifaction took place. (Function applied per module).
|
||||
@@ -171,6 +177,17 @@ const Config = {
|
||||
getSourceExts: () => [],
|
||||
getTransformModulePath: () => require.resolve('metro-bundler/src/transformer.js'),
|
||||
getTransformOptions: async () => ({}),
|
||||
polyfills: [
|
||||
require.resolve('../../Libraries/polyfills/Object.es6.js'),
|
||||
require.resolve('../../Libraries/polyfills/console.js'),
|
||||
require.resolve('../../Libraries/polyfills/error-guard.js'),
|
||||
require.resolve('../../Libraries/polyfills/Number.es6.js'),
|
||||
require.resolve('../../Libraries/polyfills/String.prototype.es6.js'),
|
||||
require.resolve('../../Libraries/polyfills/Array.prototype.es6.js'),
|
||||
require.resolve('../../Libraries/polyfills/Array.es6.js'),
|
||||
require.resolve('../../Libraries/polyfills/Object.es7.js'),
|
||||
require.resolve('../../Libraries/polyfills/babelHelpers.js'),
|
||||
],
|
||||
postMinifyProcess: x => x,
|
||||
postProcessModules: modules => modules,
|
||||
postProcessModulesForBuck: modules => modules,
|
||||
@@ -222,7 +239,6 @@ const Config = {
|
||||
},
|
||||
|
||||
loadFileCustom<TConfig: {}>(pathToConfig: string, defaults: TConfig): TConfig {
|
||||
//$FlowFixMe: necessary dynamic require
|
||||
const config: {} = require(pathToConfig);
|
||||
return {...defaults, ...config};
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user