@samitouri / QOS-React / commits / e0a0e65412

Move `react-html` to `react-markup` (#30688)

Sebastian Silbermann committed Aug 14, 2024 at 19:22 UTC e0a0e65412cfa00e959fbef0f6c3a0c73725f0a3
23 files changed +79 -79
packages/react-client/src/forks/ReactFlightClientConfig.markup.js
+1 -1
@@ -9,7 +9,7 @@
9
10 import type {Thenable} from 'shared/ReactTypes';
11
12 -export * from 'react-html/src/ReactHTMLLegacyClientStreamConfig.js';
12 +export * from 'react-markup/src/ReactMarkupLegacyClientStreamConfig.js';
13 export * from 'react-client/src/ReactClientConsoleConfigPlain';
14
15 export type ModuleLoading = null;
packages/react-html/npm/index.js deleted
-7
@@ -1,7 +0,0 @@
1 -'use strict';
2 -
3 -if (process.env.NODE_ENV === 'production') {
4 - module.exports = require('./cjs/react-html.production.js');
5 -} else {
6 - module.exports = require('./cjs/react-html.development.js');
7 -}
packages/react-html/npm/react-html.react-server.js deleted
-7
@@ -1,7 +0,0 @@
1 -'use strict';
2 -
3 -if (process.env.NODE_ENV === 'production') {
4 - module.exports = require('./cjs/react-html.react-server.production.js');
5 -} else {
6 - module.exports = require('./cjs/react-html.react-server.development.js');
7 -}
packages/react-markup/README.md renamed
+5 -5
@@ -1,17 +1,17 @@
1 -# `react-html`
1 +# `react-markup`
2
3 This package provides the ability to render standalone HTML from Server Components for use in embedded contexts such as e-mails and RSS/Atom feeds. It cannot use Client Components and does not hydrate. It is intended to be paired with the generic React package, which is shipped as `react` to npm.
4
5 ## Installation
6
7 ```sh
8 -npm install react react-html
8 +npm install react react-markup
9 ```
10
11 ## Usage
12
13 ```js
14 -import { renderToMarkup } from 'react-html';
14 +import { renderToMarkup } from 'react-markup';
15 import EmailTemplate from './my-email-template-component.js'
16
17 async function action(email, name) {
@@ -27,6 +27,6 @@ Note that this is an async function that needs to be awaited - unlike the legacy
27
28 ## API
29
30 -### `react-html`
30 +### `react-markup`
31
32 -See https://react.dev/reference/react-html
32 +See https://react.dev/reference/react-markup
packages/react-markup/index.js renamed
+1 -1
@@ -7,4 +7,4 @@
7 * @flow
8 */
9
10 -export * from './src/ReactHTMLClient';
10 +export * from './src/ReactMarkupClient';
packages/react-markup/npm/index.js new
+7
@@ -0,0 +1,7 @@
1 +'use strict';
2 +
3 +if (process.env.NODE_ENV === 'production') {
4 + module.exports = require('./cjs/react-markup.production.js');
5 +} else {
6 + module.exports = require('./cjs/react-markup.development.js');
7 +}
packages/react-markup/npm/react-markup.react-server.js new
+7
@@ -0,0 +1,7 @@
1 +'use strict';
2 +
3 +if (process.env.NODE_ENV === 'production') {
4 + module.exports = require('./cjs/react-markup.react-server.production.js');
5 +} else {
6 + module.exports = require('./cjs/react-markup.react-server.development.js');
7 +}
packages/react-markup/package.json renamed
+4 -4
@@ -1,5 +1,5 @@
1 {
2 - "name": "react-html",
2 + "name": "react-markup",
3 "version": "19.0.0",
4 "private": true,
5 "description": "React package generating embedded HTML markup such as e-mails using Server Components.",
@@ -7,7 +7,7 @@
7 "repository": {
8 "type": "git",
9 "url": "https://github.com/facebook/react.git",
10 - "directory": "packages/react-html"
10 + "directory": "packages/react-markup"
11 },
12 "keywords": [
13 "react"
@@ -24,12 +24,12 @@
24 "LICENSE",
25 "README.md",
26 "index.js",
27 - "react-html.react-server.js",
27 + "react-markup.react-server.js",
28 "cjs/"
29 ],
30 "exports": {
31 ".": {
32 - "react-server": "./react-html.react-server.js",
32 + "react-server": "./react-markup.react-server.js",
33 "default": "./index.js"
34 },
35 "./src/*": "./src/*",
packages/react-markup/react-markup.react-server.js renamed
+1 -1
@@ -7,4 +7,4 @@
7 * @flow
8 */
9
10 -export * from './src/ReactHTMLServer';
10 +export * from './src/ReactMarkupServer';
packages/react-markup/src/ReactFizzConfigMarkup.js renamed
packages/react-markup/src/ReactMarkupClient.js renamed
+1 -1
@@ -23,7 +23,7 @@ import {
23 createResumableState,
24 createRenderState,
25 createRootFormatContext,
26 -} from './ReactFizzConfigHTML';
26 +} from './ReactFizzConfigMarkup';
27
28 type MarkupOptions = {
29 identifierPrefix?: string,
packages/react-markup/src/ReactMarkupClient.stable.js renamed
+1 -1
@@ -8,4 +8,4 @@
8 */
9
10 // eslint-disable-next-line react-internal/prod-error-codes
11 -throw new Error('react-html should not get built in stable');
11 +throw new Error('react-markup should not get built in stable');
packages/react-markup/src/ReactMarkupLegacyClientStreamConfig.js renamed
packages/react-markup/src/ReactMarkupServer.js renamed
+1 -1
@@ -41,7 +41,7 @@ import {
41 createResumableState,
42 createRenderState,
43 createRootFormatContext,
44 -} from './ReactFizzConfigHTML';
44 +} from './ReactFizzConfigMarkup';
45
46 type ReactMarkupNodeList =
47 // This is the intersection of ReactNodeList and ReactClientValue minus
packages/react-markup/src/ReactMarkupServer.stable.js renamed
+1 -1
@@ -8,4 +8,4 @@
8 */
9
10 // eslint-disable-next-line react-internal/prod-error-codes
11 -throw new Error('react-html should not get built in stable');
11 +throw new Error('react-markup should not get built in stable');
packages/react-markup/src/__tests__/ReactMarkupClient-test.js renamed
+14 -14
@@ -10,7 +10,7 @@
10 'use strict';
11
12 let React;
13 -let ReactHTML;
13 +let ReactMarkup;
14
15 function normalizeCodeLocInfo(str) {
16 return (
@@ -24,18 +24,18 @@ function normalizeCodeLocInfo(str) {
24 if (!__EXPERIMENTAL__) {
25 it('should not be built in stable', () => {
26 try {
27 - require('react-html');
27 + require('react-markup');
28 } catch (x) {
29 return;
30 }
31 - throw new Error('Expected react-html not to exist in stable.');
31 + throw new Error('Expected react-markup not to exist in stable.');
32 });
33 } else {
34 - describe('ReactHTML', () => {
34 + describe('ReactMarkup', () => {
35 beforeEach(() => {
36 jest.resetModules();
37 React = require('react');
38 - ReactHTML = require('react-html');
38 + ReactMarkup = require('react-markup');
39 });
40
41 it('should be able to render a simple component', async () => {
@@ -43,7 +43,7 @@ if (!__EXPERIMENTAL__) {
43 return <div>hello world</div>;
44 }
45
46 - const html = await ReactHTML.renderToMarkup(<Component />);
46 + const html = await ReactMarkup.renderToMarkup(<Component />);
47 expect(html).toBe('<div>hello world</div>');
48 });
49
@@ -52,14 +52,14 @@ if (!__EXPERIMENTAL__) {
52 return <div>{'hello '.repeat(200)}world</div>;
53 }
54
55 - const html = await ReactHTML.renderToMarkup(
55 + const html = await ReactMarkup.renderToMarkup(
56 React.createElement(Component),
57 );
58 expect(html).toBe('<div>' + ('hello '.repeat(200) + 'world') + '</div>');
59 });
60
61 it('should prefix html tags with a doctype', async () => {
62 - const html = await ReactHTML.renderToMarkup(
62 + const html = await ReactMarkup.renderToMarkup(
63 <html>
64 <body>hello</body>
65 </html>,
@@ -76,7 +76,7 @@ if (!__EXPERIMENTAL__) {
76 }
77
78 await expect(async () => {
79 - await ReactHTML.renderToMarkup(<Component />);
79 + await ReactMarkup.renderToMarkup(<Component />);
80 }).rejects.toThrow();
81 });
82
@@ -87,7 +87,7 @@ if (!__EXPERIMENTAL__) {
87 }
88
89 await expect(async () => {
90 - await ReactHTML.renderToMarkup(<Component />);
90 + await ReactMarkup.renderToMarkup(<Component />);
91 }).rejects.toThrow();
92 });
93
@@ -100,7 +100,7 @@ if (!__EXPERIMENTAL__) {
100 }
101
102 await expect(async () => {
103 - await ReactHTML.renderToMarkup(<Component />);
103 + await ReactMarkup.renderToMarkup(<Component />);
104 }).rejects.toThrow();
105 });
106
@@ -142,7 +142,7 @@ if (!__EXPERIMENTAL__) {
142 );
143 }
144
145 - const html = await ReactHTML.renderToMarkup(<Component />);
145 + const html = await ReactMarkup.renderToMarkup(<Component />);
146 const container = document.createElement('div');
147 container.innerHTML = html;
148
@@ -176,7 +176,7 @@ if (!__EXPERIMENTAL__) {
176 );
177 }
178
179 - const html = await ReactHTML.renderToMarkup(<Component />);
179 + const html = await ReactMarkup.renderToMarkup(<Component />);
180 expect(html).toBe('<div>01</div>');
181 });
182
@@ -199,7 +199,7 @@ if (!__EXPERIMENTAL__) {
199 }
200
201 await expect(async () => {
202 - await ReactHTML.renderToMarkup(
202 + await ReactMarkup.renderToMarkup(
203 <div>
204 <Foo />
205 </div>,
packages/react-markup/src/__tests__/ReactMarkupServer-test.js renamed
+18 -18
@@ -13,7 +13,7 @@ global.TextDecoder = require('util').TextDecoder;
13 global.TextEncoder = require('util').TextEncoder;
14
15 let React;
16 -let ReactHTML;
16 +let ReactMarkup;
17
18 function normalizeCodeLocInfo(str) {
19 return (
@@ -27,34 +27,34 @@ function normalizeCodeLocInfo(str) {
27 if (!__EXPERIMENTAL__) {
28 it('should not be built in stable', () => {
29 try {
30 - require('react-html');
30 + require('react-markup');
31 } catch (x) {
32 return;
33 }
34 - throw new Error('Expected react-html not to exist in stable.');
34 + throw new Error('Expected react-markup not to exist in stable.');
35 });
36 } else {
37 - describe('ReactHTML', () => {
37 + describe('ReactMarkup', () => {
38 beforeEach(() => {
39 jest.resetModules();
40 // We run in the react-server condition.
41 jest.mock('react', () => require('react/react.react-server'));
42 if (__EXPERIMENTAL__) {
43 - jest.mock('react-html', () =>
44 - require('react-html/react-html.react-server'),
43 + jest.mock('react-markup', () =>
44 + require('react-markup/react-markup.react-server'),
45 );
46 }
47
48 React = require('react');
49 if (__EXPERIMENTAL__) {
50 - ReactHTML = require('react-html');
50 + ReactMarkup = require('react-markup');
51 } else {
52 try {
53 - require('react-html/react-html.react-server');
53 + require('react-markup/react-markup.react-server');
54 } catch (x) {
55 return;
56 }
57 - throw new Error('Expected react-html not to exist in stable.');
57 + throw new Error('Expected react-markup not to exist in stable.');
58 }
59 });
60
@@ -64,7 +64,7 @@ if (!__EXPERIMENTAL__) {
64 return React.createElement('div', null, 'hello world');
65 }
66
67 - const html = await ReactHTML.renderToMarkup(
67 + const html = await ReactMarkup.renderToMarkup(
68 React.createElement(Component),
69 );
70 expect(html).toBe('<div>hello world</div>');
@@ -76,14 +76,14 @@ if (!__EXPERIMENTAL__) {
76 return React.createElement('div', null, 'hello '.repeat(200) + 'world');
77 }
78
79 - const html = await ReactHTML.renderToMarkup(
79 + const html = await ReactMarkup.renderToMarkup(
80 React.createElement(Component),
81 );
82 expect(html).toBe('<div>' + ('hello '.repeat(200) + 'world') + '</div>');
83 });
84
85 it('should prefix html tags with a doctype', async () => {
86 - const html = await ReactHTML.renderToMarkup(
86 + const html = await ReactMarkup.renderToMarkup(
87 // We can't use JSX because that's client-JSX in our tests.
88 React.createElement(
89 'html',
@@ -104,7 +104,7 @@ if (!__EXPERIMENTAL__) {
104 }
105
106 await expect(async () => {
107 - await ReactHTML.renderToMarkup(React.createElement(Component));
107 + await ReactMarkup.renderToMarkup(React.createElement(Component));
108 }).rejects.toThrow();
109 });
110
@@ -116,7 +116,7 @@ if (!__EXPERIMENTAL__) {
116 }
117
118 await expect(async () => {
119 - await ReactHTML.renderToMarkup(React.createElement(Component));
119 + await ReactMarkup.renderToMarkup(React.createElement(Component));
120 }).rejects.toThrow();
121 });
122
@@ -130,7 +130,7 @@ if (!__EXPERIMENTAL__) {
130 }
131
132 await expect(async () => {
133 - await ReactHTML.renderToMarkup(React.createElement(Component));
133 + await ReactMarkup.renderToMarkup(React.createElement(Component));
134 }).rejects.toThrow();
135 });
136
@@ -173,7 +173,7 @@ if (!__EXPERIMENTAL__) {
173 );
174 }
175
176 - const html = await ReactHTML.renderToMarkup(
176 + const html = await ReactMarkup.renderToMarkup(
177 React.createElement(Component),
178 );
179 const container = document.createElement('div');
@@ -204,7 +204,7 @@ if (!__EXPERIMENTAL__) {
204 return React.createElement('div', null, a, b);
205 }
206
207 - const html = await ReactHTML.renderToMarkup(
207 + const html = await ReactMarkup.renderToMarkup(
208 React.createElement(Component),
209 );
210 expect(html).toBe('<div>00</div>');
@@ -225,7 +225,7 @@ if (!__EXPERIMENTAL__) {
225 }
226
227 await expect(async () => {
228 - await ReactHTML.renderToMarkup(
228 + await ReactMarkup.renderToMarkup(
229 React.createElement('div', null, React.createElement(Foo)),
230 {
231 onError(error, errorInfo) {
packages/react-reconciler/src/forks/ReactFiberConfig.markup.js
+1 -1
@@ -13,4 +13,4 @@ export * from 'react-dom-bindings/src/client/ReactFiberConfigDOM';
13 export * from 'react-client/src/ReactClientConsoleConfigBrowser';
14
15 // eslint-disable-next-line react-internal/prod-error-codes
16 -throw new Error('Fiber is not used in react-html');
16 +throw new Error('Fiber is not used in react-markup');
packages/react-server/src/forks/ReactFizzConfig.markup.js
+1 -1
@@ -8,7 +8,7 @@
8 */
9 import type {Request} from 'react-server/src/ReactFizzServer';
10
11 -export * from 'react-html/src/ReactFizzConfigHTML.js';
11 +export * from 'react-markup/src/ReactFizzConfigMarkup.js';
12
13 export * from 'react-client/src/ReactClientConsoleConfigPlain';
14
scripts/error-codes/codes.json
+2 -2
@@ -516,7 +516,7 @@
516 "528": "Expected <link> not to update to be updated to a stylesheet with precedence. Check the `rel`, `href`, and `precedence` props of this component. Alternatively, check whether two different <link> components render in the same slot or share the same key.%s",
517 "529": "Expected stylesheet with precedence to not be updated to a different kind of <link>. Check the `rel`, `href`, and `precedence` props of this component. Alternatively, check whether two different <link> components render in the same slot or share the same key.%s",
518 "530": "The render was aborted by the server with a promise.",
519 - "531": "react-html is not supported outside a React Server Components environment.",
519 + "531": "react-markup is not supported outside a React Server Components environment.",
520 "532": "Attempted to render a Client Component from renderToMarkup. This is not supported since it will never hydrate. Only render Server Components with renderToMarkup.",
521 "533": "Attempted to render a Server Action from renderToMarkup. This is not supported since it varies by version of the app. Use a fixed URL for any forms instead.",
522 "534": "renderToMarkup should not have emitted Client References. This is a bug in React.",
@@ -527,4 +527,4 @@
527 "539": "Binary RSC chunks cannot be encoded as strings. This is a bug in the wiring of the React streams.",
528 "540": "String chunks need to be passed in their original shape. Not split into smaller string chunks. This is a bug in the wiring of the React streams.",
529 "541": "Compared context values must be arrays"
530 -}
\ No newline at end of file
530 +}
scripts/rollup/bundles.js
+6 -6
@@ -367,10 +367,10 @@ const bundles = [
367 {
368 bundleTypes: __EXPERIMENTAL__ ? [NODE_DEV, NODE_PROD] : [],
369 moduleType: RENDERER,
370 - entry: 'react-html/src/ReactHTMLServer.js',
371 - name: 'react-html.react-server',
370 + entry: 'react-markup/src/ReactMarkupServer.js',
371 + name: 'react-markup.react-server',
372 condition: 'react-server',
373 - global: 'ReactHTML',
373 + global: 'ReactMarkup',
374 minifyWithProdErrorCodes: false,
375 wrapWithModuleBoundaries: false,
376 externals: ['react'],
@@ -380,9 +380,9 @@ const bundles = [
380 {
381 bundleTypes: __EXPERIMENTAL__ ? [NODE_DEV, NODE_PROD] : [],
382 moduleType: RENDERER,
383 - entry: 'react-html/src/ReactHTMLClient.js',
384 - name: 'react-html',
385 - global: 'ReactHTML',
383 + entry: 'react-markup/src/ReactMarkupClient.js',
384 + name: 'react-markup',
385 + global: 'ReactMarkup',
386 minifyWithProdErrorCodes: false,
387 wrapWithModuleBoundaries: false,
388 externals: ['react'],
scripts/rollup/forks.js
+4 -4
@@ -65,8 +65,8 @@ const forks = Object.freeze({
65 if (entry === 'react/src/ReactServer.js') {
66 return './packages/react/src/ReactSharedInternalsServer.js';
67 }
68 - if (entry === 'react-html/src/ReactHTMLServer.js') {
69 - // Inside the ReactHTMLServer render we don't refer to any shared internals
68 + if (entry === 'react-markup/src/ReactMarkupServer.js') {
69 + // Inside the ReactMarkupServer render we don't refer to any shared internals
70 // but instead use our own internal copy of the state because you cannot use
71 // any of this state from a component anyway. E.g. you can't use a client hook.
72 return './packages/react/src/ReactSharedInternalsClient.js';
@@ -100,8 +100,8 @@ const forks = Object.freeze({
100 entry === 'react-dom/src/ReactDOMFB.js' ||
101 entry === 'react-dom/src/ReactDOMTestingFB.js' ||
102 entry === 'react-dom/src/ReactDOMServer.js' ||
103 - entry === 'react-html/src/ReactHTMLClient.js' ||
104 - entry === 'react-html/src/ReactHTMLServer.js'
103 + entry === 'react-markup/src/ReactMarkupClient.js' ||
104 + entry === 'react-markup/src/ReactMarkupServer.js'
105 ) {
106 if (
107 bundleType === FB_WWW_DEV ||
scripts/shared/inlinedHostConfigs.js
+3 -3
@@ -444,14 +444,14 @@ module.exports = [
444 {
445 shortName: 'markup',
446 entryPoints: [
447 - 'react-html/src/ReactHTMLClient.js', // react-html
448 - 'react-html/src/ReactHTMLServer.js', // react-html/react-html.react-server
447 + 'react-markup/src/ReactMarkupClient.js', // react-markup
448 + 'react-markup/src/ReactMarkupServer.js', // react-markup/react-markup.react-server
449 ],
450 paths: [
451 'react-dom',
452 'react-dom/src/ReactDOMReactServer.js',
453 'react-dom-bindings',
454 - 'react-html',
454 + 'react-markup',
455 'shared/ReactDOMSharedInternals',
456 ],
457 isFlowTyped: true,