Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds react-events package for internal testing #15150

Merged
merged 3 commits into from
Mar 19, 2019
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions packages/react-events/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# `react-events`

This is package is intended for use with the experimental React events API.
16 changes: 16 additions & 0 deletions packages/react-events/index.js
Original file line number Diff line number Diff line change
@@ -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.
*
* @flow
*/

'use strict';

const ReactEvents = require('./src/ReactEvents');

// TODO: decide on the top-level export form.
// This is hacky but makes it work with both Rollup and Jest.
module.exports = ReactEvents.default || ReactEvents;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we've been doing this on our new packages. See: https://github.com/facebook/react/blob/master/packages/react-cache/index.js

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah good catch

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed! #15152

7 changes: 7 additions & 0 deletions packages/react-events/npm/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
'use strict';

if (process.env.NODE_ENV === 'production') {
module.exports = require('./cjs/react-events.production.min.js');
} else {
module.exports = require('./cjs/react-events.development.js');
}
35 changes: 35 additions & 0 deletions packages/react-events/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"name": "react-events",
"description": "React is a JavaScript library for building user interfaces.",
"keywords": [
"react"
],
"version": "16.8.4",
trueadm marked this conversation as resolved.
Show resolved Hide resolved
"homepage": "https://reactjs.org/",
"bugs": "https://github.com/facebook/react/issues",
"license": "MIT",
"files": [
"LICENSE",
"README.md",
"build-info.json",
"cjs/",
"umd/"
],
"main": "index.js",
"repository": {
"type": "git",
"url": "https://github.com/facebook/react.git",
"directory": "packages/react"
},
"engines": {
"node": ">=0.10.0"
},
"dependencies": {
"loose-envify": "^1.1.0"
},
"browserify": {
"transform": [
"loose-envify"
]
}
}
25 changes: 25 additions & 0 deletions packages/react-events/src/ReactEvents.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/**
* 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.
*
* @flow
*/

import {
REACT_EVENT_TARGET_TYPE,
REACT_EVENT_TARGET_TOUCH_HIT,
} from 'shared/ReactSymbols';
import type {ReactEventTarget} from 'shared/ReactTypes';

const TouchHitTarget: ReactEventTarget = {
$$typeof: REACT_EVENT_TARGET_TYPE,
type: REACT_EVENT_TARGET_TOUCH_HIT,
};

const ReactEvents = {
TouchHitTarget,
};

export default ReactEvents;
5 changes: 5 additions & 0 deletions packages/shared/ReactSymbols.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ export const REACT_EVENT_TARGET_TYPE = hasSymbol
? Symbol.for('react.event_target')
: 0xead6;

// React event targets
export const REACT_EVENT_TARGET_TOUCH_HIT = hasSymbol
? Symbol.for('react.event_target.touch_hit')
: 0xead7;

const MAYBE_ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
const FAUX_ITERATOR_SYMBOL = '@@iterator';

Expand Down
2 changes: 1 addition & 1 deletion packages/shared/ReactTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,5 +95,5 @@ export type ReactEvent = {|

export type ReactEventTarget = {|
$$typeof: Symbol | number,
type: string,
type: Symbol | number,
|};
9 changes: 9 additions & 0 deletions scripts/rollup/bundles.js
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,15 @@ const bundles = [
global: 'SchedulerTracing',
externals: [],
},

/******* React Events (experimental) *******/
{
bundleTypes: [NODE_DEV, NODE_PROD, FB_WWW_DEV, FB_WWW_PROD],
moduleType: ISOMORPHIC,
entry: 'react-events',
global: 'ReactEvents',
externals: [],
},
];

// Based on deep-freeze by substack (public domain)
Expand Down
28 changes: 28 additions & 0 deletions scripts/rollup/results.json
Original file line number Diff line number Diff line change
Expand Up @@ -1147,6 +1147,34 @@
"packageName": "scheduler",
"size": 12088,
"gzip": 2473
},
{
"filename": "react-events.development.js",
"bundleType": "NODE_DEV",
"packageName": "react-events",
"size": 1135,
"gzip": 623
},
{
"filename": "react-events.production.min.js",
"bundleType": "NODE_PROD",
"packageName": "react-events",
"size": 448,
"gzip": 328
},
{
"filename": "ReactEvents-dev.js",
"bundleType": "FB_WWW_DEV",
"packageName": "react-events",
"size": 1106,
"gzip": 613
},
{
"filename": "ReactEvents-prod.js",
"bundleType": "FB_WWW_PROD",
"packageName": "react-events",
"size": 643,
"gzip": 377
}
]
}