@teambit/react 0.0.658 → 0.0.661
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/{__compositions-1645845653707.js → __compositions-1646054175292.js} +0 -0
- package/{__overview-1645845653707.js → __overview-1646054175292.js} +0 -0
- package/{__preview-1645845653707.js → __preview-1646054175292.js} +2 -2
- package/artifacts/env-template/public/141.js +1 -1
- package/artifacts/env-template/public/181.js +1 -1
- package/artifacts/env-template/public/719.js +6 -6
- package/artifacts/env-template/public/828.js +1 -0
- package/artifacts/env-template/public/848.js +1 -1
- package/artifacts/env-template/public/assets-manifest.json +8 -8
- package/artifacts/env-template/public/compositions.a29353c2c80be59181b1.js +1 -0
- package/artifacts/env-template/public/compositions.html +1 -1
- package/artifacts/env-template/public/overview.18c7c56a6db3d4b9912c.js +1 -0
- package/artifacts/env-template/public/overview.html +1 -1
- package/artifacts/env-template/public/preview-root.30924f8e26bed72c1811.js +1 -0
- package/artifacts/env-template/public/service-worker.js +1 -1
- package/artifacts/preview/teambit_react_react-preview.js +1 -1
- package/dist/webpack/{format-webpack-messages.js → overlay/formatWebpackMessages.js} +28 -14
- package/dist/webpack/overlay/formatWebpackMessages.js.map +1 -0
- package/dist/webpack/{launch-editor-endpoint.js → overlay/launchEditorEndpoint.js} +4 -3
- package/dist/webpack/overlay/launchEditorEndpoint.js.map +1 -0
- package/dist/webpack/{refresh.js → overlay/refreshOverlayInterop.js} +4 -1
- package/dist/webpack/overlay/refreshOverlayInterop.js.map +1 -0
- package/dist/webpack/{react-hot-dev-client.js → overlay/webpackHotDevClient.js} +70 -52
- package/dist/webpack/overlay/webpackHotDevClient.js.map +1 -0
- package/dist/webpack/webpack.config.component.dev.js +3 -4
- package/dist/webpack/webpack.config.component.dev.js.map +1 -1
- package/package-tar/teambit-react-0.0.661.tgz +0 -0
- package/package.json +34 -33
- package/webpack/{format-webpack-messages.js → overlay/formatWebpackMessages.js} +21 -6
- package/webpack/{launch-editor-endpoint.js → overlay/launchEditorEndpoint.js} +3 -0
- package/webpack/{refresh.js → overlay/refreshOverlayInterop.js} +3 -0
- package/webpack/{react-hot-dev-client.js → overlay/webpackHotDevClient.js} +70 -44
- package/webpack/webpack.config.component.dev.ts +3 -4
- package/artifacts/env-template/public/630.js +0 -1
- package/artifacts/env-template/public/compositions.4dcc252966de7ecf5e64.js +0 -1
- package/artifacts/env-template/public/overview.8e47457bd9c3b98a050f.js +0 -1
- package/artifacts/env-template/public/preview-root.c077b08ae05bc42cdb9b.js +0 -1
- package/dist/webpack/format-webpack-messages.js.map +0 -1
- package/dist/webpack/launch-editor-endpoint.js.map +0 -1
- package/dist/webpack/react-hot-dev-client.js.map +0 -1
- package/dist/webpack/refresh.js.map +0 -1
- package/package-tar/teambit-react-0.0.658.tgz +0 -0
|
@@ -1,25 +1,46 @@
|
|
|
1
|
-
/* eslint-disable
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
/*
|
|
3
|
+
* this file was copied as is from `react-dev-utils/webpackHotDevClient`
|
|
4
|
+
* and adjusted for our socket url.
|
|
5
|
+
*
|
|
6
|
+
* we use just set process.env.WDS_* with the EnvironmentPlugin or DefinePlugin
|
|
7
|
+
* once we get react-error-overlay up and running again
|
|
8
|
+
*/
|
|
9
|
+
|
|
2
10
|
/**
|
|
3
11
|
* Copyright (c) 2015-present, Facebook, Inc.
|
|
4
12
|
*
|
|
5
13
|
* This source code is licensed under the MIT license found in the
|
|
6
14
|
* LICENSE file in the root directory of this source tree.
|
|
7
15
|
*/
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
16
|
+
|
|
17
|
+
'use strict';
|
|
18
|
+
|
|
19
|
+
// This alternative WebpackDevServer combines the functionality of:
|
|
20
|
+
// https://github.com/webpack/webpack-dev-server/blob/webpack-1/client/index.js
|
|
21
|
+
// https://github.com/webpack/webpack/blob/webpack-1/hot/dev-server.js
|
|
22
|
+
|
|
23
|
+
// It only supports their simplest configuration (hot updates on same server).
|
|
24
|
+
// It makes some opinionated choices on top, like adding a syntax error overlay
|
|
25
|
+
// that looks similar to our console output. The error overlay is inspired by:
|
|
26
|
+
// https://github.com/glenjamin/webpack-hot-middleware
|
|
27
|
+
|
|
28
|
+
var stripAnsi = require('strip-ansi');
|
|
29
|
+
var url = require('url');
|
|
30
|
+
var launchEditorEndpoint = require('./launchEditorEndpoint');
|
|
31
|
+
var formatWebpackMessages = require('./formatWebpackMessages');
|
|
32
|
+
var ErrorOverlay = require('react-error-overlay');
|
|
13
33
|
|
|
14
34
|
ErrorOverlay.setEditorHandler(function editorHandler(errorLocation) {
|
|
15
35
|
// Keep this sync with errorOverlayMiddleware.js
|
|
16
|
-
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
17
36
|
fetch(
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
37
|
+
launchEditorEndpoint +
|
|
38
|
+
'?fileName=' +
|
|
39
|
+
window.encodeURIComponent(errorLocation.fileName) +
|
|
40
|
+
'&lineNumber=' +
|
|
41
|
+
window.encodeURIComponent(errorLocation.lineNumber || 1) +
|
|
42
|
+
'&colNumber=' +
|
|
43
|
+
window.encodeURIComponent(errorLocation.colNumber || 1)
|
|
23
44
|
);
|
|
24
45
|
});
|
|
25
46
|
|
|
@@ -29,9 +50,9 @@ ErrorOverlay.setEditorHandler(function editorHandler(errorLocation) {
|
|
|
29
50
|
// application. This is handled below when we are notified of a compile (code
|
|
30
51
|
// change).
|
|
31
52
|
// See https://github.com/facebook/create-react-app/issues/3096
|
|
32
|
-
|
|
53
|
+
var hadRuntimeError = false;
|
|
33
54
|
ErrorOverlay.startReportingRuntimeErrors({
|
|
34
|
-
onError() {
|
|
55
|
+
onError: function () {
|
|
35
56
|
hadRuntimeError = true;
|
|
36
57
|
},
|
|
37
58
|
filename: '/static/js/bundle.js',
|
|
@@ -44,18 +65,16 @@ if (module.hot && typeof module.hot.dispose === 'function') {
|
|
|
44
65
|
});
|
|
45
66
|
}
|
|
46
67
|
|
|
47
|
-
// Connect to WebpackDevServer via a socket.
|
|
48
68
|
const querystring = module.id.substring(module.id.indexOf('?'));
|
|
49
69
|
const urlParams = new URLSearchParams(querystring);
|
|
50
70
|
|
|
51
|
-
|
|
71
|
+
// Connect to WebpackDevServer via a socket.
|
|
72
|
+
var connection = new WebSocket(
|
|
52
73
|
url.format({
|
|
53
74
|
protocol: window.location.protocol === 'https:' ? 'wss' : 'ws',
|
|
54
75
|
hostname: window.location.hostname,
|
|
55
76
|
port: window.location.port,
|
|
56
|
-
|
|
57
|
-
pathname: urlParams.get('sockPath') || '/sockjs-node',
|
|
58
|
-
// pathname: '_hmr/teambit.bad-jokes/extensions/harmony-react',
|
|
77
|
+
pathname: urlParams.get('sockPath') || '/ws',
|
|
59
78
|
slashes: true,
|
|
60
79
|
})
|
|
61
80
|
);
|
|
@@ -64,24 +83,20 @@ const connection = new WebSocket(
|
|
|
64
83
|
// to avoid spamming the console. Disconnect usually happens
|
|
65
84
|
// when developer stops the server.
|
|
66
85
|
connection.onclose = function () {
|
|
67
|
-
// eslint-disable-next-line no-console
|
|
68
86
|
if (typeof console !== 'undefined' && typeof console.info === 'function') {
|
|
69
|
-
// eslint-disable-next-line no-console
|
|
70
87
|
console.info('The development server has disconnected.\nRefresh the page if necessary.');
|
|
71
88
|
}
|
|
72
89
|
};
|
|
73
90
|
|
|
74
91
|
// Remember some state related to hot module replacement.
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
92
|
+
var isFirstCompilation = true;
|
|
93
|
+
var mostRecentCompilationHash = null;
|
|
94
|
+
var hasCompileErrors = false;
|
|
78
95
|
|
|
79
96
|
function clearOutdatedErrors() {
|
|
80
97
|
// Clean up outdated compile errors, if any.
|
|
81
|
-
// eslint-disable-next-line no-console
|
|
82
98
|
if (typeof console !== 'undefined' && typeof console.clear === 'function') {
|
|
83
99
|
if (hasCompileErrors) {
|
|
84
|
-
// eslint-disable-next-line no-console
|
|
85
100
|
console.clear();
|
|
86
101
|
}
|
|
87
102
|
}
|
|
@@ -91,7 +106,7 @@ function clearOutdatedErrors() {
|
|
|
91
106
|
function handleSuccess() {
|
|
92
107
|
clearOutdatedErrors();
|
|
93
108
|
|
|
94
|
-
|
|
109
|
+
var isHotUpdate = !isFirstCompilation;
|
|
95
110
|
isFirstCompilation = false;
|
|
96
111
|
hasCompileErrors = false;
|
|
97
112
|
|
|
@@ -109,27 +124,23 @@ function handleSuccess() {
|
|
|
109
124
|
function handleWarnings(warnings) {
|
|
110
125
|
clearOutdatedErrors();
|
|
111
126
|
|
|
112
|
-
|
|
127
|
+
var isHotUpdate = !isFirstCompilation;
|
|
113
128
|
isFirstCompilation = false;
|
|
114
129
|
hasCompileErrors = false;
|
|
115
130
|
|
|
116
131
|
function printWarnings() {
|
|
117
132
|
// Print warnings to the console.
|
|
118
|
-
|
|
119
|
-
warnings,
|
|
133
|
+
var formatted = formatWebpackMessages({
|
|
134
|
+
warnings: warnings,
|
|
120
135
|
errors: [],
|
|
121
136
|
});
|
|
122
137
|
|
|
123
|
-
// eslint-disable-next-line no-console
|
|
124
138
|
if (typeof console !== 'undefined' && typeof console.warn === 'function') {
|
|
125
|
-
|
|
126
|
-
for (let i = 0; i < formatted.warnings.length; i++) {
|
|
139
|
+
for (var i = 0; i < formatted.warnings.length; i++) {
|
|
127
140
|
if (i === 5) {
|
|
128
|
-
// eslint-disable-next-line
|
|
129
141
|
console.warn('There were more warnings in other files.\n' + 'You can find a complete log in the terminal.');
|
|
130
142
|
break;
|
|
131
143
|
}
|
|
132
|
-
// eslint-disable-next-line no-console
|
|
133
144
|
console.warn(stripAnsi(formatted.warnings[i]));
|
|
134
145
|
}
|
|
135
146
|
}
|
|
@@ -155,8 +166,8 @@ function handleErrors(errors) {
|
|
|
155
166
|
hasCompileErrors = true;
|
|
156
167
|
|
|
157
168
|
// "Massage" webpack messages.
|
|
158
|
-
|
|
159
|
-
errors,
|
|
169
|
+
var formatted = formatWebpackMessages({
|
|
170
|
+
errors: errors,
|
|
160
171
|
warnings: [],
|
|
161
172
|
});
|
|
162
173
|
|
|
@@ -164,11 +175,8 @@ function handleErrors(errors) {
|
|
|
164
175
|
ErrorOverlay.reportBuildError(formatted.errors[0]);
|
|
165
176
|
|
|
166
177
|
// Also log them to the console.
|
|
167
|
-
// eslint-disable-next-line no-console
|
|
168
178
|
if (typeof console !== 'undefined' && typeof console.error === 'function') {
|
|
169
|
-
|
|
170
|
-
for (let i = 0; i < formatted.errors.length; i++) {
|
|
171
|
-
// eslint-disable-next-line no-console
|
|
179
|
+
for (var i = 0; i < formatted.errors.length; i++) {
|
|
172
180
|
console.error(stripAnsi(formatted.errors[i]));
|
|
173
181
|
}
|
|
174
182
|
}
|
|
@@ -191,7 +199,7 @@ function handleAvailableHash(hash) {
|
|
|
191
199
|
|
|
192
200
|
// Handle messages from the server.
|
|
193
201
|
connection.onmessage = function (e) {
|
|
194
|
-
|
|
202
|
+
var message = JSON.parse(e.data);
|
|
195
203
|
switch (message.type) {
|
|
196
204
|
case 'hash':
|
|
197
205
|
handleAvailableHash(message.data);
|
|
@@ -228,6 +236,18 @@ function canApplyUpdates() {
|
|
|
228
236
|
return module.hot.status() === 'idle';
|
|
229
237
|
}
|
|
230
238
|
|
|
239
|
+
function canAcceptErrors() {
|
|
240
|
+
// NOTE: This var is injected by Webpack's DefinePlugin, and is a boolean instead of string.
|
|
241
|
+
const hasReactRefresh = process.env.FAST_REFRESH;
|
|
242
|
+
|
|
243
|
+
const status = module.hot.status();
|
|
244
|
+
// React refresh can handle hot-reloading over errors.
|
|
245
|
+
// However, when hot-reload status is abort or fail,
|
|
246
|
+
// it indicates the current update cannot be applied safely,
|
|
247
|
+
// and thus we should bail out to a forced reload for consistency.
|
|
248
|
+
return hasReactRefresh && ['abort', 'fail'].indexOf(status) === -1;
|
|
249
|
+
}
|
|
250
|
+
|
|
231
251
|
// Attempt to update code on the fly, fall back to a hard reload.
|
|
232
252
|
function tryApplyUpdates(onHotUpdateSuccess) {
|
|
233
253
|
if (!module.hot) {
|
|
@@ -241,7 +261,13 @@ function tryApplyUpdates(onHotUpdateSuccess) {
|
|
|
241
261
|
}
|
|
242
262
|
|
|
243
263
|
function handleApplyUpdates(err, updatedModules) {
|
|
244
|
-
|
|
264
|
+
const haveErrors = err || hadRuntimeError;
|
|
265
|
+
// When there is no error but updatedModules is unavailable,
|
|
266
|
+
// it indicates a critical failure in hot-reloading,
|
|
267
|
+
// e.g. server is not ready to serve new bundle,
|
|
268
|
+
// and hence we need to do a forced reload.
|
|
269
|
+
const needsForcedReload = !err && !updatedModules;
|
|
270
|
+
if ((haveErrors && !canAcceptErrors()) || needsForcedReload) {
|
|
245
271
|
window.location.reload();
|
|
246
272
|
return;
|
|
247
273
|
}
|
|
@@ -258,7 +284,7 @@ function tryApplyUpdates(onHotUpdateSuccess) {
|
|
|
258
284
|
}
|
|
259
285
|
|
|
260
286
|
// https://webpack.github.io/docs/hot-module-replacement.html#check
|
|
261
|
-
|
|
287
|
+
var result = module.hot.check(/* autoApply */ true, handleApplyUpdates);
|
|
262
288
|
|
|
263
289
|
// // webpack 2 returns a Promise instead of invoking a callback
|
|
264
290
|
if (result && result.then) {
|
|
@@ -83,10 +83,9 @@ export default function (workDir: string, envId: string): Configuration {
|
|
|
83
83
|
new ReactRefreshWebpackPlugin({
|
|
84
84
|
overlay: {
|
|
85
85
|
sockPath: `_hmr/${envId}`,
|
|
86
|
-
// TODO
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
module: require.resolve('./refresh'),
|
|
86
|
+
// TODO - react-error-overlay not showing runtime errors - https://github.com/teambit/bit/issues/5452
|
|
87
|
+
entry: require.resolve('./overlay/webpackHotDevClient'),
|
|
88
|
+
module: require.resolve('./overlay/refreshOverlayInterop'),
|
|
90
89
|
},
|
|
91
90
|
|
|
92
91
|
// we use '@pmmmwh/react-refresh-webpack-plugin/loader' directly where relevant.
|