Permalink
Browse files

Change `polyfills` to `getPolyfills` function for more configurability

Summary:
Changing the `polyfills` option to `getPolyfills({platform})` will let us return a different set of polyfills for each platform. See facebook/metro#25 for the motivation.
Closes #14943

Differential Revision: D5405878

Pulled By: mjesun

fbshipit-source-id: 908e49a286841f97655603d92d0fdfb000547510
  • Loading branch information...
ide authored and facebook-github-bot committed Jul 12, 2017
1 parent 999851a commit 9f87728f5d7807b324c9ea7f5f82bb0ac7585cbd
Showing with 4 additions and 3 deletions.
  1. +1 −1 local-cli/server/runServer.js
  2. +3 −2 local-cli/util/Config.js
@@ -157,7 +157,7 @@ function getPackagerServer(args, config) {
maxWorkers: args.maxWorkers,
platforms: defaultPlatforms.concat(args.platforms),
polyfillModuleNames: config.getPolyfillModuleNames(),
polyfills: config.polyfills,
getPolyfills: config.getPolyfills,
postMinifyProcess: config.postMinifyProcess,
postProcessModules: config.postProcessModules,
projectRoots: args.projectRoots,
View
@@ -94,7 +94,7 @@ export type ConfigT = {
* 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>,
getPolyfills: ({platform: string}) => Array<string>,
/**
* An optional function that can modify the code and source map of bundle
@@ -177,7 +177,7 @@ const Config = {
getSourceExts: () => [],
getTransformModulePath: () => require.resolve('metro-bundler/src/transformer.js'),
getTransformOptions: async () => ({}),
polyfills: [
getPolyfills: ({platform}) => [
require.resolve('../../Libraries/polyfills/Object.es6.js'),
require.resolve('../../Libraries/polyfills/console.js'),
require.resolve('../../Libraries/polyfills/error-guard.js'),
@@ -239,6 +239,7 @@ const Config = {
},
loadFileCustom<TConfig: {}>(pathToConfig: string, defaults: TConfig): TConfig {
// $FlowFixMe: necessary dynamic require
const config: {} = require(pathToConfig);
return {...defaults, ...config};
},

0 comments on commit 9f87728

Please sign in to comment.