Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit a77f2c4

Browse files
cpojerfacebook-github-bot
authored andcommittedJul 22, 2020
Create @react-native/polyfills package.
Summary: Changelog: [Internal] Reviewed By: GijsWeterings Differential Revision: D22625944 fbshipit-source-id: 1d97550c92115eb637da57e8f38c28e8139f3a8b
1 parent bbb7bef commit a77f2c4

16 files changed

+99
-51
lines changed
 

‎Libraries/vendor/core/ErrorUtils.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* @flow strict
99
*/
1010

11-
import type {ErrorUtilsT} from '../../polyfills/error-guard';
11+
import type {ErrorUtilsT} from '@react-native/polyfills/error-guard';
1212

1313
/**
1414
* The particular require runtime that we are using looks for a global

‎jest-preset.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ module.exports = {
2121
),
2222
},
2323
transformIgnorePatterns: [
24-
'node_modules/(?!(jest-)?react-native|@react-native-community)',
24+
'node_modules/(?!((jest-)?react-native|@react-native(-community)?)/)',
2525
],
2626
setupFiles: [require.resolve('./jest/setup.js')],
2727
testEnvironment: 'node',

‎jest.config.js

+37-40
Original file line numberDiff line numberDiff line change
@@ -3,49 +3,46 @@
33
*
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
6+
*
7+
* @format
68
*/
79

810
'use strict';
911

1012
module.exports = {
11-
'transform': {
12-
'^.+\\.(bmp|gif|jpg|jpeg|mp4|png|psd|svg|webp)$': '<rootDir>/jest/assetFileTransformer.js',
13-
'.*': './jest/preprocessor.js',
14-
},
15-
'setupFiles': [
16-
'./jest/setup.js',
17-
],
18-
'timers': 'fake',
19-
'testRegex': '/__tests__/.*-test\\.js$',
20-
'testPathIgnorePatterns': [
21-
'/node_modules/',
22-
'<rootDir>/template',
23-
'Libraries/Renderer',
24-
'RNTester/e2e',
25-
],
26-
'haste': {
27-
'defaultPlatform': 'ios',
28-
'platforms': [
29-
'ios',
30-
'android',
31-
],
32-
},
33-
'unmockedModulePathPatterns': [
34-
'node_modules/react/',
35-
'Libraries/Renderer',
36-
'promise',
37-
'source-map',
38-
'fastpath',
39-
'denodeify',
40-
'fbjs',
41-
],
42-
'testEnvironment': 'node',
43-
'collectCoverageFrom': [
44-
'Libraries/**/*.js',
45-
],
46-
'coveragePathIgnorePatterns': [
47-
'/__tests__/',
48-
'/vendor/',
49-
'<rootDir>/Libraries/react-native/',
50-
],
13+
transform: {
14+
'^.+\\.(bmp|gif|jpg|jpeg|mp4|png|psd|svg|webp)$':
15+
'<rootDir>/jest/assetFileTransformer.js',
16+
'.*': './jest/preprocessor.js',
17+
},
18+
setupFiles: ['./jest/setup.js'],
19+
timers: 'fake',
20+
testRegex: '/__tests__/.*-test\\.js$',
21+
testPathIgnorePatterns: [
22+
'/node_modules/',
23+
'<rootDir>/template',
24+
'Libraries/Renderer',
25+
'RNTester/e2e',
26+
],
27+
transformIgnorePatterns: ['node_modules/(?!@react-native/)'],
28+
haste: {
29+
defaultPlatform: 'ios',
30+
platforms: ['ios', 'android'],
31+
},
32+
unmockedModulePathPatterns: [
33+
'node_modules/react/',
34+
'Libraries/Renderer',
35+
'promise',
36+
'source-map',
37+
'fastpath',
38+
'denodeify',
39+
'fbjs',
40+
],
41+
testEnvironment: 'node',
42+
collectCoverageFrom: ['Libraries/**/*.js'],
43+
coveragePathIgnorePatterns: [
44+
'/__tests__/',
45+
'/vendor/',
46+
'<rootDir>/Libraries/react-native/',
47+
],
5148
};

‎jest/setup.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
const MockNativeMethods = jest.requireActual('./MockNativeMethods');
1313
const mockComponent = jest.requireActual('./mockComponent');
1414

15-
jest.requireActual('../Libraries/polyfills/Object.es7.js');
16-
jest.requireActual('../Libraries/polyfills/error-guard');
15+
jest.requireActual('@react-native/polyfills/Object.es7');
16+
jest.requireActual('@react-native/polyfills/error-guard');
1717

1818
global.__DEV__ = true;
1919

‎package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,10 @@
8585
"react": "0.0.0-experimental-aae83a4b9"
8686
},
8787
"dependencies": {
88-
"@react-native-community/cli": "^4.10.0",
8988
"@react-native-community/cli-platform-android": "^4.10.0",
9089
"@react-native-community/cli-platform-ios": "^4.10.0",
90+
"@react-native-community/cli": "^4.10.0",
91+
"@react-native/polyfills": "1.0.0",
9192
"abort-controller": "^3.0.0",
9293
"anser": "^1.4.9",
9394
"base64-js": "^1.1.2",

‎packages/polyfills/.npmignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
**/__mocks__/**
2+
**/__tests__/**
3+
BUCK

‎packages/polyfills/BUCK

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
load("@fbsource//tools/build_defs/third_party:yarn_defs.bzl", "yarn_workspace")
2+
3+
yarn_workspace(
4+
name = "yarn-workspace",
5+
srcs = glob(
6+
[
7+
"**/*.js",
8+
"**/*.json",
9+
],
10+
exclude = [
11+
"**/__fixtures__/**",
12+
"**/__flowtests__/**",
13+
"**/__mocks__/**",
14+
"**/__tests__/**",
15+
"**/node_modules/**",
16+
"**/node_modules/.bin/**",
17+
],
18+
),
19+
visibility = ["PUBLIC"],
20+
)
File renamed without changes.
File renamed without changes.
File renamed without changes.

‎packages/polyfills/index.js

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/**
2+
* Copyright (c) Facebook, Inc. and its affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*
7+
* @format
8+
*/
9+
10+
'use strict';
11+
12+
module.exports = () => [
13+
require.resolve('./console.js'),
14+
require.resolve('./error-guard.js'),
15+
require.resolve('./Object.es7.js'),
16+
];

‎packages/polyfills/package.json

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"name": "@react-native/polyfills",
3+
"version": "1.0.0",
4+
"description": "Polyfills for React Native.",
5+
"repository": {
6+
"type": "git",
7+
"url": "git@github.com:facebook/react-native.git"
8+
},
9+
"license": "MIT"
10+
}

‎rn-get-polyfills.js

+1-5
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,4 @@
99

1010
'use strict';
1111

12-
module.exports = () => [
13-
require.resolve('./Libraries/polyfills/console.js'),
14-
require.resolve('./Libraries/polyfills/error-guard.js'),
15-
require.resolve('./Libraries/polyfills/Object.es7.js'),
16-
];
12+
module.exports = require('@react-native/polyfills');

‎scripts/run-ci-e2e-tests.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ try {
8989

9090
const METRO_CONFIG = path.join(ROOT, 'metro.config.js');
9191
const RN_GET_POLYFILLS = path.join(ROOT, 'rn-get-polyfills.js');
92-
const RN_POLYFILLS_PATH = 'Libraries/polyfills/';
92+
const RN_POLYFILLS_PATH = 'packages/polyfills/';
9393
exec(`mkdir -p ${RN_POLYFILLS_PATH}`);
9494

9595
cp(METRO_CONFIG, '.');

‎yarn.lock

+5
Original file line numberDiff line numberDiff line change
@@ -1144,6 +1144,11 @@
11441144
"@react-native-community/eslint-plugin@file:packages/eslint-plugin-react-native-community":
11451145
version "1.1.0"
11461146

1147+
"@react-native/polyfills@1.0.0":
1148+
version "1.0.0"
1149+
resolved "https://registry.yarnpkg.com/@react-native/polyfills/-/polyfills-1.0.0.tgz#05bb0031533598f9458cf65a502b8df0eecae780"
1150+
integrity sha512-0jbp4RxjYopTsIdLl+/Fy2TiwVYHy4mgeu07DG4b/LyM0OS/+lPP5c9sbnt/AMlnF6qz2JRZpPpGw1eMNS6A4w==
1151+
11471152
"@reactions/component@^2.0.2":
11481153
version "2.0.2"
11491154
resolved "https://registry.yarnpkg.com/@reactions/component/-/component-2.0.2.tgz#40f8c1c2c37baabe57a0c944edb9310dc1ec6642"

0 commit comments

Comments
 (0)
Please sign in to comment.