mirror of
https://github.com/status-im/react-native.git
synced 2025-01-12 10:34:57 +00:00
Move Array<string> to $ReadOnlyArray<string>. Separate polyfill list into a file.
Summary: Move the returned type of `getPolyfills` from a standard `Array` to a read-only one, so that we make sure the array is not modified once created. Also, refactor the list of polyfills included by default to a generic, central file, then require it both from the CLI utils as well as the development server. Reviewed By: jeanlauliac Differential Revision: D5406553 fbshipit-source-id: ab980288bb1c625338de469da77dd6fc70bcedbc
This commit is contained in:
parent
cad2d9b072
commit
6dd9d16833
@ -152,12 +152,12 @@ function getPackagerServer(args, config) {
|
||||
blacklistRE: config.getBlacklistRE(),
|
||||
cacheVersion: '3',
|
||||
extraNodeModules: config.extraNodeModules,
|
||||
getPolyfills: config.getPolyfills,
|
||||
getTransformOptions: config.getTransformOptions,
|
||||
hasteImpl: config.hasteImpl,
|
||||
maxWorkers: args.maxWorkers,
|
||||
platforms: defaultPlatforms.concat(args.platforms),
|
||||
polyfillModuleNames: config.getPolyfillModuleNames(),
|
||||
getPolyfills: config.getPolyfills,
|
||||
postMinifyProcess: config.postMinifyProcess,
|
||||
postProcessModules: config.postProcessModules,
|
||||
projectRoots: args.projectRoots,
|
||||
|
@ -13,6 +13,7 @@
|
||||
const blacklist = require('metro-bundler/src/blacklist');
|
||||
const findSymlinksPaths = require('./findSymlinksPaths');
|
||||
const fs = require('fs');
|
||||
const getPolyfills = require('../../rn-get-polyfills');
|
||||
const invariant = require('fbjs/lib/invariant');
|
||||
const path = require('path');
|
||||
|
||||
@ -94,7 +95,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...
|
||||
*/
|
||||
getPolyfills: ({platform: string}) => Array<string>,
|
||||
getPolyfills: ({platform: ?string}) => $ReadOnlyArray<string>,
|
||||
|
||||
/**
|
||||
* An optional function that can modify the code and source map of bundle
|
||||
@ -177,17 +178,7 @@ const Config = {
|
||||
getSourceExts: () => [],
|
||||
getTransformModulePath: () => require.resolve('metro-bundler/src/transformer.js'),
|
||||
getTransformOptions: async () => ({}),
|
||||
getPolyfills: ({platform}) => [
|
||||
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'),
|
||||
],
|
||||
getPolyfills,
|
||||
postMinifyProcess: x => x,
|
||||
postProcessModules: modules => modules,
|
||||
postProcessModulesForBuck: modules => modules,
|
||||
|
@ -99,6 +99,7 @@
|
||||
"jest-preset.json",
|
||||
"jest",
|
||||
"lib",
|
||||
"rn-get-polyfills.js",
|
||||
"setupBabel.js",
|
||||
"Libraries",
|
||||
"LICENSE",
|
||||
|
@ -8,6 +8,8 @@
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
const getPolyfills = require('./rn-get-polyfills');
|
||||
|
||||
/**
|
||||
* This cli config is needed for development purposes, e.g. for running
|
||||
* integration tests during local development or on CI services.
|
||||
@ -16,4 +18,5 @@ module.exports = {
|
||||
extraNodeModules: {
|
||||
'react-native': __dirname,
|
||||
},
|
||||
getPolyfills,
|
||||
};
|
||||
|
23
rn-get-polyfills.js
Normal file
23
rn-get-polyfills.js
Normal file
@ -0,0 +1,23 @@
|
||||
/**
|
||||
* Copyright (c) 2013-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
module.exports = () => [
|
||||
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'),
|
||||
];
|
Loading…
x
Reference in New Issue
Block a user