Skip to content

Commit 5c97c74

Browse files
lunaruanrajitkhanna
authored andcommitted
add jsx-runtime and jsx-dev-runtime (facebook#18299)
This PR adds the jsx-runtime and jsx-dev-runtime modules for the JSX Babel Plugin. WWW still relies on jsx/jsxs/jsxDEV from the "react" module, so once we refactor the code to point to the runtime modules we will remove jsx/jsxs/jsxDEV from the "react" module.
1 parent 2666642 commit 5c97c74

18 files changed

+927
-88
lines changed

packages/react/index.classic.fb.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,5 @@ export {
5050
DEPRECATED_createResponder,
5151
// enableScopeAPI
5252
unstable_createScope,
53-
// enableJSXTransformAPI
54-
jsx,
55-
jsxs,
56-
jsxDEV,
5753
} from './src/React';
54+
export {jsx, jsxs, jsxDEV} from './src/jsx/ReactJSX';

packages/react/index.experimental.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,4 @@ export {
4545
unstable_withSuspenseConfig,
4646
// enableBlocksAPI
4747
block,
48-
// enableJSXTransformAPI
49-
jsx,
50-
jsxs,
51-
jsxDEV,
5248
} from './src/React';

packages/react/index.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,4 @@ export {
7676
DEPRECATED_createResponder,
7777
unstable_createFundamental,
7878
unstable_createScope,
79-
jsx,
80-
jsxs,
81-
jsxDEV,
8279
} from './src/React';

packages/react/index.modern.fb.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,5 @@ export {
4949
DEPRECATED_createResponder,
5050
// enableScopeAPI
5151
unstable_createScope,
52-
// enableJSXTransformAPI
53-
jsx,
54-
jsxs,
55-
jsxDEV,
5652
} from './src/React';
53+
export {jsx, jsxs, jsxDEV} from './src/jsx/ReactJSX';

packages/react/jsx-dev-runtime.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
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+
* @flow
8+
*/
9+
10+
export {Fragment, jsxDEV} from './src/jsx/ReactJSX';

packages/react/jsx-runtime.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
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+
* @flow
8+
*/
9+
export {Fragment, jsx, jsxs} from './src/jsx/ReactJSX';

packages/react/npm/jsx-dev-runtime.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
'use strict';
2+
3+
if (process.env.NODE_ENV === 'production') {
4+
module.exports = require('./cjs/react-jsx-dev-runtime.production.min.js');
5+
} else {
6+
module.exports = require('./cjs/react-jsx-dev-runtime.development.js');
7+
}

packages/react/npm/jsx-runtime.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
'use strict';
2+
3+
if (process.env.NODE_ENV === 'production') {
4+
module.exports = require('./cjs/react-jsx-runtime.production.min.js');
5+
} else {
6+
module.exports = require('./cjs/react-jsx-runtime.development.js');
7+
}

packages/react/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@
1414
"build-info.json",
1515
"index.js",
1616
"cjs/",
17-
"umd/"
17+
"umd/",
18+
"jsx-runtime.js",
19+
"jsx-dev-runtime.js"
1820
],
1921
"main": "index.js",
2022
"repository": {

packages/react/src/React.js

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ import {
2424
createFactory as createFactoryProd,
2525
cloneElement as cloneElementProd,
2626
isValidElement,
27-
jsx as jsxProd,
2827
} from './ReactElement';
2928
import {createContext} from './ReactContext';
3029
import {lazy} from './ReactLazy';
@@ -52,9 +51,6 @@ import {
5251
createElementWithValidation,
5352
createFactoryWithValidation,
5453
cloneElementWithValidation,
55-
jsxWithValidation,
56-
jsxWithValidationStatic,
57-
jsxWithValidationDynamic,
5854
} from './ReactElementValidator';
5955
import createMutableSource from './createMutableSource';
6056
import ReactSharedInternals from './ReactSharedInternals';
@@ -67,12 +63,6 @@ const createElement = __DEV__ ? createElementWithValidation : createElementProd;
6763
const cloneElement = __DEV__ ? cloneElementWithValidation : cloneElementProd;
6864
const createFactory = __DEV__ ? createFactoryWithValidation : createFactoryProd;
6965

70-
const jsxDEV = __DEV__ ? jsxWithValidation : undefined;
71-
const jsx = __DEV__ ? jsxWithValidationDynamic : jsxProd;
72-
// we may want to special case jsxs internally to take advantage of static children.
73-
// for now we can ship identical prod functions
74-
const jsxs = __DEV__ ? jsxWithValidationStatic : jsxProd;
75-
7666
const Children = {
7767
map,
7868
forEach,
@@ -127,9 +117,4 @@ export {
127117
createFundamental as unstable_createFundamental,
128118
// enableScopeAPI
129119
createScope as unstable_createScope,
130-
// enableJSXTransformAPI
131-
jsx,
132-
jsxs,
133-
// TODO: jsxDEV should not be exposed as a name. We might want to move it to a different entry point.
134-
jsxDEV,
135120
};

0 commit comments

Comments
 (0)