Create `@react-native/polyfills` package.

Summary: Changelog: [Internal]

Reviewed By: GijsWeterings

Differential Revision: D22625944

fbshipit-source-id: 1d97550c92115eb637da57e8f38c28e8139f3a8b
This commit is contained in:
Christoph Nakazawa 2020-07-22 02:59:15 -07:00 коммит произвёл Facebook GitHub Bot
Родитель bbb7bef539
Коммит a77f2c40d1
16 изменённых файлов: 99 добавлений и 51 удалений

2
Libraries/vendor/core/ErrorUtils.js поставляемый
Просмотреть файл

@ -8,7 +8,7 @@
* @flow strict * @flow strict
*/ */
import type {ErrorUtilsT} from '../../polyfills/error-guard'; import type {ErrorUtilsT} from '@react-native/polyfills/error-guard';
/** /**
* The particular require runtime that we are using looks for a global * The particular require runtime that we are using looks for a global

Просмотреть файл

@ -21,7 +21,7 @@ module.exports = {
), ),
}, },
transformIgnorePatterns: [ transformIgnorePatterns: [
'node_modules/(?!(jest-)?react-native|@react-native-community)', 'node_modules/(?!((jest-)?react-native|@react-native(-community)?)/)',
], ],
setupFiles: [require.resolve('./jest/setup.js')], setupFiles: [require.resolve('./jest/setup.js')],
testEnvironment: 'node', testEnvironment: 'node',

Просмотреть файл

@ -3,49 +3,46 @@
* *
* This source code is licensed under the MIT license found in the * This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree. * LICENSE file in the root directory of this source tree.
*
* @format
*/ */
'use strict'; 'use strict';
module.exports = { module.exports = {
'transform': { transform: {
'^.+\\.(bmp|gif|jpg|jpeg|mp4|png|psd|svg|webp)$': '<rootDir>/jest/assetFileTransformer.js', '^.+\\.(bmp|gif|jpg|jpeg|mp4|png|psd|svg|webp)$':
'.*': './jest/preprocessor.js', '<rootDir>/jest/assetFileTransformer.js',
}, '.*': './jest/preprocessor.js',
'setupFiles': [ },
'./jest/setup.js', setupFiles: ['./jest/setup.js'],
], timers: 'fake',
'timers': 'fake', testRegex: '/__tests__/.*-test\\.js$',
'testRegex': '/__tests__/.*-test\\.js$', testPathIgnorePatterns: [
'testPathIgnorePatterns': [ '/node_modules/',
'/node_modules/', '<rootDir>/template',
'<rootDir>/template', 'Libraries/Renderer',
'Libraries/Renderer', 'RNTester/e2e',
'RNTester/e2e', ],
], transformIgnorePatterns: ['node_modules/(?!@react-native/)'],
'haste': { haste: {
'defaultPlatform': 'ios', defaultPlatform: 'ios',
'platforms': [ platforms: ['ios', 'android'],
'ios', },
'android', unmockedModulePathPatterns: [
], 'node_modules/react/',
}, 'Libraries/Renderer',
'unmockedModulePathPatterns': [ 'promise',
'node_modules/react/', 'source-map',
'Libraries/Renderer', 'fastpath',
'promise', 'denodeify',
'source-map', 'fbjs',
'fastpath', ],
'denodeify', testEnvironment: 'node',
'fbjs', collectCoverageFrom: ['Libraries/**/*.js'],
], coveragePathIgnorePatterns: [
'testEnvironment': 'node', '/__tests__/',
'collectCoverageFrom': [ '/vendor/',
'Libraries/**/*.js', '<rootDir>/Libraries/react-native/',
], ],
'coveragePathIgnorePatterns': [
'/__tests__/',
'/vendor/',
'<rootDir>/Libraries/react-native/',
],
}; };

Просмотреть файл

@ -12,8 +12,8 @@
const MockNativeMethods = jest.requireActual('./MockNativeMethods'); const MockNativeMethods = jest.requireActual('./MockNativeMethods');
const mockComponent = jest.requireActual('./mockComponent'); const mockComponent = jest.requireActual('./mockComponent');
jest.requireActual('../Libraries/polyfills/Object.es7.js'); jest.requireActual('@react-native/polyfills/Object.es7');
jest.requireActual('../Libraries/polyfills/error-guard'); jest.requireActual('@react-native/polyfills/error-guard');
global.__DEV__ = true; global.__DEV__ = true;

Просмотреть файл

@ -85,9 +85,10 @@
"react": "0.0.0-experimental-aae83a4b9" "react": "0.0.0-experimental-aae83a4b9"
}, },
"dependencies": { "dependencies": {
"@react-native-community/cli": "^4.10.0",
"@react-native-community/cli-platform-android": "^4.10.0", "@react-native-community/cli-platform-android": "^4.10.0",
"@react-native-community/cli-platform-ios": "^4.10.0", "@react-native-community/cli-platform-ios": "^4.10.0",
"@react-native-community/cli": "^4.10.0",
"@react-native/polyfills": "1.0.0",
"abort-controller": "^3.0.0", "abort-controller": "^3.0.0",
"anser": "^1.4.9", "anser": "^1.4.9",
"base64-js": "^1.1.2", "base64-js": "^1.1.2",

Просмотреть файл

@ -0,0 +1,3 @@
**/__mocks__/**
**/__tests__/**
BUCK

20
packages/polyfills/BUCK Normal file
Просмотреть файл

@ -0,0 +1,20 @@
load("@fbsource//tools/build_defs/third_party:yarn_defs.bzl", "yarn_workspace")
yarn_workspace(
name = "yarn-workspace",
srcs = glob(
[
"**/*.js",
"**/*.json",
],
exclude = [
"**/__fixtures__/**",
"**/__flowtests__/**",
"**/__mocks__/**",
"**/__tests__/**",
"**/node_modules/**",
"**/node_modules/.bin/**",
],
),
visibility = ["PUBLIC"],
)

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

@ -0,0 +1,16 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
*/
'use strict';
module.exports = () => [
require.resolve('./console.js'),
require.resolve('./error-guard.js'),
require.resolve('./Object.es7.js'),
];

Просмотреть файл

@ -0,0 +1,10 @@
{
"name": "@react-native/polyfills",
"version": "1.0.0",
"description": "Polyfills for React Native.",
"repository": {
"type": "git",
"url": "git@github.com:facebook/react-native.git"
},
"license": "MIT"
}

Просмотреть файл

@ -9,8 +9,4 @@
'use strict'; 'use strict';
module.exports = () => [ module.exports = require('@react-native/polyfills');
require.resolve('./Libraries/polyfills/console.js'),
require.resolve('./Libraries/polyfills/error-guard.js'),
require.resolve('./Libraries/polyfills/Object.es7.js'),
];

Просмотреть файл

@ -89,7 +89,7 @@ try {
const METRO_CONFIG = path.join(ROOT, 'metro.config.js'); const METRO_CONFIG = path.join(ROOT, 'metro.config.js');
const RN_GET_POLYFILLS = path.join(ROOT, 'rn-get-polyfills.js'); const RN_GET_POLYFILLS = path.join(ROOT, 'rn-get-polyfills.js');
const RN_POLYFILLS_PATH = 'Libraries/polyfills/'; const RN_POLYFILLS_PATH = 'packages/polyfills/';
exec(`mkdir -p ${RN_POLYFILLS_PATH}`); exec(`mkdir -p ${RN_POLYFILLS_PATH}`);
cp(METRO_CONFIG, '.'); cp(METRO_CONFIG, '.');

Просмотреть файл

@ -1144,6 +1144,11 @@
"@react-native-community/eslint-plugin@file:packages/eslint-plugin-react-native-community": "@react-native-community/eslint-plugin@file:packages/eslint-plugin-react-native-community":
version "1.1.0" version "1.1.0"
"@react-native/polyfills@1.0.0":
version "1.0.0"
resolved "https://registry.yarnpkg.com/@react-native/polyfills/-/polyfills-1.0.0.tgz#05bb0031533598f9458cf65a502b8df0eecae780"
integrity sha512-0jbp4RxjYopTsIdLl+/Fy2TiwVYHy4mgeu07DG4b/LyM0OS/+lPP5c9sbnt/AMlnF6qz2JRZpPpGw1eMNS6A4w==
"@reactions/component@^2.0.2": "@reactions/component@^2.0.2":
version "2.0.2" version "2.0.2"
resolved "https://registry.yarnpkg.com/@reactions/component/-/component-2.0.2.tgz#40f8c1c2c37baabe57a0c944edb9310dc1ec6642" resolved "https://registry.yarnpkg.com/@reactions/component/-/component-2.0.2.tgz#40f8c1c2c37baabe57a0c944edb9310dc1ec6642"