@rspack/plugin-react-refresh 1.5.0 → 1.5.2
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.
- package/README.md +15 -0
- package/client/overlay/index.js +6 -1
- package/client/reactRefresh.js +7 -1
- package/client/refreshUtils.js +14 -0
- package/dist/index.d.ts +4 -1
- package/dist/index.js +223 -84
- package/dist/options.d.ts +5 -0
- package/dist/paths.d.ts +2 -2
- package/dist/sockets/WDSSocket.js +55 -34
- package/dist/sockets/WHMEventSource.js +44 -26
- package/dist/sockets/utils/getCurrentScriptSource.js +37 -14
- package/dist/sockets/utils/getSocketUrlParts.js +60 -81
- package/dist/sockets/utils/getUrlFromParts.js +37 -17
- package/dist/sockets/utils/getWDSMetadata.js +37 -22
- package/exports/index.d.mts +1 -1
- package/exports/index.mjs +5 -1
- package/package.json +9 -6
- package/dist/options.js +0 -39
- package/dist/paths.js +0 -19
- package/dist/utils/getAdditionalEntries.js +0 -88
- package/dist/utils/getIntegrationEntry.js +0 -18
- package/dist/utils/getSocketIntegration.js +0 -21
package/README.md
CHANGED
|
@@ -217,6 +217,21 @@ new ReactRefreshPlugin({
|
|
|
217
217
|
});
|
|
218
218
|
```
|
|
219
219
|
|
|
220
|
+
### reloadOnRuntimeErrors
|
|
221
|
+
|
|
222
|
+
- Type: `boolean`
|
|
223
|
+
- Default: `false`
|
|
224
|
+
|
|
225
|
+
Config the plugin whether trigger a full page reload when an unrecoverable runtime error is encountered.
|
|
226
|
+
|
|
227
|
+
Currently, only module factory undefined error is considered as unrecoverable runtime error.
|
|
228
|
+
|
|
229
|
+
```js
|
|
230
|
+
new ReactRefreshPlugin({
|
|
231
|
+
reloadOnRuntimeErrors: true,
|
|
232
|
+
});
|
|
233
|
+
```
|
|
234
|
+
|
|
220
235
|
## Credits
|
|
221
236
|
|
|
222
237
|
Thanks to the [react-refresh-webpack-plugin](https://github.com/pmmmwh/react-refresh-webpack-plugin) created by [@pmmmwh](https://github.com/pmmmwh), which inspires implement this plugin.
|
package/client/overlay/index.js
CHANGED
|
@@ -240,7 +240,12 @@ function render() {
|
|
|
240
240
|
*/
|
|
241
241
|
function cleanup() {
|
|
242
242
|
// Clean up and reset all internal state.
|
|
243
|
-
|
|
243
|
+
try {
|
|
244
|
+
document.body.removeChild(iframeRoot);
|
|
245
|
+
} catch (e) {
|
|
246
|
+
// In case user render react app directly to body, will trigger `NotFoundError` when recovery from an Error
|
|
247
|
+
// https://developer.mozilla.org/en-US/docs/Web/API/Node/removeChild#exceptions
|
|
248
|
+
}
|
|
244
249
|
scheduledRenderFn = null;
|
|
245
250
|
root = null;
|
|
246
251
|
iframeRoot = null;
|
package/client/reactRefresh.js
CHANGED
|
@@ -14,7 +14,13 @@ function refresh(moduleId, webpackHot) {
|
|
|
14
14
|
if (typeof __react_refresh_test__ !== 'undefined') {
|
|
15
15
|
testMode = __react_refresh_test__;
|
|
16
16
|
}
|
|
17
|
-
RefreshUtils.executeRuntime(
|
|
17
|
+
RefreshUtils.executeRuntime(
|
|
18
|
+
exports,
|
|
19
|
+
moduleId,
|
|
20
|
+
webpackHot,
|
|
21
|
+
errorOverlay,
|
|
22
|
+
testMode,
|
|
23
|
+
);
|
|
18
24
|
};
|
|
19
25
|
if (typeof Promise !== 'undefined' && currentExports instanceof Promise) {
|
|
20
26
|
currentExports.then(fn);
|
package/client/refreshUtils.js
CHANGED
|
@@ -209,6 +209,7 @@ function shouldInvalidateReactRefreshBoundary(prevExports, nextExports) {
|
|
|
209
209
|
}
|
|
210
210
|
|
|
211
211
|
var enqueueUpdate = createDebounceUpdate();
|
|
212
|
+
|
|
212
213
|
function executeRuntime(
|
|
213
214
|
moduleExports,
|
|
214
215
|
moduleId,
|
|
@@ -245,6 +246,15 @@ function executeRuntime(
|
|
|
245
246
|
* @returns {void}
|
|
246
247
|
*/
|
|
247
248
|
function hotErrorHandler(error) {
|
|
249
|
+
console.error(error);
|
|
250
|
+
if (
|
|
251
|
+
__reload_on_runtime_errors__ &&
|
|
252
|
+
isUnrecoverableRuntimeError(error)
|
|
253
|
+
) {
|
|
254
|
+
location.reload();
|
|
255
|
+
return;
|
|
256
|
+
}
|
|
257
|
+
|
|
248
258
|
if (typeof refreshOverlay !== 'undefined' && refreshOverlay) {
|
|
249
259
|
refreshOverlay.handleRuntimeError(error);
|
|
250
260
|
}
|
|
@@ -287,6 +297,10 @@ function executeRuntime(
|
|
|
287
297
|
}
|
|
288
298
|
}
|
|
289
299
|
|
|
300
|
+
function isUnrecoverableRuntimeError(error) {
|
|
301
|
+
return error.message.startsWith('RuntimeError: factory is undefined');
|
|
302
|
+
}
|
|
303
|
+
|
|
290
304
|
module.exports = Object.freeze({
|
|
291
305
|
enqueueUpdate: enqueueUpdate,
|
|
292
306
|
executeRuntime: executeRuntime,
|
package/dist/index.d.ts
CHANGED
|
@@ -3,7 +3,10 @@ import type { NormalizedPluginOptions, PluginOptions } from './options';
|
|
|
3
3
|
export type { PluginOptions };
|
|
4
4
|
declare class ReactRefreshRspackPlugin {
|
|
5
5
|
options: NormalizedPluginOptions;
|
|
6
|
-
|
|
6
|
+
/**
|
|
7
|
+
* @deprecated
|
|
8
|
+
*/
|
|
9
|
+
static get deprecated_runtimePaths(): string[];
|
|
7
10
|
static loader: string;
|
|
8
11
|
constructor(options?: PluginOptions);
|
|
9
12
|
apply(compiler: Compiler): void;
|
package/dist/index.js
CHANGED
|
@@ -1,116 +1,255 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.n = (module)=>{
|
|
5
|
+
var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
|
|
6
|
+
__webpack_require__.d(getter, {
|
|
7
|
+
a: getter
|
|
8
|
+
});
|
|
9
|
+
return getter;
|
|
10
|
+
};
|
|
11
|
+
})();
|
|
12
|
+
(()=>{
|
|
13
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
14
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
get: definition[key]
|
|
17
|
+
});
|
|
18
|
+
};
|
|
19
|
+
})();
|
|
20
|
+
(()=>{
|
|
21
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
22
|
+
})();
|
|
23
|
+
(()=>{
|
|
24
|
+
__webpack_require__.r = (exports1)=>{
|
|
25
|
+
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
26
|
+
value: 'Module'
|
|
27
|
+
});
|
|
28
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
29
|
+
value: true
|
|
30
|
+
});
|
|
31
|
+
};
|
|
32
|
+
})();
|
|
33
|
+
var __webpack_exports__ = {};
|
|
34
|
+
__webpack_require__.r(__webpack_exports__);
|
|
35
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
36
|
+
ReactRefreshRspackPlugin: ()=>ReactRefreshRspackPlugin,
|
|
37
|
+
default: ()=>src
|
|
38
|
+
});
|
|
39
|
+
const external_node_path_namespaceObject = require("node:path");
|
|
40
|
+
var external_node_path_default = /*#__PURE__*/ __webpack_require__.n(external_node_path_namespaceObject);
|
|
41
|
+
const d = (object, property, defaultValue)=>{
|
|
42
|
+
if (void 0 === object[property] && void 0 !== defaultValue) object[property] = defaultValue;
|
|
43
|
+
return object[property];
|
|
4
44
|
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
45
|
+
const normalizeOverlay = (options)=>{
|
|
46
|
+
const defaultOverlay = {
|
|
47
|
+
entry: external_node_path_default().join(__dirname, '../client/errorOverlayEntry.js'),
|
|
48
|
+
module: external_node_path_default().join(__dirname, '../client/overlay/index.js'),
|
|
49
|
+
sockIntegration: 'wds'
|
|
50
|
+
};
|
|
51
|
+
if (!options) return false;
|
|
52
|
+
if (void 0 === options || true === options) return defaultOverlay;
|
|
53
|
+
options.entry = options.entry ?? defaultOverlay.entry;
|
|
54
|
+
options.module = options.module ?? defaultOverlay.module;
|
|
55
|
+
options.sockIntegration = options.sockIntegration ?? defaultOverlay.sockIntegration;
|
|
56
|
+
return options;
|
|
57
|
+
};
|
|
58
|
+
function normalizeOptions(options) {
|
|
59
|
+
d(options, 'exclude', /node_modules/i);
|
|
60
|
+
d(options, 'include', /\.([cm]js|[jt]sx?|flow)$/i);
|
|
61
|
+
d(options, 'library');
|
|
62
|
+
d(options, 'forceEnable', false);
|
|
63
|
+
d(options, 'injectLoader', true);
|
|
64
|
+
d(options, 'injectEntry', true);
|
|
65
|
+
d(options, 'reloadOnRuntimeErrors', false);
|
|
66
|
+
options.overlay = normalizeOverlay(options.overlay);
|
|
67
|
+
return options;
|
|
68
|
+
}
|
|
69
|
+
const reactRefreshPath = external_node_path_default().join(__dirname, '../client/reactRefresh.js');
|
|
70
|
+
const reactRefreshEntryPath = external_node_path_default().join(__dirname, '../client/reactRefreshEntry.js');
|
|
71
|
+
const refreshUtilsPath = external_node_path_default().join(__dirname, '../client/refreshUtils.js');
|
|
72
|
+
let refreshRuntimeDirPath;
|
|
73
|
+
function getRefreshRuntimeDirPath() {
|
|
74
|
+
if (!refreshRuntimeDirPath) refreshRuntimeDirPath = external_node_path_default().dirname(require.resolve('react-refresh', {
|
|
75
|
+
paths: [
|
|
76
|
+
reactRefreshPath
|
|
77
|
+
]
|
|
78
|
+
}));
|
|
79
|
+
return refreshRuntimeDirPath;
|
|
80
|
+
}
|
|
81
|
+
const getRefreshRuntimePaths = ()=>[
|
|
82
|
+
reactRefreshEntryPath,
|
|
83
|
+
reactRefreshPath,
|
|
84
|
+
refreshUtilsPath,
|
|
85
|
+
getRefreshRuntimeDirPath()
|
|
86
|
+
];
|
|
87
|
+
const external_node_querystring_namespaceObject = require("node:querystring");
|
|
88
|
+
var external_node_querystring_default = /*#__PURE__*/ __webpack_require__.n(external_node_querystring_namespaceObject);
|
|
89
|
+
function getAdditionalEntries({ devServer, options }) {
|
|
90
|
+
const resourceQuery = {};
|
|
91
|
+
if (devServer) {
|
|
92
|
+
const { client, https, http2, sockHost, sockPath, sockPort } = devServer;
|
|
93
|
+
let { host, path, port } = devServer;
|
|
94
|
+
let protocol = https || http2 ? 'https' : 'http';
|
|
95
|
+
if (sockHost) host = sockHost;
|
|
96
|
+
if (sockPath) path = sockPath;
|
|
97
|
+
if (sockPort) port = sockPort;
|
|
98
|
+
if (client && null != client.webSocketURL) {
|
|
99
|
+
let parsedUrl = client.webSocketURL;
|
|
100
|
+
if ('string' == typeof parsedUrl) parsedUrl = new URL(parsedUrl);
|
|
101
|
+
let auth;
|
|
102
|
+
if (parsedUrl.username) {
|
|
103
|
+
auth = parsedUrl.username;
|
|
104
|
+
if (parsedUrl.password) auth += `:${parsedUrl.password}`;
|
|
105
|
+
}
|
|
106
|
+
if (null != parsedUrl.hostname) host = [
|
|
107
|
+
null != auth && auth,
|
|
108
|
+
parsedUrl.hostname
|
|
109
|
+
].filter(Boolean).join('@');
|
|
110
|
+
if (null != parsedUrl.pathname) path = parsedUrl.pathname;
|
|
111
|
+
if (null != parsedUrl.port) port = [
|
|
112
|
+
'0',
|
|
113
|
+
'auto'
|
|
114
|
+
].includes(String(parsedUrl.port)) ? void 0 : parsedUrl.port;
|
|
115
|
+
if (null != parsedUrl.protocol) protocol = 'auto' !== parsedUrl.protocol ? parsedUrl.protocol.replace(':', '') : 'ws';
|
|
116
|
+
}
|
|
117
|
+
if (host) resourceQuery.sockHost = host;
|
|
118
|
+
if (path) resourceQuery.sockPath = path;
|
|
119
|
+
if (port) resourceQuery.sockPort = port;
|
|
120
|
+
resourceQuery.sockProtocol = protocol;
|
|
121
|
+
}
|
|
122
|
+
if (options.overlay) {
|
|
123
|
+
const { sockHost, sockPath, sockPort, sockProtocol } = options.overlay;
|
|
124
|
+
if (sockHost) resourceQuery.sockHost = sockHost;
|
|
125
|
+
if (sockPath) resourceQuery.sockPath = sockPath;
|
|
126
|
+
if (sockPort) resourceQuery.sockPort = sockPort;
|
|
127
|
+
if (sockProtocol) resourceQuery.sockProtocol = sockProtocol;
|
|
128
|
+
}
|
|
129
|
+
const queryString = external_node_querystring_default().stringify(resourceQuery, void 0, void 0, {
|
|
130
|
+
encodeURIComponent (str) {
|
|
131
|
+
return str;
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
const prependEntries = [
|
|
135
|
+
reactRefreshEntryPath
|
|
136
|
+
];
|
|
137
|
+
const overlayEntries = [
|
|
138
|
+
false !== options.overlay && options.overlay?.entry && `${require.resolve(options.overlay.entry)}${queryString ? `?${queryString}` : ''}`
|
|
139
|
+
].filter(Boolean);
|
|
140
|
+
return {
|
|
141
|
+
prependEntries,
|
|
142
|
+
overlayEntries
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
function getIntegrationEntry(integrationType) {
|
|
146
|
+
let resolvedEntry;
|
|
147
|
+
switch(integrationType){
|
|
148
|
+
case 'whm':
|
|
149
|
+
resolvedEntry = 'webpack-hot-middleware/client';
|
|
150
|
+
break;
|
|
151
|
+
}
|
|
152
|
+
return resolvedEntry;
|
|
153
|
+
}
|
|
154
|
+
function getSocketIntegration(integrationType) {
|
|
155
|
+
let resolvedSocketIntegration;
|
|
156
|
+
switch(integrationType){
|
|
157
|
+
case 'wds':
|
|
158
|
+
resolvedSocketIntegration = external_node_path_default().join(__dirname, './sockets/WDSSocket.js');
|
|
159
|
+
break;
|
|
160
|
+
case 'whm':
|
|
161
|
+
resolvedSocketIntegration = external_node_path_default().join(__dirname, './sockets/WHMEventSource.js');
|
|
162
|
+
break;
|
|
163
|
+
default:
|
|
164
|
+
resolvedSocketIntegration = require.resolve(integrationType);
|
|
165
|
+
break;
|
|
166
|
+
}
|
|
167
|
+
return resolvedSocketIntegration;
|
|
168
|
+
}
|
|
13
169
|
function addEntry(entry, compiler) {
|
|
14
170
|
new compiler.webpack.EntryPlugin(compiler.context, entry, {
|
|
15
|
-
name:
|
|
171
|
+
name: void 0
|
|
16
172
|
}).apply(compiler);
|
|
17
173
|
}
|
|
18
174
|
function addSocketEntry(sockIntegration, compiler) {
|
|
19
|
-
const integrationEntry =
|
|
20
|
-
if (integrationEntry)
|
|
21
|
-
addEntry(integrationEntry, compiler);
|
|
22
|
-
}
|
|
175
|
+
const integrationEntry = getIntegrationEntry(sockIntegration);
|
|
176
|
+
if (integrationEntry) addEntry(integrationEntry, compiler);
|
|
23
177
|
}
|
|
24
178
|
const PLUGIN_NAME = 'ReactRefreshRspackPlugin';
|
|
25
179
|
class ReactRefreshRspackPlugin {
|
|
26
|
-
|
|
27
|
-
|
|
180
|
+
options;
|
|
181
|
+
static get deprecated_runtimePaths() {
|
|
182
|
+
return getRefreshRuntimePaths();
|
|
183
|
+
}
|
|
184
|
+
static loader = 'builtin:react-refresh-loader';
|
|
185
|
+
constructor(options = {}){
|
|
186
|
+
this.options = normalizeOptions(options);
|
|
28
187
|
}
|
|
29
188
|
apply(compiler) {
|
|
30
|
-
if (
|
|
31
|
-
|
|
32
|
-
// Ref: https://github.com/webpack/webpack/issues/7074
|
|
33
|
-
(compiler.options.mode !== 'development' ||
|
|
34
|
-
// We also check for production process.env.NODE_ENV,
|
|
35
|
-
// in case it was set and mode is non-development (e.g. 'none')
|
|
36
|
-
(process.env.NODE_ENV && process.env.NODE_ENV === 'production')) &&
|
|
37
|
-
!this.options.forceEnable) {
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
40
|
-
const addEntries = (0, getAdditionalEntries_1.getAdditionalEntries)({
|
|
189
|
+
if (('development' !== compiler.options.mode || process.env.NODE_ENV && 'production' === process.env.NODE_ENV) && !this.options.forceEnable) return;
|
|
190
|
+
const addEntries = getAdditionalEntries({
|
|
41
191
|
devServer: compiler.options.devServer,
|
|
42
|
-
options: this.options
|
|
192
|
+
options: this.options
|
|
43
193
|
});
|
|
44
|
-
if (this.options.injectEntry)
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
if (this.options.overlay !== false &&
|
|
50
|
-
this.options.overlay.sockIntegration) {
|
|
51
|
-
addSocketEntry(this.options.overlay.sockIntegration, compiler);
|
|
52
|
-
}
|
|
53
|
-
for (const entry of addEntries.overlayEntries) {
|
|
54
|
-
addEntry(entry, compiler);
|
|
55
|
-
}
|
|
194
|
+
if (this.options.injectEntry) for (const entry of addEntries.prependEntries)addEntry(entry, compiler);
|
|
195
|
+
if (false !== this.options.overlay && this.options.overlay.sockIntegration) addSocketEntry(this.options.overlay.sockIntegration, compiler);
|
|
196
|
+
for (const entry of addEntries.overlayEntries)addEntry(entry, compiler);
|
|
56
197
|
new compiler.webpack.ProvidePlugin({
|
|
57
|
-
$ReactRefreshRuntime$:
|
|
198
|
+
$ReactRefreshRuntime$: reactRefreshPath
|
|
58
199
|
}).apply(compiler);
|
|
59
|
-
if (this.options.injectLoader) {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
}
|
|
76
|
-
|
|
200
|
+
if (this.options.injectLoader) compiler.options.module.rules.unshift({
|
|
201
|
+
test: this.options.test,
|
|
202
|
+
include: this.options.include,
|
|
203
|
+
exclude: {
|
|
204
|
+
or: [
|
|
205
|
+
this.options.exclude,
|
|
206
|
+
[
|
|
207
|
+
...getRefreshRuntimePaths()
|
|
208
|
+
]
|
|
209
|
+
].filter(Boolean)
|
|
210
|
+
},
|
|
211
|
+
resourceQuery: this.options.resourceQuery,
|
|
212
|
+
dependency: {
|
|
213
|
+
not: [
|
|
214
|
+
'url'
|
|
215
|
+
]
|
|
216
|
+
},
|
|
217
|
+
use: ReactRefreshRspackPlugin.loader
|
|
218
|
+
});
|
|
77
219
|
const definedModules = {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
compiler.options.output.uniqueName ||
|
|
81
|
-
compiler.options.output.library)),
|
|
220
|
+
__react_refresh_library__: JSON.stringify(compiler.webpack.Template.toIdentifier(this.options.library || compiler.options.output.uniqueName || compiler.options.output.library)),
|
|
221
|
+
__reload_on_runtime_errors__: this.options.reloadOnRuntimeErrors
|
|
82
222
|
};
|
|
83
223
|
const providedModules = {
|
|
84
|
-
__react_refresh_utils__:
|
|
224
|
+
__react_refresh_utils__: refreshUtilsPath
|
|
85
225
|
};
|
|
86
|
-
if (this.options.overlay
|
|
87
|
-
// Stub errorOverlay module so their calls can be erased
|
|
226
|
+
if (false === this.options.overlay) {
|
|
88
227
|
definedModules.__react_refresh_error_overlay__ = false;
|
|
89
228
|
definedModules.__react_refresh_socket__ = false;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
if (this.options.overlay.
|
|
93
|
-
providedModules.__react_refresh_error_overlay__ = require.resolve(this.options.overlay.module);
|
|
94
|
-
}
|
|
95
|
-
if (this.options.overlay.sockIntegration) {
|
|
96
|
-
providedModules.__react_refresh_socket__ = (0, getSocketIntegration_1.getSocketIntegration)(this.options.overlay.sockIntegration);
|
|
97
|
-
}
|
|
229
|
+
} else {
|
|
230
|
+
if (this.options.overlay.module) providedModules.__react_refresh_error_overlay__ = require.resolve(this.options.overlay.module);
|
|
231
|
+
if (this.options.overlay.sockIntegration) providedModules.__react_refresh_socket__ = getSocketIntegration(this.options.overlay.sockIntegration);
|
|
98
232
|
}
|
|
99
233
|
new compiler.webpack.DefinePlugin(definedModules).apply(compiler);
|
|
100
234
|
new compiler.webpack.ProvidePlugin(providedModules).apply(compiler);
|
|
101
|
-
const refreshPath = node_path_1.default.dirname(require.resolve('react-refresh'));
|
|
102
235
|
compiler.options.resolve.alias = {
|
|
103
|
-
'react-refresh':
|
|
104
|
-
...compiler.options.resolve.alias
|
|
236
|
+
'react-refresh': getRefreshRuntimeDirPath(),
|
|
237
|
+
...compiler.options.resolve.alias
|
|
105
238
|
};
|
|
106
|
-
compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation)
|
|
107
|
-
compilation.hooks.additionalTreeRuntimeRequirements.tap(PLUGIN_NAME, (_, runtimeRequirements)
|
|
239
|
+
compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation)=>{
|
|
240
|
+
compilation.hooks.additionalTreeRuntimeRequirements.tap(PLUGIN_NAME, (_, runtimeRequirements)=>{
|
|
108
241
|
runtimeRequirements.add(compiler.rspack.RuntimeGlobals.moduleCache);
|
|
109
242
|
});
|
|
110
243
|
});
|
|
111
244
|
}
|
|
112
245
|
}
|
|
113
|
-
|
|
114
|
-
ReactRefreshRspackPlugin
|
|
115
|
-
|
|
116
|
-
|
|
246
|
+
const src = ReactRefreshRspackPlugin;
|
|
247
|
+
exports.ReactRefreshRspackPlugin = __webpack_exports__.ReactRefreshRspackPlugin;
|
|
248
|
+
exports["default"] = __webpack_exports__["default"];
|
|
249
|
+
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
250
|
+
"ReactRefreshRspackPlugin",
|
|
251
|
+
"default"
|
|
252
|
+
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
253
|
+
Object.defineProperty(exports, '__esModule', {
|
|
254
|
+
value: true
|
|
255
|
+
});
|
package/dist/options.d.ts
CHANGED
|
@@ -75,6 +75,11 @@ export type PluginOptions = {
|
|
|
75
75
|
* @default true
|
|
76
76
|
*/
|
|
77
77
|
injectEntry?: boolean;
|
|
78
|
+
/**
|
|
79
|
+
* Whether to reload the page on runtime errors. E.g: undefined module factory
|
|
80
|
+
* @default false
|
|
81
|
+
*/
|
|
82
|
+
reloadOnRuntimeErrors?: boolean;
|
|
78
83
|
};
|
|
79
84
|
export interface NormalizedPluginOptions extends Required<PluginOptions> {
|
|
80
85
|
overlay: false | OverlayOptions;
|
package/dist/paths.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export declare const reactRefreshPath: string;
|
|
2
2
|
export declare const reactRefreshEntryPath: string;
|
|
3
3
|
export declare const refreshUtilsPath: string;
|
|
4
|
-
export declare
|
|
5
|
-
export declare const
|
|
4
|
+
export declare function getRefreshRuntimeDirPath(): string;
|
|
5
|
+
export declare const getRefreshRuntimePaths: () => string[];
|
|
@@ -1,42 +1,63 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.n = (module)=>{
|
|
5
|
+
var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
|
|
6
|
+
__webpack_require__.d(getter, {
|
|
7
|
+
a: getter
|
|
8
|
+
});
|
|
9
|
+
return getter;
|
|
10
|
+
};
|
|
11
|
+
})();
|
|
12
|
+
(()=>{
|
|
13
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
14
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
get: definition[key]
|
|
17
|
+
});
|
|
18
|
+
};
|
|
19
|
+
})();
|
|
20
|
+
(()=>{
|
|
21
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
22
|
+
})();
|
|
23
|
+
(()=>{
|
|
24
|
+
__webpack_require__.r = (exports1)=>{
|
|
25
|
+
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
26
|
+
value: 'Module'
|
|
27
|
+
});
|
|
28
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
29
|
+
value: true
|
|
30
|
+
});
|
|
31
|
+
};
|
|
32
|
+
})();
|
|
33
|
+
var __webpack_exports__ = {};
|
|
34
|
+
__webpack_require__.r(__webpack_exports__);
|
|
35
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
36
|
+
init: ()=>init
|
|
37
|
+
});
|
|
38
|
+
const getSocketUrlParts_js_namespaceObject = require("./utils/getSocketUrlParts.js");
|
|
39
|
+
var getSocketUrlParts_js_default = /*#__PURE__*/ __webpack_require__.n(getSocketUrlParts_js_namespaceObject);
|
|
40
|
+
const getUrlFromParts_js_namespaceObject = require("./utils/getUrlFromParts.js");
|
|
41
|
+
var getUrlFromParts_js_default = /*#__PURE__*/ __webpack_require__.n(getUrlFromParts_js_namespaceObject);
|
|
42
|
+
const getWDSMetadata_js_namespaceObject = require("./utils/getWDSMetadata.js");
|
|
43
|
+
var getWDSMetadata_js_default = /*#__PURE__*/ __webpack_require__.n(getWDSMetadata_js_namespaceObject);
|
|
25
44
|
function init(messageHandler, resourceQuery) {
|
|
26
|
-
if (typeof __webpack_dev_server_client__
|
|
45
|
+
if ('undefined' != typeof __webpack_dev_server_client__) {
|
|
27
46
|
let SocketClient;
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}
|
|
34
|
-
const wdsMeta = (0, getWDSMetadata_1.default)(SocketClient);
|
|
35
|
-
const urlParts = (0, getSocketUrlParts_1.default)(resourceQuery, wdsMeta);
|
|
36
|
-
const connection = new SocketClient((0, getUrlFromParts_1.default)(urlParts, wdsMeta));
|
|
37
|
-
connection.onMessage(function onSocketMessage(data) {
|
|
47
|
+
SocketClient = 'default' in __webpack_dev_server_client__ ? __webpack_dev_server_client__.default : __webpack_dev_server_client__;
|
|
48
|
+
const wdsMeta = getWDSMetadata_js_default()(SocketClient);
|
|
49
|
+
const urlParts = getSocketUrlParts_js_default()(resourceQuery, wdsMeta);
|
|
50
|
+
const connection = new SocketClient(getUrlFromParts_js_default()(urlParts, wdsMeta));
|
|
51
|
+
connection.onMessage(function(data) {
|
|
38
52
|
const message = JSON.parse(data);
|
|
39
53
|
messageHandler(message);
|
|
40
54
|
});
|
|
41
55
|
}
|
|
42
56
|
}
|
|
57
|
+
exports.init = __webpack_exports__.init;
|
|
58
|
+
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
59
|
+
"init"
|
|
60
|
+
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
61
|
+
Object.defineProperty(exports, '__esModule', {
|
|
62
|
+
value: true
|
|
63
|
+
});
|
|
@@ -1,34 +1,52 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
5
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: definition[key]
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
})();
|
|
11
|
+
(()=>{
|
|
12
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
13
|
+
})();
|
|
14
|
+
(()=>{
|
|
15
|
+
__webpack_require__.r = (exports1)=>{
|
|
16
|
+
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
17
|
+
value: 'Module'
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
20
|
+
value: true
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
})();
|
|
24
|
+
var __webpack_exports__ = {};
|
|
25
|
+
__webpack_require__.r(__webpack_exports__);
|
|
26
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
+
init: ()=>init
|
|
28
|
+
});
|
|
18
29
|
const singletonKey = '__webpack_hot_middleware_reporter__';
|
|
19
|
-
/**
|
|
20
|
-
* Initializes a socket server for HMR for webpack-hot-middleware.
|
|
21
|
-
* @param {function(*): void} messageHandler A handler to consume Webpack compilation messages.
|
|
22
|
-
* @returns {void}
|
|
23
|
-
*/
|
|
24
30
|
function init(messageHandler) {
|
|
25
31
|
const client = window[singletonKey];
|
|
26
32
|
client.useCustomOverlay({
|
|
27
|
-
showProblems(type, data) {
|
|
28
|
-
messageHandler({
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
33
|
+
showProblems (type, data) {
|
|
34
|
+
messageHandler({
|
|
35
|
+
type,
|
|
36
|
+
data
|
|
37
|
+
});
|
|
32
38
|
},
|
|
39
|
+
clear () {
|
|
40
|
+
messageHandler({
|
|
41
|
+
type: 'ok'
|
|
42
|
+
});
|
|
43
|
+
}
|
|
33
44
|
});
|
|
34
45
|
}
|
|
46
|
+
exports.init = __webpack_exports__.init;
|
|
47
|
+
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
48
|
+
"init"
|
|
49
|
+
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
50
|
+
Object.defineProperty(exports, '__esModule', {
|
|
51
|
+
value: true
|
|
52
|
+
});
|
|
@@ -1,22 +1,45 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
5
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: definition[key]
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
})();
|
|
11
|
+
(()=>{
|
|
12
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
13
|
+
})();
|
|
14
|
+
(()=>{
|
|
15
|
+
__webpack_require__.r = (exports1)=>{
|
|
16
|
+
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
17
|
+
value: 'Module'
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
20
|
+
value: true
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
})();
|
|
24
|
+
var __webpack_exports__ = {};
|
|
25
|
+
__webpack_require__.r(__webpack_exports__);
|
|
26
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
+
default: ()=>getCurrentScriptSource
|
|
28
|
+
});
|
|
4
29
|
function getCurrentScriptSource() {
|
|
5
|
-
// `document.currentScript` is the most accurate way to get the current running script,
|
|
6
|
-
// but is not supported in all browsers (most notably, IE).
|
|
7
30
|
if ('currentScript' in document) {
|
|
8
|
-
|
|
9
|
-
// e.g. asynchronous chunks on Firefox.
|
|
10
|
-
// We should not fallback to the list-approach as it would not be safe.
|
|
11
|
-
if (document.currentScript == null)
|
|
12
|
-
return;
|
|
31
|
+
if (null == document.currentScript) return;
|
|
13
32
|
return document.currentScript.getAttribute('src');
|
|
14
33
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
const scriptElementsWithSrc = Array.prototype.filter.call(document.scripts || [], (elem) => elem.getAttribute('src'));
|
|
18
|
-
if (!scriptElementsWithSrc.length)
|
|
19
|
-
return;
|
|
34
|
+
const scriptElementsWithSrc = Array.prototype.filter.call(document.scripts || [], (elem)=>elem.getAttribute('src'));
|
|
35
|
+
if (!scriptElementsWithSrc.length) return;
|
|
20
36
|
const currentScript = scriptElementsWithSrc[scriptElementsWithSrc.length - 1];
|
|
21
37
|
return currentScript.getAttribute('src');
|
|
22
38
|
}
|
|
39
|
+
exports["default"] = __webpack_exports__["default"];
|
|
40
|
+
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
41
|
+
"default"
|
|
42
|
+
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
43
|
+
Object.defineProperty(exports, '__esModule', {
|
|
44
|
+
value: true
|
|
45
|
+
});
|
|
@@ -1,108 +1,87 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.n = (module)=>{
|
|
5
|
+
var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
|
|
6
|
+
__webpack_require__.d(getter, {
|
|
7
|
+
a: getter
|
|
8
|
+
});
|
|
9
|
+
return getter;
|
|
10
|
+
};
|
|
11
|
+
})();
|
|
12
|
+
(()=>{
|
|
13
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
14
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
get: definition[key]
|
|
17
|
+
});
|
|
18
|
+
};
|
|
19
|
+
})();
|
|
20
|
+
(()=>{
|
|
21
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
22
|
+
})();
|
|
23
|
+
(()=>{
|
|
24
|
+
__webpack_require__.r = (exports1)=>{
|
|
25
|
+
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
26
|
+
value: 'Module'
|
|
27
|
+
});
|
|
28
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
29
|
+
value: true
|
|
30
|
+
});
|
|
31
|
+
};
|
|
32
|
+
})();
|
|
33
|
+
var __webpack_exports__ = {};
|
|
34
|
+
__webpack_require__.r(__webpack_exports__);
|
|
35
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
36
|
+
default: ()=>getSocketUrlParts
|
|
37
|
+
});
|
|
38
|
+
const external_getCurrentScriptSource_js_namespaceObject = require("./getCurrentScriptSource.js");
|
|
39
|
+
var external_getCurrentScriptSource_js_default = /*#__PURE__*/ __webpack_require__.n(external_getCurrentScriptSource_js_namespaceObject);
|
|
8
40
|
function getSocketUrlParts(resourceQuery, metadata = {}) {
|
|
9
41
|
const urlParts = {};
|
|
10
|
-
// If the resource query is available,
|
|
11
|
-
// parse it and ignore everything we received from the script host.
|
|
12
42
|
if (resourceQuery) {
|
|
13
43
|
const parsedQuery = {};
|
|
14
44
|
const searchParams = new URLSearchParams(resourceQuery.slice(1));
|
|
15
|
-
searchParams.forEach((value, key)
|
|
45
|
+
searchParams.forEach((value, key)=>{
|
|
16
46
|
parsedQuery[key] = value;
|
|
17
47
|
});
|
|
18
48
|
urlParts.hostname = parsedQuery.sockHost;
|
|
19
49
|
urlParts.pathname = parsedQuery.sockPath;
|
|
20
50
|
urlParts.port = parsedQuery.sockPort;
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
else {
|
|
27
|
-
const scriptSource = (0, getCurrentScriptSource_1.default)();
|
|
51
|
+
if (parsedQuery.sockProtocol) urlParts.protocol = `${parsedQuery.sockProtocol}:`;
|
|
52
|
+
} else {
|
|
53
|
+
const scriptSource = external_getCurrentScriptSource_js_default()();
|
|
28
54
|
let url = {};
|
|
29
55
|
try {
|
|
30
|
-
// The placeholder `baseURL` with `window.location.href`,
|
|
31
|
-
// is to allow parsing of path-relative or protocol-relative URLs,
|
|
32
|
-
// and will have no effect if `scriptSource` is a fully valid URL.
|
|
33
|
-
// biome-ignore lint: reason
|
|
34
56
|
url = new URL(scriptSource, window.location.href);
|
|
35
|
-
}
|
|
36
|
-
catch (e) {
|
|
37
|
-
// URL parsing failed, do nothing.
|
|
38
|
-
// We will still proceed to see if we can recover using `resourceQuery`
|
|
39
|
-
}
|
|
40
|
-
// Parse authentication credentials in case we need them
|
|
57
|
+
} catch (e) {}
|
|
41
58
|
if (url.username) {
|
|
42
|
-
// Since HTTP basic authentication does not allow empty username,
|
|
43
|
-
// we only include password if the username is not empty.
|
|
44
|
-
// Result: <username> or <username>:<password>
|
|
45
59
|
urlParts.auth = url.username;
|
|
46
|
-
if (url.password) {
|
|
47
|
-
urlParts.auth += `:${url.password}`;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
// `file://` URLs has `'null'` origin
|
|
51
|
-
if (url.origin !== 'null') {
|
|
52
|
-
urlParts.hostname = url.hostname;
|
|
60
|
+
if (url.password) urlParts.auth += `:${url.password}`;
|
|
53
61
|
}
|
|
62
|
+
if ('null' !== url.origin) urlParts.hostname = url.hostname;
|
|
54
63
|
urlParts.protocol = url.protocol;
|
|
55
64
|
urlParts.port = url.port;
|
|
56
65
|
}
|
|
57
|
-
if (!urlParts.pathname)
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
urlParts.pathname = '/sockjs-node';
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
// Check for IPv4 and IPv6 host addresses that correspond to any/empty.
|
|
68
|
-
// This is important because `hostname` can be empty for some hosts,
|
|
69
|
-
// such as 'about:blank' or 'file://' URLs.
|
|
70
|
-
const isEmptyHostname = urlParts.hostname === '0.0.0.0' ||
|
|
71
|
-
urlParts.hostname === '[::]' ||
|
|
72
|
-
!urlParts.hostname;
|
|
73
|
-
// We only re-assign the hostname if it is empty,
|
|
74
|
-
// and if we are using HTTP/HTTPS protocols.
|
|
75
|
-
if (isEmptyHostname &&
|
|
76
|
-
window.location.hostname &&
|
|
77
|
-
window.location.protocol.indexOf('http') === 0) {
|
|
78
|
-
urlParts.hostname = window.location.hostname;
|
|
79
|
-
}
|
|
80
|
-
// We only re-assign `protocol` when `protocol` is unavailable,
|
|
81
|
-
// or if `hostname` is available and is empty,
|
|
82
|
-
// since otherwise we risk creating an invalid URL.
|
|
83
|
-
// We also do this when 'https' is used as it mandates the use of secure sockets.
|
|
84
|
-
if (!urlParts.protocol ||
|
|
85
|
-
(urlParts.hostname &&
|
|
86
|
-
(isEmptyHostname || window.location.protocol === 'https:'))) {
|
|
87
|
-
urlParts.protocol = window.location.protocol;
|
|
88
|
-
}
|
|
89
|
-
// We only re-assign port when it is not available
|
|
90
|
-
if (!urlParts.port) {
|
|
91
|
-
urlParts.port = window.location.port;
|
|
92
|
-
}
|
|
93
|
-
if (!urlParts.hostname || !urlParts.pathname) {
|
|
94
|
-
throw new Error([
|
|
95
|
-
'[React Refresh] Failed to get an URL for the socket connection.',
|
|
96
|
-
"This usually means that the current executed script doesn't have a `src` attribute set.",
|
|
97
|
-
'You should either specify the socket path parameters under the `devServer` key in your Rspack config, or use the `overlay` option.',
|
|
98
|
-
'https://www.rspack.dev/guide/tech/react#fast-refresh',
|
|
99
|
-
].join('\n'));
|
|
100
|
-
}
|
|
66
|
+
if (!urlParts.pathname) if (4 === metadata.version) urlParts.pathname = '/ws';
|
|
67
|
+
else urlParts.pathname = '/sockjs-node';
|
|
68
|
+
const isEmptyHostname = '0.0.0.0' === urlParts.hostname || '[::]' === urlParts.hostname || !urlParts.hostname;
|
|
69
|
+
if (isEmptyHostname && window.location.hostname && 0 === window.location.protocol.indexOf('http')) urlParts.hostname = window.location.hostname;
|
|
70
|
+
if (!urlParts.protocol || urlParts.hostname && (isEmptyHostname || 'https:' === window.location.protocol)) urlParts.protocol = window.location.protocol;
|
|
71
|
+
if (!urlParts.port) urlParts.port = window.location.port;
|
|
72
|
+
if (!urlParts.hostname || !urlParts.pathname) throw new Error("[React Refresh] Failed to get an URL for the socket connection.\nThis usually means that the current executed script doesn't have a `src` attribute set.\nYou should either specify the socket path parameters under the `devServer` key in your Rspack config, or use the `overlay` option.\nhttps://www.rspack.dev/guide/tech/react#fast-refresh");
|
|
101
73
|
return {
|
|
102
74
|
auth: urlParts.auth,
|
|
103
75
|
hostname: urlParts.hostname,
|
|
104
76
|
pathname: urlParts.pathname,
|
|
105
77
|
protocol: urlParts.protocol,
|
|
106
|
-
port: urlParts.port ||
|
|
78
|
+
port: urlParts.port || void 0
|
|
107
79
|
};
|
|
108
80
|
}
|
|
81
|
+
exports["default"] = __webpack_exports__["default"];
|
|
82
|
+
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
83
|
+
"default"
|
|
84
|
+
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
85
|
+
Object.defineProperty(exports, '__esModule', {
|
|
86
|
+
value: true
|
|
87
|
+
});
|
|
@@ -1,29 +1,49 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
5
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: definition[key]
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
})();
|
|
11
|
+
(()=>{
|
|
12
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
13
|
+
})();
|
|
14
|
+
(()=>{
|
|
15
|
+
__webpack_require__.r = (exports1)=>{
|
|
16
|
+
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
17
|
+
value: 'Module'
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
20
|
+
value: true
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
})();
|
|
24
|
+
var __webpack_exports__ = {};
|
|
25
|
+
__webpack_require__.r(__webpack_exports__);
|
|
26
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
+
default: ()=>urlFromParts
|
|
28
|
+
});
|
|
10
29
|
function urlFromParts(urlParts, metadata = {}) {
|
|
11
30
|
let fullProtocol = 'http:';
|
|
12
|
-
if (urlParts.protocol)
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
if (metadata.enforceWs) {
|
|
16
|
-
fullProtocol = fullProtocol.replace(/^(?:http|.+-extension|file)/i, 'ws');
|
|
17
|
-
}
|
|
31
|
+
if (urlParts.protocol) fullProtocol = urlParts.protocol;
|
|
32
|
+
if (metadata.enforceWs) fullProtocol = fullProtocol.replace(/^(?:http|.+-extension|file)/i, 'ws');
|
|
18
33
|
fullProtocol = `${fullProtocol}//`;
|
|
19
34
|
let fullHost = urlParts.hostname;
|
|
20
35
|
if (urlParts.auth) {
|
|
21
36
|
const fullAuth = `${urlParts.auth.split(':').map(encodeURIComponent).join(':')}@`;
|
|
22
37
|
fullHost = fullAuth + fullHost;
|
|
23
38
|
}
|
|
24
|
-
if (urlParts.port) {
|
|
25
|
-
fullHost = `${fullHost}:${urlParts.port}`;
|
|
26
|
-
}
|
|
39
|
+
if (urlParts.port) fullHost = `${fullHost}:${urlParts.port}`;
|
|
27
40
|
const url = new URL(urlParts.pathname, fullProtocol + fullHost);
|
|
28
41
|
return url.href;
|
|
29
42
|
}
|
|
43
|
+
exports["default"] = __webpack_exports__["default"];
|
|
44
|
+
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
45
|
+
"default"
|
|
46
|
+
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
47
|
+
Object.defineProperty(exports, '__esModule', {
|
|
48
|
+
value: true
|
|
49
|
+
});
|
|
@@ -1,30 +1,45 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
5
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: definition[key]
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
})();
|
|
11
|
+
(()=>{
|
|
12
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
13
|
+
})();
|
|
14
|
+
(()=>{
|
|
15
|
+
__webpack_require__.r = (exports1)=>{
|
|
16
|
+
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
17
|
+
value: 'Module'
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
20
|
+
value: true
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
})();
|
|
24
|
+
var __webpack_exports__ = {};
|
|
25
|
+
__webpack_require__.r(__webpack_exports__);
|
|
26
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
+
default: ()=>getWDSMetadata
|
|
28
|
+
});
|
|
4
29
|
function getWDSMetadata(SocketClient) {
|
|
5
30
|
let enforceWs = false;
|
|
6
|
-
if (
|
|
7
|
-
SocketClient.name !== null &&
|
|
8
|
-
SocketClient.name.toLowerCase().includes('websocket')) {
|
|
9
|
-
enforceWs = true;
|
|
10
|
-
}
|
|
31
|
+
if (void 0 !== SocketClient.name && null !== SocketClient.name && SocketClient.name.toLowerCase().includes('websocket')) enforceWs = true;
|
|
11
32
|
let version;
|
|
12
|
-
|
|
13
|
-
if (!('onMessage' in SocketClient.prototype)) {
|
|
14
|
-
version = 3;
|
|
15
|
-
}
|
|
16
|
-
else {
|
|
17
|
-
// WDS versions >=3.5.0 <4
|
|
18
|
-
if ('getClientPath' in SocketClient ||
|
|
19
|
-
Object.getPrototypeOf(SocketClient).name === 'BaseClient') {
|
|
20
|
-
version = 3;
|
|
21
|
-
}
|
|
22
|
-
else {
|
|
23
|
-
version = 4;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
33
|
+
version = 'onMessage' in SocketClient.prototype ? 'getClientPath' in SocketClient || 'BaseClient' === Object.getPrototypeOf(SocketClient).name ? 3 : 4 : 3;
|
|
26
34
|
return {
|
|
27
35
|
enforceWs: enforceWs,
|
|
28
|
-
version: version
|
|
36
|
+
version: version
|
|
29
37
|
};
|
|
30
38
|
}
|
|
39
|
+
exports["default"] = __webpack_exports__["default"];
|
|
40
|
+
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
41
|
+
"default"
|
|
42
|
+
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
43
|
+
Object.defineProperty(exports, '__esModule', {
|
|
44
|
+
value: true
|
|
45
|
+
});
|
package/exports/index.d.mts
CHANGED
package/exports/index.mjs
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
// ES modules wrapper
|
|
2
|
-
import {
|
|
2
|
+
import { createRequire } from 'node:module';
|
|
3
|
+
|
|
4
|
+
const require = createRequire(import.meta.url);
|
|
5
|
+
const { ReactRefreshRspackPlugin } = require('../dist/index.js');
|
|
6
|
+
|
|
3
7
|
// default export will be deprecated in next major version
|
|
4
8
|
export default ReactRefreshRspackPlugin;
|
|
5
9
|
export { ReactRefreshRspackPlugin };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rspack/plugin-react-refresh",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.2",
|
|
4
4
|
"repository": "https://github.com/rspack-contrib/rspack-plugin-react-refresh",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"description": "React refresh plugin for Rspack",
|
|
@@ -32,10 +32,12 @@
|
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@biomejs/biome": "^1.9.4",
|
|
35
|
-
"@rslib/core": "^0.
|
|
36
|
-
"@rspack/core": "1.
|
|
35
|
+
"@rslib/core": "^0.15.1",
|
|
36
|
+
"@rspack/core": "^1.5.8",
|
|
37
37
|
"@types/jest": "29.5.14",
|
|
38
38
|
"@types/node": "^22.17.0",
|
|
39
|
+
"bumpp": "^10.2.3",
|
|
40
|
+
"cac": "^6.7.14",
|
|
39
41
|
"cross-env": "^10.0.0",
|
|
40
42
|
"execa": "9.6.0",
|
|
41
43
|
"fs-extra": "11.3.0",
|
|
@@ -68,11 +70,12 @@
|
|
|
68
70
|
"registry": "https://registry.npmjs.org/"
|
|
69
71
|
},
|
|
70
72
|
"scripts": {
|
|
71
|
-
"build": "
|
|
72
|
-
"dev": "
|
|
73
|
+
"build": "rslib build",
|
|
74
|
+
"dev": "rslib build -w",
|
|
73
75
|
"lint": "biome check .",
|
|
74
76
|
"lint:write": "biome check . --write",
|
|
75
77
|
"test": "jest --colors",
|
|
76
|
-
"release": "node ./scripts/release.mjs"
|
|
78
|
+
"release": "node ./scripts/release.mjs",
|
|
79
|
+
"bump": "npx bumpp --no-push --no-tag --no-commit"
|
|
77
80
|
}
|
|
78
81
|
}
|
package/dist/options.js
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.normalizeOptions = normalizeOptions;
|
|
4
|
-
const d = (object, property, defaultValue) => {
|
|
5
|
-
// TODO: should we also add default for null?
|
|
6
|
-
if (typeof object[property] === 'undefined' &&
|
|
7
|
-
typeof defaultValue !== 'undefined') {
|
|
8
|
-
object[property] = defaultValue;
|
|
9
|
-
}
|
|
10
|
-
return object[property];
|
|
11
|
-
};
|
|
12
|
-
const normalizeOverlay = (options) => {
|
|
13
|
-
const defaultOverlay = {
|
|
14
|
-
entry: require.resolve('../client/errorOverlayEntry.js'),
|
|
15
|
-
module: require.resolve('../client/overlay/index.js'),
|
|
16
|
-
sockIntegration: 'wds',
|
|
17
|
-
};
|
|
18
|
-
if (!options) {
|
|
19
|
-
return false;
|
|
20
|
-
}
|
|
21
|
-
if (typeof options === 'undefined' || options === true) {
|
|
22
|
-
return defaultOverlay;
|
|
23
|
-
}
|
|
24
|
-
options.entry = options.entry ?? defaultOverlay.entry;
|
|
25
|
-
options.module = options.module ?? defaultOverlay.module;
|
|
26
|
-
options.sockIntegration =
|
|
27
|
-
options.sockIntegration ?? defaultOverlay.sockIntegration;
|
|
28
|
-
return options;
|
|
29
|
-
};
|
|
30
|
-
function normalizeOptions(options) {
|
|
31
|
-
d(options, 'exclude', /node_modules/i);
|
|
32
|
-
d(options, 'include', /\.([cm]js|[jt]sx?|flow)$/i);
|
|
33
|
-
d(options, 'library');
|
|
34
|
-
d(options, 'forceEnable', false);
|
|
35
|
-
d(options, 'injectLoader', true);
|
|
36
|
-
d(options, 'injectEntry', true);
|
|
37
|
-
options.overlay = normalizeOverlay(options.overlay);
|
|
38
|
-
return options;
|
|
39
|
-
}
|
package/dist/paths.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.runtimePaths = exports.refreshRuntimeDirPath = exports.refreshUtilsPath = exports.reactRefreshEntryPath = exports.reactRefreshPath = void 0;
|
|
7
|
-
const node_path_1 = __importDefault(require("node:path"));
|
|
8
|
-
exports.reactRefreshPath = require.resolve('../client/reactRefresh.js');
|
|
9
|
-
exports.reactRefreshEntryPath = require.resolve('../client/reactRefreshEntry.js');
|
|
10
|
-
exports.refreshUtilsPath = require.resolve('../client/refreshUtils.js');
|
|
11
|
-
exports.refreshRuntimeDirPath = node_path_1.default.dirname(require.resolve('react-refresh', {
|
|
12
|
-
paths: [exports.reactRefreshPath],
|
|
13
|
-
}));
|
|
14
|
-
exports.runtimePaths = [
|
|
15
|
-
exports.reactRefreshEntryPath,
|
|
16
|
-
exports.reactRefreshPath,
|
|
17
|
-
exports.refreshUtilsPath,
|
|
18
|
-
exports.refreshRuntimeDirPath,
|
|
19
|
-
];
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.getAdditionalEntries = getAdditionalEntries;
|
|
7
|
-
const node_querystring_1 = __importDefault(require("node:querystring"));
|
|
8
|
-
const paths_1 = require("../paths");
|
|
9
|
-
function getAdditionalEntries({ devServer, options, }) {
|
|
10
|
-
const resourceQuery = {};
|
|
11
|
-
if (devServer) {
|
|
12
|
-
const { client, https, http2, sockHost, sockPath, sockPort } = devServer;
|
|
13
|
-
let { host, path, port } = devServer;
|
|
14
|
-
let protocol = https || http2 ? 'https' : 'http';
|
|
15
|
-
if (sockHost)
|
|
16
|
-
host = sockHost;
|
|
17
|
-
if (sockPath)
|
|
18
|
-
path = sockPath;
|
|
19
|
-
if (sockPort)
|
|
20
|
-
port = sockPort;
|
|
21
|
-
if (client && client.webSocketURL != null) {
|
|
22
|
-
let parsedUrl = client.webSocketURL;
|
|
23
|
-
if (typeof parsedUrl === 'string')
|
|
24
|
-
parsedUrl = new URL(parsedUrl);
|
|
25
|
-
let auth;
|
|
26
|
-
if (parsedUrl.username) {
|
|
27
|
-
auth = parsedUrl.username;
|
|
28
|
-
if (parsedUrl.password) {
|
|
29
|
-
auth += `:${parsedUrl.password}`;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
if (parsedUrl.hostname != null) {
|
|
33
|
-
host = [auth != null && auth, parsedUrl.hostname]
|
|
34
|
-
.filter(Boolean)
|
|
35
|
-
.join('@');
|
|
36
|
-
}
|
|
37
|
-
if (parsedUrl.pathname != null) {
|
|
38
|
-
path = parsedUrl.pathname;
|
|
39
|
-
}
|
|
40
|
-
if (parsedUrl.port != null) {
|
|
41
|
-
port = !['0', 'auto'].includes(String(parsedUrl.port))
|
|
42
|
-
? parsedUrl.port
|
|
43
|
-
: undefined;
|
|
44
|
-
}
|
|
45
|
-
if (parsedUrl.protocol != null) {
|
|
46
|
-
protocol =
|
|
47
|
-
parsedUrl.protocol !== 'auto'
|
|
48
|
-
? parsedUrl.protocol.replace(':', '')
|
|
49
|
-
: 'ws';
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
if (host)
|
|
53
|
-
resourceQuery.sockHost = host;
|
|
54
|
-
if (path)
|
|
55
|
-
resourceQuery.sockPath = path;
|
|
56
|
-
if (port)
|
|
57
|
-
resourceQuery.sockPort = port;
|
|
58
|
-
resourceQuery.sockProtocol = protocol;
|
|
59
|
-
}
|
|
60
|
-
if (options.overlay) {
|
|
61
|
-
const { sockHost, sockPath, sockPort, sockProtocol } = options.overlay;
|
|
62
|
-
if (sockHost)
|
|
63
|
-
resourceQuery.sockHost = sockHost;
|
|
64
|
-
if (sockPath)
|
|
65
|
-
resourceQuery.sockPath = sockPath;
|
|
66
|
-
if (sockPort)
|
|
67
|
-
resourceQuery.sockPort = sockPort;
|
|
68
|
-
if (sockProtocol)
|
|
69
|
-
resourceQuery.sockProtocol = sockProtocol;
|
|
70
|
-
}
|
|
71
|
-
// We don't need to URI encode the resourceQuery as it will be parsed by Webpack
|
|
72
|
-
const queryString = node_querystring_1.default.stringify(resourceQuery, undefined, undefined, {
|
|
73
|
-
encodeURIComponent(str) {
|
|
74
|
-
return str;
|
|
75
|
-
},
|
|
76
|
-
});
|
|
77
|
-
const prependEntries = [
|
|
78
|
-
// React-refresh runtime
|
|
79
|
-
paths_1.reactRefreshEntryPath,
|
|
80
|
-
];
|
|
81
|
-
const overlayEntries = [
|
|
82
|
-
// Error overlay runtime
|
|
83
|
-
options.overlay !== false &&
|
|
84
|
-
options.overlay?.entry &&
|
|
85
|
-
`${require.resolve(options.overlay.entry)}${queryString ? `?${queryString}` : ''}`,
|
|
86
|
-
].filter(Boolean);
|
|
87
|
-
return { prependEntries, overlayEntries };
|
|
88
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getIntegrationEntry = getIntegrationEntry;
|
|
4
|
-
/**
|
|
5
|
-
* Gets entry point of a supported socket integration.
|
|
6
|
-
* @param integrationType A valid socket integration type or a path to a module.
|
|
7
|
-
* @returns Path to the resolved integration entry point.
|
|
8
|
-
*/
|
|
9
|
-
function getIntegrationEntry(integrationType) {
|
|
10
|
-
let resolvedEntry;
|
|
11
|
-
switch (integrationType) {
|
|
12
|
-
case 'whm': {
|
|
13
|
-
resolvedEntry = 'webpack-hot-middleware/client';
|
|
14
|
-
break;
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
return resolvedEntry;
|
|
18
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getSocketIntegration = getSocketIntegration;
|
|
4
|
-
function getSocketIntegration(integrationType) {
|
|
5
|
-
let resolvedSocketIntegration;
|
|
6
|
-
switch (integrationType) {
|
|
7
|
-
case 'wds': {
|
|
8
|
-
resolvedSocketIntegration = require.resolve('../sockets/WDSSocket');
|
|
9
|
-
break;
|
|
10
|
-
}
|
|
11
|
-
case 'whm': {
|
|
12
|
-
resolvedSocketIntegration = require.resolve('../sockets/WHMEventSource');
|
|
13
|
-
break;
|
|
14
|
-
}
|
|
15
|
-
default: {
|
|
16
|
-
resolvedSocketIntegration = require.resolve(integrationType);
|
|
17
|
-
break;
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
return resolvedSocketIntegration;
|
|
21
|
-
}
|