@rspack/dev-server 0.0.21 → 0.0.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (100) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/LICENSE +1 -1
  3. package/dist/config.d.ts +19 -14
  4. package/dist/config.d.ts.map +1 -1
  5. package/dist/config.js +0 -52
  6. package/dist/config.js.map +1 -1
  7. package/dist/server.d.ts +14 -41
  8. package/dist/server.d.ts.map +1 -1
  9. package/dist/server.js +308 -257
  10. package/dist/server.js.map +1 -1
  11. package/jest.config.js +3 -1
  12. package/package.json +10 -9
  13. package/src/config.ts +21 -67
  14. package/src/server.ts +350 -311
  15. package/tests/__snapshots__/normalizeOptions.test.ts.snap +223 -24
  16. package/tests/e2e/hot-reaload.test.ts +35 -39
  17. package/tests/e2e-fixtures/react/node_modules/react/LICENSE +21 -0
  18. package/tests/e2e-fixtures/react/node_modules/react/README.md +37 -0
  19. package/tests/e2e-fixtures/react/node_modules/react/cjs/react-jsx-dev-runtime.development.js +1296 -0
  20. package/tests/e2e-fixtures/react/node_modules/react/cjs/react-jsx-dev-runtime.production.min.js +10 -0
  21. package/tests/e2e-fixtures/react/node_modules/react/cjs/react-jsx-dev-runtime.profiling.min.js +10 -0
  22. package/tests/e2e-fixtures/react/node_modules/react/cjs/react-jsx-runtime.development.js +1314 -0
  23. package/tests/e2e-fixtures/react/node_modules/react/cjs/react-jsx-runtime.production.min.js +11 -0
  24. package/tests/e2e-fixtures/react/node_modules/react/cjs/react-jsx-runtime.profiling.min.js +11 -0
  25. package/tests/e2e-fixtures/react/node_modules/react/cjs/react.development.js +2739 -0
  26. package/tests/e2e-fixtures/react/node_modules/react/cjs/react.production.min.js +26 -0
  27. package/tests/e2e-fixtures/react/node_modules/react/cjs/react.shared-subset.development.js +20 -0
  28. package/tests/e2e-fixtures/react/node_modules/react/cjs/react.shared-subset.production.min.js +10 -0
  29. package/tests/e2e-fixtures/react/node_modules/react/index.js +7 -0
  30. package/tests/e2e-fixtures/react/node_modules/react/jsx-dev-runtime.js +7 -0
  31. package/tests/e2e-fixtures/react/node_modules/react/jsx-runtime.js +7 -0
  32. package/tests/e2e-fixtures/react/node_modules/react/package.json +47 -0
  33. package/tests/e2e-fixtures/react/node_modules/react/react.shared-subset.js +7 -0
  34. package/tests/e2e-fixtures/react/node_modules/react/umd/react.development.js +3342 -0
  35. package/tests/e2e-fixtures/react/node_modules/react/umd/react.production.min.js +31 -0
  36. package/tests/e2e-fixtures/react/node_modules/react/umd/react.profiling.min.js +31 -0
  37. package/tests/e2e-fixtures/react/node_modules/react-dom/LICENSE +21 -0
  38. package/tests/e2e-fixtures/react/node_modules/react-dom/README.md +60 -0
  39. package/tests/e2e-fixtures/react/node_modules/react-dom/cjs/react-dom-server-legacy.browser.development.js +7018 -0
  40. package/tests/e2e-fixtures/react/node_modules/react-dom/cjs/react-dom-server-legacy.browser.production.min.js +93 -0
  41. package/tests/e2e-fixtures/react/node_modules/react-dom/cjs/react-dom-server-legacy.node.development.js +7078 -0
  42. package/tests/e2e-fixtures/react/node_modules/react-dom/cjs/react-dom-server-legacy.node.production.min.js +101 -0
  43. package/tests/e2e-fixtures/react/node_modules/react-dom/cjs/react-dom-server.browser.development.js +7003 -0
  44. package/tests/e2e-fixtures/react/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js +96 -0
  45. package/tests/e2e-fixtures/react/node_modules/react-dom/cjs/react-dom-server.node.development.js +7059 -0
  46. package/tests/e2e-fixtures/react/node_modules/react-dom/cjs/react-dom-server.node.production.min.js +102 -0
  47. package/tests/e2e-fixtures/react/node_modules/react-dom/cjs/react-dom-test-utils.development.js +1741 -0
  48. package/tests/e2e-fixtures/react/node_modules/react-dom/cjs/react-dom-test-utils.production.min.js +40 -0
  49. package/tests/e2e-fixtures/react/node_modules/react-dom/cjs/react-dom.development.js +29868 -0
  50. package/tests/e2e-fixtures/react/node_modules/react-dom/cjs/react-dom.production.min.js +323 -0
  51. package/tests/e2e-fixtures/react/node_modules/react-dom/cjs/react-dom.profiling.min.js +367 -0
  52. package/tests/e2e-fixtures/react/node_modules/react-dom/client.js +25 -0
  53. package/tests/e2e-fixtures/react/node_modules/react-dom/index.js +38 -0
  54. package/tests/e2e-fixtures/react/node_modules/react-dom/package.json +62 -0
  55. package/tests/e2e-fixtures/react/node_modules/react-dom/profiling.js +38 -0
  56. package/tests/e2e-fixtures/react/node_modules/react-dom/server.browser.js +17 -0
  57. package/tests/e2e-fixtures/react/node_modules/react-dom/server.js +3 -0
  58. package/tests/e2e-fixtures/react/node_modules/react-dom/server.node.js +17 -0
  59. package/tests/e2e-fixtures/react/node_modules/react-dom/test-utils.js +7 -0
  60. package/tests/e2e-fixtures/react/node_modules/react-dom/umd/react-dom-server-legacy.browser.development.js +7015 -0
  61. package/tests/e2e-fixtures/react/node_modules/react-dom/umd/react-dom-server-legacy.browser.production.min.js +75 -0
  62. package/tests/e2e-fixtures/react/node_modules/react-dom/umd/react-dom-server.browser.development.js +7000 -0
  63. package/tests/e2e-fixtures/react/node_modules/react-dom/umd/react-dom-server.browser.production.min.js +76 -0
  64. package/tests/e2e-fixtures/react/node_modules/react-dom/umd/react-dom-test-utils.development.js +1737 -0
  65. package/tests/e2e-fixtures/react/node_modules/react-dom/umd/react-dom-test-utils.production.min.js +33 -0
  66. package/tests/e2e-fixtures/react/node_modules/react-dom/umd/react-dom.development.js +29869 -0
  67. package/tests/e2e-fixtures/react/node_modules/react-dom/umd/react-dom.production.min.js +267 -0
  68. package/tests/e2e-fixtures/react/node_modules/react-dom/umd/react-dom.profiling.min.js +285 -0
  69. package/tests/e2e-fixtures/react/node_modules/scheduler/LICENSE +21 -0
  70. package/tests/e2e-fixtures/react/node_modules/scheduler/README.md +9 -0
  71. package/tests/e2e-fixtures/react/node_modules/scheduler/cjs/scheduler-unstable_mock.development.js +700 -0
  72. package/tests/e2e-fixtures/react/node_modules/scheduler/cjs/scheduler-unstable_mock.production.min.js +20 -0
  73. package/tests/e2e-fixtures/react/node_modules/scheduler/cjs/scheduler-unstable_post_task.development.js +207 -0
  74. package/tests/e2e-fixtures/react/node_modules/scheduler/cjs/scheduler-unstable_post_task.production.min.js +14 -0
  75. package/tests/e2e-fixtures/react/node_modules/scheduler/cjs/scheduler.development.js +634 -0
  76. package/tests/e2e-fixtures/react/node_modules/scheduler/cjs/scheduler.production.min.js +19 -0
  77. package/tests/e2e-fixtures/react/node_modules/scheduler/index.js +7 -0
  78. package/tests/e2e-fixtures/react/node_modules/scheduler/package.json +36 -0
  79. package/tests/e2e-fixtures/react/node_modules/scheduler/umd/scheduler-unstable_mock.development.js +699 -0
  80. package/tests/e2e-fixtures/react/node_modules/scheduler/umd/scheduler-unstable_mock.production.min.js +19 -0
  81. package/tests/e2e-fixtures/react/node_modules/scheduler/umd/scheduler.development.js +152 -0
  82. package/tests/e2e-fixtures/react/node_modules/scheduler/umd/scheduler.production.min.js +146 -0
  83. package/tests/e2e-fixtures/react/node_modules/scheduler/umd/scheduler.profiling.min.js +146 -0
  84. package/tests/e2e-fixtures/react/node_modules/scheduler/unstable_mock.js +7 -0
  85. package/tests/e2e-fixtures/react/node_modules/scheduler/unstable_post_task.js +7 -0
  86. package/tests/e2e-fixtures/react/package.json +2 -0
  87. package/tests/e2e-fixtures/react/webpack.config.js +6 -2
  88. package/tests/helpers/emitFile.ts +58 -4
  89. package/tests/normalizeOptions.test.ts +58 -16
  90. package/tsconfig.tsbuildinfo +1 -1
  91. package/dist/logger.d.ts +0 -7
  92. package/dist/logger.d.ts.map +0 -1
  93. package/dist/logger.js +0 -28
  94. package/dist/logger.js.map +0 -1
  95. package/dist/ws.d.ts +0 -13
  96. package/dist/ws.d.ts.map +0 -1
  97. package/dist/ws.js +0 -12
  98. package/dist/ws.js.map +0 -1
  99. package/src/logger.ts +0 -30
  100. package/src/ws.ts +0 -18
@@ -3,45 +3,203 @@
3
3
  exports[`normalize options snapshot additional entires should added 1`] = `
4
4
  {
5
5
  "main": [
6
+ "<prefix>/dist/clients/WebSocketClient.js",
7
+ "<prefix>/rspack-dev-client/dist/index.js?protocol=ws%3A&hostname=0.0.0.0&port=8080&pathname=%2Fws&logging=info&overlay=true&reconnect=10&hot=true&live-reload=true",
6
8
  "<prefix>/rspack-dev-client/dist/devServer.js",
7
9
  "<prefix>/rspack-dev-client/dist/reactRefresh.js",
8
- "<prefix>/rspack-dev-client/dist/index.js",
9
10
  "<prefix>/something",
10
11
  ],
11
12
  }
12
13
  `;
13
14
 
15
+ exports[`normalize options snapshot compier.options.devServer should be equal to server.options when devServer is undefined 1`] = `
16
+ {
17
+ "builtins": {
18
+ "browserslist": [],
19
+ "decorator": {
20
+ "emitMetadata": true,
21
+ "legacy": true,
22
+ },
23
+ "define": {},
24
+ "emotion": undefined,
25
+ "html": [],
26
+ "minify": {
27
+ "enable": true,
28
+ "passes": 1,
29
+ },
30
+ "react": {
31
+ "development": true,
32
+ "refresh": true,
33
+ },
34
+ },
35
+ "devServer": {
36
+ "allowedHosts": "auto",
37
+ "bonjour": false,
38
+ "client": {
39
+ "logging": "info",
40
+ "overlay": true,
41
+ "reconnect": 10,
42
+ "webSocketURL": {},
43
+ },
44
+ "compress": true,
45
+ "devMiddleware": {},
46
+ "historyApiFallback": false,
47
+ "host": undefined,
48
+ "hot": true,
49
+ "liveReload": true,
50
+ "magicHtml": true,
51
+ "open": [],
52
+ "port": 8080,
53
+ "server": {
54
+ "options": {},
55
+ "type": "http",
56
+ },
57
+ "setupExitSignals": true,
58
+ "static": [
59
+ {
60
+ "directory": "<PROJECT_ROOT>/public",
61
+ "publicPath": [
62
+ "/",
63
+ ],
64
+ "serveIndex": {
65
+ "icons": true,
66
+ },
67
+ "staticOptions": {},
68
+ "watch": {
69
+ "alwaysStat": true,
70
+ "atomic": false,
71
+ "followSymlinks": false,
72
+ "ignoreInitial": true,
73
+ "ignorePermissionErrors": true,
74
+ "ignored": undefined,
75
+ "interval": undefined,
76
+ "persistent": true,
77
+ "usePolling": false,
78
+ },
79
+ },
80
+ ],
81
+ "watchFiles": [],
82
+ "webSocketServer": {
83
+ "options": {
84
+ "path": "/ws",
85
+ },
86
+ "type": "ws",
87
+ },
88
+ },
89
+ }
90
+ `;
91
+
14
92
  exports[`normalize options snapshot no options 1`] = `
15
93
  {
94
+ "allowedHosts": "auto",
95
+ "bonjour": false,
96
+ "client": {
97
+ "logging": "info",
98
+ "overlay": true,
99
+ "reconnect": 10,
100
+ "webSocketURL": {},
101
+ },
102
+ "compress": true,
16
103
  "devMiddleware": {},
104
+ "historyApiFallback": false,
17
105
  "host": undefined,
18
106
  "hot": true,
19
107
  "liveReload": true,
20
- "open": true,
21
- "port": undefined,
22
- "proxy": undefined,
23
- "static": {
24
- "directory": "<PROJECT_ROOT>/dist",
25
- "watch": {},
108
+ "magicHtml": true,
109
+ "open": [],
110
+ "port": 8080,
111
+ "server": {
112
+ "options": {},
113
+ "type": "http",
114
+ },
115
+ "setupExitSignals": true,
116
+ "static": [
117
+ {
118
+ "directory": "<PROJECT_ROOT>/public",
119
+ "publicPath": [
120
+ "/",
121
+ ],
122
+ "serveIndex": {
123
+ "icons": true,
124
+ },
125
+ "staticOptions": {},
126
+ "watch": {
127
+ "alwaysStat": true,
128
+ "atomic": false,
129
+ "followSymlinks": false,
130
+ "ignoreInitial": true,
131
+ "ignorePermissionErrors": true,
132
+ "ignored": undefined,
133
+ "interval": undefined,
134
+ "persistent": true,
135
+ "usePolling": false,
136
+ },
137
+ },
138
+ ],
139
+ "watchFiles": [],
140
+ "webSocketServer": {
141
+ "options": {
142
+ "path": "/ws",
143
+ },
144
+ "type": "ws",
26
145
  },
27
- "webSocketServer": {},
28
146
  }
29
147
  `;
30
148
 
31
149
  exports[`normalize options snapshot port string 1`] = `
32
150
  {
151
+ "allowedHosts": "auto",
152
+ "bonjour": false,
153
+ "client": {
154
+ "logging": "info",
155
+ "overlay": true,
156
+ "reconnect": 10,
157
+ "webSocketURL": {},
158
+ },
159
+ "compress": true,
33
160
  "devMiddleware": {},
161
+ "historyApiFallback": false,
34
162
  "host": undefined,
35
163
  "hot": true,
36
164
  "liveReload": true,
37
- "open": true,
165
+ "magicHtml": true,
166
+ "open": [],
38
167
  "port": 9000,
39
- "proxy": undefined,
40
- "static": {
41
- "directory": "<PROJECT_ROOT>/dist",
42
- "watch": {},
168
+ "server": {
169
+ "options": {},
170
+ "type": "http",
171
+ },
172
+ "setupExitSignals": true,
173
+ "static": [
174
+ {
175
+ "directory": "<PROJECT_ROOT>/public",
176
+ "publicPath": [
177
+ "/",
178
+ ],
179
+ "serveIndex": {
180
+ "icons": true,
181
+ },
182
+ "staticOptions": {},
183
+ "watch": {
184
+ "alwaysStat": true,
185
+ "atomic": false,
186
+ "followSymlinks": false,
187
+ "ignoreInitial": true,
188
+ "ignorePermissionErrors": true,
189
+ "ignored": undefined,
190
+ "interval": undefined,
191
+ "persistent": true,
192
+ "usePolling": false,
193
+ },
194
+ },
195
+ ],
196
+ "watchFiles": [],
197
+ "webSocketServer": {
198
+ "options": {
199
+ "path": "/ws",
200
+ },
201
+ "type": "ws",
43
202
  },
44
- "webSocketServer": {},
45
203
  }
46
204
  `;
47
205
 
@@ -52,9 +210,9 @@ exports[`normalize options snapshot react.development and react.refresh should b
52
210
  "decorator": {
53
211
  "emitMetadata": true,
54
212
  "legacy": true,
55
- "useDefineForClassFields": true,
56
213
  },
57
214
  "define": {},
215
+ "emotion": undefined,
58
216
  "html": [],
59
217
  "minify": {
60
218
  "enable": true,
@@ -66,18 +224,58 @@ exports[`normalize options snapshot react.development and react.refresh should b
66
224
  },
67
225
  },
68
226
  "devServer": {
227
+ "allowedHosts": "auto",
228
+ "bonjour": false,
229
+ "client": {
230
+ "logging": "info",
231
+ "overlay": true,
232
+ "reconnect": 10,
233
+ "webSocketURL": {},
234
+ },
235
+ "compress": true,
69
236
  "devMiddleware": {},
237
+ "historyApiFallback": false,
70
238
  "host": undefined,
71
239
  "hot": true,
72
240
  "liveReload": true,
73
- "open": true,
74
- "port": undefined,
75
- "proxy": undefined,
76
- "static": {
77
- "directory": "<PROJECT_ROOT>/dist",
78
- "watch": {},
79
- },
80
- "webSocketServer": {},
241
+ "magicHtml": true,
242
+ "open": [],
243
+ "port": 8080,
244
+ "server": {
245
+ "options": {},
246
+ "type": "http",
247
+ },
248
+ "setupExitSignals": true,
249
+ "static": [
250
+ {
251
+ "directory": "<PROJECT_ROOT>/public",
252
+ "publicPath": [
253
+ "/",
254
+ ],
255
+ "serveIndex": {
256
+ "icons": true,
257
+ },
258
+ "staticOptions": {},
259
+ "watch": {
260
+ "alwaysStat": true,
261
+ "atomic": false,
262
+ "followSymlinks": false,
263
+ "ignoreInitial": true,
264
+ "ignorePermissionErrors": true,
265
+ "ignored": undefined,
266
+ "interval": undefined,
267
+ "persistent": true,
268
+ "usePolling": false,
269
+ },
270
+ },
271
+ ],
272
+ "watchFiles": [],
273
+ "webSocketServer": {
274
+ "options": {
275
+ "path": "/ws",
276
+ },
277
+ "type": "ws",
278
+ },
81
279
  },
82
280
  }
83
281
  `;
@@ -85,9 +283,10 @@ exports[`normalize options snapshot react.development and react.refresh should b
85
283
  exports[`normalize options snapshot react-refresh client added when react/refresh enabled 1`] = `
86
284
  {
87
285
  "main": [
286
+ "<prefix>/dist/clients/WebSocketClient.js",
287
+ "<prefix>/rspack-dev-client/dist/index.js?protocol=ws%3A&hostname=0.0.0.0&port=8080&pathname=%2Fws&logging=info&overlay=true&reconnect=10&hot=true&live-reload=true",
88
288
  "<prefix>/rspack-dev-client/dist/devServer.js",
89
289
  "<prefix>/rspack-dev-client/dist/reactRefresh.js",
90
- "<prefix>/rspack-dev-client/dist/index.js",
91
290
  "<prefix>/something",
92
291
  ],
93
292
  }
@@ -1,29 +1,26 @@
1
1
  import { RspackDevServer } from "@rspack/dev-server";
2
2
  import { createCompiler } from "@rspack/core";
3
3
  import { initFixture, installDeps } from "../helpers/tempDir";
4
- import { editFile } from "../helpers/emitFile";
4
+ import { editFile, waitingForBuild } from "../helpers/emitFile";
5
5
  import path from "path";
6
6
  import runBrowser from "../helpers/runBrowser";
7
7
  import type { Browser, Page } from "puppeteer";
8
8
 
9
- describe("reload and hot should works", () => {
10
- let browser: Browser;
11
- let server: RspackDevServer;
12
-
13
- afterEach(async () => {
14
- if (browser) {
15
- await browser.close();
16
- }
17
- if (server) {
18
- await server.stop();
19
- }
9
+ async function wait(time) {
10
+ return new Promise(resolve => {
11
+ setTimeout(() => {
12
+ resolve(undefined);
13
+ }, time);
20
14
  });
15
+ }
21
16
 
22
- it("reload should works", async () => {
23
- const tempDir = await initFixture("react");
17
+ describe("reload and hot should works", () => {
18
+ it.skip("reload and hot should works", async () => {
19
+ // reload should works
20
+ let tempDir = await initFixture("react");
24
21
  await installDeps(tempDir);
25
- const config = require(path.resolve(tempDir, "./webpack.config.js"));
26
- const compiler = createCompiler({
22
+ let config = require(path.resolve(tempDir, "./webpack.config.js"));
23
+ let compiler = createCompiler({
27
24
  ...config,
28
25
  context: tempDir,
29
26
  devServer: {
@@ -31,23 +28,19 @@ describe("reload and hot should works", () => {
31
28
  liveReload: true
32
29
  }
33
30
  });
34
- server = new RspackDevServer(compiler);
31
+ let server = new RspackDevServer(compiler.options.devServer, compiler);
35
32
  await server.start();
36
- const launched = await runBrowser();
37
- ({ browser } = launched);
38
- const { page } = launched;
39
-
40
- const consoleMessages: string[] = [];
41
- page.on("console", message => {
42
- const text = message.text();
43
- consoleMessages.push(text);
44
- });
33
+ await waitingForBuild(server.options.port);
34
+ console.log("=== before goto page ===");
35
+ let { browser, page } = await runBrowser();
45
36
 
46
37
  await page.goto(`http://localhost:${server.options.port}`);
47
38
  await page.click(".test-button");
48
39
  expect(await getText(page, ".test-button-content")).toBe("1");
49
40
  expect(await getText(page, ".placeholder")).toBe("__PLACE_HOLDER__");
50
- await editFile(path.resolve(tempDir, "./app.jsx"), code =>
41
+
42
+ const appFilePath = path.resolve(tempDir, "./app.jsx");
43
+ await editFile(appFilePath, code =>
51
44
  code.replace("__PLACE_HOLDER__", "update")
52
45
  );
53
46
  expect(await getText(page, ".test-button-content")).toBe("0");
@@ -60,31 +53,31 @@ describe("reload and hot should works", () => {
60
53
  expect((await getComputedStyle(page, "body")).backgroundColor).toBe(
61
54
  "rgba(255, 0, 0, 0)"
62
55
  );
63
- });
56
+ await server.stop();
57
+ await browser.close();
58
+ console.log("=== first end ===");
64
59
 
65
- it("hot should works", async () => {
66
- const tempDir = await initFixture("react");
60
+ // hot should works;
61
+ console.log("=== second start ===");
62
+ tempDir = await initFixture("react");
67
63
  await installDeps(tempDir);
68
- const config = require(path.resolve(tempDir, "./webpack.config.js"));
69
- const compiler = createCompiler({
64
+ config = require(path.resolve(tempDir, "./webpack.config.js"));
65
+ compiler = createCompiler({
70
66
  ...config,
71
67
  context: tempDir
72
68
  });
73
- server = new RspackDevServer(compiler);
69
+ server = new RspackDevServer(compiler.options.devServer, compiler);
74
70
  await server.start();
71
+ await waitingForBuild(server.options.port);
72
+ console.log("=== before goto page ===");
75
73
 
76
- const launched = await runBrowser();
77
- ({ browser } = launched);
78
- const { page } = launched;
79
-
74
+ ({ browser, page } = await runBrowser());
80
75
  const consoleMessages: string[] = [];
81
76
  page.on("console", message => {
82
77
  const text = message.text();
83
78
  consoleMessages.push(text);
84
79
  });
85
-
86
80
  await page.goto(`http://localhost:${server.options.port}`);
87
-
88
81
  await page.click(".test-button");
89
82
  expect(await getText(page, ".test-button-content")).toBe("1");
90
83
  expect(await getText(page, ".placeholder")).toBe("__PLACE_HOLDER__");
@@ -100,6 +93,9 @@ describe("reload and hot should works", () => {
100
93
  );
101
94
  expect(await getText(page, ".test-button-content")).toBe("1");
102
95
  expect(consoleMessages).toContain("App hot update...");
96
+ await server.stop();
97
+ await browser.close();
98
+ console.log("=== second end ===");
103
99
  });
104
100
  });
105
101
 
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) Facebook, Inc. and its affiliates.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,37 @@
1
+ # `react`
2
+
3
+ React is a JavaScript library for creating user interfaces.
4
+
5
+ The `react` package contains only the functionality necessary to define React components. It is typically used together with a React renderer like `react-dom` for the web, or `react-native` for the native environments.
6
+
7
+ **Note:** by default, React will be in development mode. The development version includes extra warnings about common mistakes, whereas the production version includes extra performance optimizations and strips all error messages. Don't forget to use the [production build](https://reactjs.org/docs/optimizing-performance.html#use-the-production-build) when deploying your application.
8
+
9
+ ## Usage
10
+
11
+ ```js
12
+ import { useState } from 'react';
13
+ import { createRoot } from 'react-dom/client';
14
+
15
+ function Counter() {
16
+ const [count, setCount] = useState(0);
17
+ return (
18
+ <>
19
+ <h1>{count}</h1>
20
+ <button onClick={() => setCount(count + 1)}>
21
+ Increment
22
+ </button>
23
+ </>
24
+ );
25
+ }
26
+
27
+ const root = createRoot(document.getElementById('root'));
28
+ root.render(<App />);
29
+ ```
30
+
31
+ ## Documentation
32
+
33
+ See https://reactjs.org/
34
+
35
+ ## API
36
+
37
+ See https://reactjs.org/docs/react-api.html