Skip to content

Commit b10ad8d

Browse files
authored
chore: release v0.6.0 (#851)
* docs: add 0.6.0 template * refactor!: drop Webpack 4 and WDS 3 support (#850) * chore: cleanup * chore: first prerelease * feat: build thin externalization client (#852) * refactor: migrate from ansi-html to anser (#854) * chore: release v0.6.0-beta.1 * chore: fix publish command * chore: resolve memfs and rimraf * docs: update README to reflect new dependencies requirement * docs: clarify minimum supported Node.js version (#899) * fix: make plugin entries empty for production (#900) * chore: cleanup old utils for Webpack 4 (#904) * chore: cleanup unused utils * refactor: cleanup entry injection * refactor: cleanup runtime module * test: update snapshots * docs: update changelog * chore: bump all development deps (#905) * chore: bump all development deps * docs: add changelog entry * chore: rename prettierrc
1 parent a106ec7 commit b10ad8d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+1852
-7149
lines changed

.eslintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
*dist/
22
*node_modules/
3+
*umd/
34
*__tmp__
45

56
# Ignore examples because they might have custom ESLint configurations

.eslintrc.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
"globals": {
3333
"__DEBUG__": true,
3434
"WDS_VERSION": true,
35-
"WEBPACK_VERSION": true,
3635
"browser": true,
3736
"window": true
3837
},

.gitignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
# distribution
77
*dist
8+
*umd
89

910
# misc
1011
.DS_Store
@@ -19,6 +20,4 @@ yarn-error.log*
1920
.vscode
2021

2122
# test artifacts
22-
*.yalc
2323
*__tmp__
24-
yalc.lock

.prettierignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
*dist/
22
*node_modules/
3+
*umd/
34
*__tmp__
File renamed without changes.

CHANGELOG.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,29 @@
1+
## 0.6.0 (Unknown)
2+
3+
### BREAKING
4+
5+
- Minimum required Node.js version has been bumped to `18.12.0`.
6+
- Minimum required `webpack` version has been bumped to `5.2.0`.
7+
- Minimum supported `webpack-dev-server` version has been bumped to `4.8.0`.
8+
- Minimum supported `webpack-plugin-serve` version has been bumped to `1.0.0`.
9+
- `overlay.sockHost`, `overlay.sockPath`, `overlay.sockPort`, `overlay.sockProtocol` and `overlay.useURLPolyfill` have all been removed (#850).
10+
It was necessary to support WDS below `4.8.0` (published in April 2022).
11+
It is no-longer necessary as a direct integration with WDS is now possible.
12+
13+
### Features
14+
15+
- Added helper script to better support use cases where React and/or React-DOM are externalized (#852)
16+
17+
### Fixes
18+
19+
- Ensure plugin injected entries are no-op in production (#900)
20+
21+
### Internal
22+
23+
- Dropped support for Webpack 4 / WDS 3 (#850, #904)
24+
- Migrated from `ansi-html` to `anser` in error overlay (#854)
25+
- Bumped all development dependencies (#905)
26+
127
## 0.5.16 (31 Mar 2025)
228

329
### Fixes

README.md

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,8 @@
1313
[![Latest Version][npm:latest:badge]][npm:latest]
1414
[![Next Version][npm:next:badge]][npm:next]
1515

16-
An **EXPERIMENTAL** Webpack plugin to enable "Fast Refresh" (also known as _Hot Reloading_) for React components.
16+
A Webpack plugin to enable "Fast Refresh" (also known as _Hot Reloading_) for React components.
1717

18-
> This plugin is not 100% stable.
1918
> We're hoping to land a v1 release soon - please help us by reporting any issues you've encountered!
2019
2120
## Getting Started
@@ -28,23 +27,25 @@ and thus cannot be made compatible.
2827

2928
We recommend using the following versions:
3029

31-
| Dependency | Version |
32-
| --------------- | ---------------------------- |
33-
| `react` | `16.13.0`+, `17.x` or `18.x` |
34-
| `react-dom` | `16.13.0`+, `17.x` or `18.x` |
35-
| `react-refresh` | `0.10.0`+ |
36-
| `webpack` | `4.46.0`+ or `5.2.0`+ |
30+
| Dependency | Version |
31+
| --------------- | ------------------------------------ |
32+
| `Node.js` | `18.12.0`+, `20.x`, `22.x` |
33+
| `react` | `16.13.0`+, `17.x`, `18.x` or `19.x` |
34+
| `react-dom` | `16.13.0`+, `17.x`, `18.x` or `19.x |
35+
| `react-refresh` | `0.10.0`+ |
36+
| `webpack` | `5.2.0`+ |
3737

3838
<details>
3939
<summary>Minimum requirements</summary>
4040
<br />
4141

42-
| Dependency | Version |
43-
| --------------- | -------- |
44-
| `react` | `16.9.0` |
45-
| `react-dom` | `16.9.0` |
46-
| `react-refresh` | `0.10.0` |
47-
| `webpack` | `4.43.0` |
42+
| Dependency | Version |
43+
| --------------- | --------- |
44+
| `Node.js` | `18.12.0` |
45+
| `react` | `16.9.0` |
46+
| `react-dom` | `16.9.0` |
47+
| `react-refresh` | `0.10.0` |
48+
| `webpack` | `5.2.0` |
4849

4950
</details>
5051

@@ -319,11 +320,11 @@ but you can set the [`overlay.sockIntegration`](docs/API.md#sockintegration) opt
319320

320321
The supported versions are as follows:
321322

322-
| Dependency | Version |
323-
| ------------------------ | -------------------------- |
324-
| `webpack-dev-server` | `3.6.0`+ or `4.x` or `5.x` |
325-
| `webpack-hot-middleware` | `2.x` |
326-
| `webpack-plugin-serve` | `0.x` or `1.x` |
323+
| Dependency | Version |
324+
| ------------------------ | ----------------- |
325+
| `webpack-dev-server` | `4.8.0`+ or `5.x` |
326+
| `webpack-hot-middleware` | `2.x` |
327+
| `webpack-plugin-serve` | `1.x` |
327328

328329
## API
329330

client/ErrorOverlayEntry.js

Lines changed: 89 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -1,100 +1,103 @@
1-
/* global __react_refresh_error_overlay__, __react_refresh_socket__, __resourceQuery */
1+
/* global __react_refresh_error_overlay__, __react_refresh_socket__ */
22

3-
const events = require('./utils/errorEventHandlers.js');
4-
const formatWebpackErrors = require('./utils/formatWebpackErrors.js');
5-
const runWithPatchedUrl = require('./utils/patchUrl.js');
6-
const runWithRetry = require('./utils/retry.js');
3+
if (process.env.NODE_ENV !== 'production') {
4+
const events = require('./utils/errorEventHandlers.js');
5+
const formatWebpackErrors = require('./utils/formatWebpackErrors.js');
6+
const runWithRetry = require('./utils/retry.js');
77

8-
// Setup error states
9-
let isHotReload = false;
10-
let hasRuntimeErrors = false;
8+
// Setup error states
9+
let isHotReload = false;
10+
let hasRuntimeErrors = false;
1111

12-
/**
13-
* Try dismissing the compile error overlay.
14-
* This will also reset runtime error records (if any),
15-
* because we have new source to evaluate.
16-
* @returns {void}
17-
*/
18-
function tryDismissErrorOverlay() {
19-
__react_refresh_error_overlay__.clearCompileError();
20-
__react_refresh_error_overlay__.clearRuntimeErrors(!hasRuntimeErrors);
21-
hasRuntimeErrors = false;
22-
}
12+
/**
13+
* Try dismissing the compile error overlay.
14+
* This will also reset runtime error records (if any),
15+
* because we have new source to evaluate.
16+
* @returns {void}
17+
*/
18+
const tryDismissErrorOverlay = function () {
19+
__react_refresh_error_overlay__.clearCompileError();
20+
__react_refresh_error_overlay__.clearRuntimeErrors(!hasRuntimeErrors);
21+
hasRuntimeErrors = false;
22+
};
2323

24-
/**
25-
* A function called after a compile success signal is received from Webpack.
26-
* @returns {void}
27-
*/
28-
function handleCompileSuccess() {
29-
isHotReload = true;
24+
/**
25+
* A function called after a compile success signal is received from Webpack.
26+
* @returns {void}
27+
*/
28+
const handleCompileSuccess = function () {
29+
isHotReload = true;
3030

31-
if (isHotReload) {
32-
tryDismissErrorOverlay();
33-
}
34-
}
31+
if (isHotReload) {
32+
tryDismissErrorOverlay();
33+
}
34+
};
3535

36-
/**
37-
* A function called after a compile errored signal is received from Webpack.
38-
* @param {string[]} errors
39-
* @returns {void}
40-
*/
41-
function handleCompileErrors(errors) {
42-
isHotReload = true;
36+
/**
37+
* A function called after a compile errored signal is received from Webpack.
38+
* @param {string[]} errors
39+
* @returns {void}
40+
*/
41+
const handleCompileErrors = function (errors) {
42+
isHotReload = true;
4343

44-
const formattedErrors = formatWebpackErrors(errors);
44+
const formattedErrors = formatWebpackErrors(errors);
4545

46-
// Only show the first error
47-
__react_refresh_error_overlay__.showCompileError(formattedErrors[0]);
48-
}
46+
// Only show the first error
47+
__react_refresh_error_overlay__.showCompileError(formattedErrors[0]);
48+
};
4949

50-
/**
51-
* Handles compilation messages from Webpack.
52-
* Integrates with a compile error overlay.
53-
* @param {*} message A Webpack HMR message sent via WebSockets.
54-
* @returns {void}
55-
*/
56-
function compileMessageHandler(message) {
57-
switch (message.type) {
58-
case 'ok':
59-
case 'still-ok':
60-
case 'warnings': {
61-
// TODO: Implement handling for warnings
62-
handleCompileSuccess();
63-
break;
64-
}
65-
case 'errors': {
66-
handleCompileErrors(message.data);
67-
break;
68-
}
69-
default: {
70-
// Do nothing.
50+
/**
51+
* Handles compilation messages from Webpack.
52+
* Integrates with a compile error overlay.
53+
* @param {*} message A Webpack HMR message sent via WebSockets.
54+
* @returns {void}
55+
*/
56+
const compileMessageHandler = function (message) {
57+
switch (message.type) {
58+
case 'ok':
59+
case 'still-ok':
60+
case 'warnings': {
61+
// TODO: Implement handling for warnings
62+
handleCompileSuccess();
63+
break;
64+
}
65+
case 'errors': {
66+
handleCompileErrors(message.data);
67+
break;
68+
}
69+
default: {
70+
// Do nothing.
71+
}
7172
}
72-
}
73-
}
73+
};
7474

75-
if (process.env.NODE_ENV !== 'production') {
76-
if (typeof window !== 'undefined') {
77-
runWithPatchedUrl(function setupOverlay() {
78-
// Only register if no other overlay have been registered
79-
if (!window.__reactRefreshOverlayInjected && __react_refresh_socket__) {
80-
// Registers handlers for compile errors with retry -
81-
// This is to prevent mismatching injection order causing errors to be thrown
82-
runWithRetry(function initSocket() {
83-
__react_refresh_socket__.init(compileMessageHandler, __resourceQuery);
84-
}, 3);
85-
// Registers handlers for runtime errors
86-
events.handleError(function handleError(error) {
87-
hasRuntimeErrors = true;
88-
__react_refresh_error_overlay__.handleRuntimeError(error);
89-
});
90-
events.handleUnhandledRejection(function handleUnhandledPromiseRejection(error) {
91-
hasRuntimeErrors = true;
92-
__react_refresh_error_overlay__.handleRuntimeError(error);
93-
});
94-
95-
// Mark overlay as injected to prevent double-injection
96-
window.__reactRefreshOverlayInjected = true;
97-
}
75+
// Only register if no other overlay have been registered
76+
if (
77+
typeof window !== 'undefined' &&
78+
!window.__reactRefreshOverlayInjected &&
79+
__react_refresh_socket__
80+
) {
81+
// Registers handlers for compile errors with retry -
82+
// This is to prevent mismatching injection order causing errors to be thrown
83+
runWithRetry(
84+
function initSocket() {
85+
__react_refresh_socket__.init(compileMessageHandler);
86+
},
87+
3,
88+
'Failed to set up the socket connection.'
89+
);
90+
// Registers handlers for runtime errors
91+
events.handleError(function handleError(error) {
92+
hasRuntimeErrors = true;
93+
__react_refresh_error_overlay__.handleRuntimeError(error);
9894
});
95+
events.handleUnhandledRejection(function handleUnhandledPromiseRejection(error) {
96+
hasRuntimeErrors = true;
97+
__react_refresh_error_overlay__.handleRuntimeError(error);
98+
});
99+
100+
// Mark overlay as injected to prevent double-injection
101+
window.__reactRefreshOverlayInjected = true;
99102
}
100103
}

client/ReactRefreshEntry.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
/* global __react_refresh_library__ */
22

3-
const safeThis = require('core-js-pure/features/global-this');
4-
const RefreshRuntime = require('react-refresh/runtime');
5-
63
if (process.env.NODE_ENV !== 'production') {
4+
const safeThis = require('core-js-pure/features/global-this');
5+
const RefreshRuntime = require('react-refresh/runtime');
6+
77
if (typeof safeThis !== 'undefined') {
88
var $RefreshInjected$ = '__reactRefreshInjected';
99
// Namespace the injected flag (if necessary) for monorepo compatibility

client/utils/patchUrl.js

Lines changed: 0 additions & 40 deletions
This file was deleted.

0 commit comments

Comments
 (0)