@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.
Files changed (42) hide show
  1. package/{__compositions-1645845653707.js → __compositions-1646054175292.js} +0 -0
  2. package/{__overview-1645845653707.js → __overview-1646054175292.js} +0 -0
  3. package/{__preview-1645845653707.js → __preview-1646054175292.js} +2 -2
  4. package/artifacts/env-template/public/141.js +1 -1
  5. package/artifacts/env-template/public/181.js +1 -1
  6. package/artifacts/env-template/public/719.js +6 -6
  7. package/artifacts/env-template/public/828.js +1 -0
  8. package/artifacts/env-template/public/848.js +1 -1
  9. package/artifacts/env-template/public/assets-manifest.json +8 -8
  10. package/artifacts/env-template/public/compositions.a29353c2c80be59181b1.js +1 -0
  11. package/artifacts/env-template/public/compositions.html +1 -1
  12. package/artifacts/env-template/public/overview.18c7c56a6db3d4b9912c.js +1 -0
  13. package/artifacts/env-template/public/overview.html +1 -1
  14. package/artifacts/env-template/public/preview-root.30924f8e26bed72c1811.js +1 -0
  15. package/artifacts/env-template/public/service-worker.js +1 -1
  16. package/artifacts/preview/teambit_react_react-preview.js +1 -1
  17. package/dist/webpack/{format-webpack-messages.js → overlay/formatWebpackMessages.js} +28 -14
  18. package/dist/webpack/overlay/formatWebpackMessages.js.map +1 -0
  19. package/dist/webpack/{launch-editor-endpoint.js → overlay/launchEditorEndpoint.js} +4 -3
  20. package/dist/webpack/overlay/launchEditorEndpoint.js.map +1 -0
  21. package/dist/webpack/{refresh.js → overlay/refreshOverlayInterop.js} +4 -1
  22. package/dist/webpack/overlay/refreshOverlayInterop.js.map +1 -0
  23. package/dist/webpack/{react-hot-dev-client.js → overlay/webpackHotDevClient.js} +70 -52
  24. package/dist/webpack/overlay/webpackHotDevClient.js.map +1 -0
  25. package/dist/webpack/webpack.config.component.dev.js +3 -4
  26. package/dist/webpack/webpack.config.component.dev.js.map +1 -1
  27. package/package-tar/teambit-react-0.0.661.tgz +0 -0
  28. package/package.json +34 -33
  29. package/webpack/{format-webpack-messages.js → overlay/formatWebpackMessages.js} +21 -6
  30. package/webpack/{launch-editor-endpoint.js → overlay/launchEditorEndpoint.js} +3 -0
  31. package/webpack/{refresh.js → overlay/refreshOverlayInterop.js} +3 -0
  32. package/webpack/{react-hot-dev-client.js → overlay/webpackHotDevClient.js} +70 -44
  33. package/webpack/webpack.config.component.dev.ts +3 -4
  34. package/artifacts/env-template/public/630.js +0 -1
  35. package/artifacts/env-template/public/compositions.4dcc252966de7ecf5e64.js +0 -1
  36. package/artifacts/env-template/public/overview.8e47457bd9c3b98a050f.js +0 -1
  37. package/artifacts/env-template/public/preview-root.c077b08ae05bc42cdb9b.js +0 -1
  38. package/dist/webpack/format-webpack-messages.js.map +0 -1
  39. package/dist/webpack/launch-editor-endpoint.js.map +0 -1
  40. package/dist/webpack/react-hot-dev-client.js.map +0 -1
  41. package/dist/webpack/refresh.js.map +0 -1
  42. package/package-tar/teambit-react-0.0.658.tgz +0 -0
@@ -1,12 +1,12 @@
1
- "use strict";
1
+ /* eslint-disable */
2
2
 
3
- require("core-js/modules/es.array.iterator.js");
4
-
5
- require("core-js/modules/es.promise.js");
6
-
7
- require("core-js/modules/web.url.js");
8
-
9
- /* eslint-disable promise/catch-or-return */
3
+ /*
4
+ * this file was copied as is from `react-dev-utils/webpackHotDevClient`
5
+ * and adjusted for our socket url.
6
+ *
7
+ * we use just set process.env.WDS_* with the EnvironmentPlugin or DefinePlugin
8
+ * once we get react-error-overlay up and running again
9
+ */
10
10
 
11
11
  /**
12
12
  * Copyright (c) 2015-present, Facebook, Inc.
@@ -14,20 +14,33 @@ require("core-js/modules/web.url.js");
14
14
  * This source code is licensed under the MIT license found in the
15
15
  * LICENSE file in the root directory of this source tree.
16
16
  */
17
- const stripAnsi = require('strip-ansi');
17
+ 'use strict'; // This alternative WebpackDevServer combines the functionality of:
18
+ // https://github.com/webpack/webpack-dev-server/blob/webpack-1/client/index.js
19
+ // https://github.com/webpack/webpack/blob/webpack-1/hot/dev-server.js
20
+ // It only supports their simplest configuration (hot updates on same server).
21
+ // It makes some opinionated choices on top, like adding a syntax error overlay
22
+ // that looks similar to our console output. The error overlay is inspired by:
23
+ // https://github.com/glenjamin/webpack-hot-middleware
24
+
25
+ require("core-js/modules/es.array.iterator.js");
26
+
27
+ require("core-js/modules/es.promise.js");
28
+
29
+ require("core-js/modules/web.url.js");
30
+
31
+ var stripAnsi = require('strip-ansi');
18
32
 
19
- const ErrorOverlay = require('react-error-overlay');
33
+ var url = require('url');
20
34
 
21
- const url = require('url');
35
+ var launchEditorEndpoint = require('./launchEditorEndpoint');
22
36
 
23
- const launchEditorEndpoint = require('./launch-editor-endpoint');
37
+ var formatWebpackMessages = require('./formatWebpackMessages');
24
38
 
25
- const formatWebpackMessages = require('./format-webpack-messages');
39
+ var ErrorOverlay = require('react-error-overlay');
26
40
 
27
41
  ErrorOverlay.setEditorHandler(function editorHandler(errorLocation) {
28
42
  // Keep this sync with errorOverlayMiddleware.js
29
- // eslint-disable-next-line @typescript-eslint/no-floating-promises
30
- fetch(`${launchEditorEndpoint}?fileName=${window.encodeURIComponent(errorLocation.fileName)}&lineNumber=${window.encodeURIComponent(errorLocation.lineNumber || 1)}&colNumber=${window.encodeURIComponent(errorLocation.colNumber || 1)}`);
43
+ fetch(launchEditorEndpoint + '?fileName=' + window.encodeURIComponent(errorLocation.fileName) + '&lineNumber=' + window.encodeURIComponent(errorLocation.lineNumber || 1) + '&colNumber=' + window.encodeURIComponent(errorLocation.colNumber || 1));
31
44
  }); // We need to keep track of if there has been a runtime error.
32
45
  // Essentially, we cannot guarantee application state was not corrupted by the
33
46
  // runtime error. To prevent confusing behavior, we forcibly reload the entire
@@ -35,12 +48,11 @@ ErrorOverlay.setEditorHandler(function editorHandler(errorLocation) {
35
48
  // change).
36
49
  // See https://github.com/facebook/create-react-app/issues/3096
37
50
 
38
- let hadRuntimeError = false;
51
+ var hadRuntimeError = false;
39
52
  ErrorOverlay.startReportingRuntimeErrors({
40
- onError() {
53
+ onError: function () {
41
54
  hadRuntimeError = true;
42
55
  },
43
-
44
56
  filename: '/static/js/bundle.js'
45
57
  });
46
58
 
@@ -49,42 +61,36 @@ if (module.hot && typeof module.hot.dispose === 'function') {
49
61
  // TODO: why do we need this?
50
62
  ErrorOverlay.stopReportingRuntimeErrors();
51
63
  });
52
- } // Connect to WebpackDevServer via a socket.
53
-
64
+ }
54
65
 
55
66
  const querystring = module.id.substring(module.id.indexOf('?'));
56
- const urlParams = new URLSearchParams(querystring);
57
- const connection = new WebSocket(url.format({
67
+ const urlParams = new URLSearchParams(querystring); // Connect to WebpackDevServer via a socket.
68
+
69
+ var connection = new WebSocket(url.format({
58
70
  protocol: window.location.protocol === 'https:' ? 'wss' : 'ws',
59
71
  hostname: window.location.hostname,
60
72
  port: window.location.port,
61
- // Hardcoded in WebpackDevServer
62
- pathname: urlParams.get('sockPath') || '/sockjs-node',
63
- // pathname: '_hmr/teambit.bad-jokes/extensions/harmony-react',
73
+ pathname: urlParams.get('sockPath') || '/ws',
64
74
  slashes: true
65
75
  })); // Unlike WebpackDevServer client, we won't try to reconnect
66
76
  // to avoid spamming the console. Disconnect usually happens
67
77
  // when developer stops the server.
68
78
 
69
79
  connection.onclose = function () {
70
- // eslint-disable-next-line no-console
71
80
  if (typeof console !== 'undefined' && typeof console.info === 'function') {
72
- // eslint-disable-next-line no-console
73
81
  console.info('The development server has disconnected.\nRefresh the page if necessary.');
74
82
  }
75
83
  }; // Remember some state related to hot module replacement.
76
84
 
77
85
 
78
- let isFirstCompilation = true;
79
- let mostRecentCompilationHash = null;
80
- let hasCompileErrors = false;
86
+ var isFirstCompilation = true;
87
+ var mostRecentCompilationHash = null;
88
+ var hasCompileErrors = false;
81
89
 
82
90
  function clearOutdatedErrors() {
83
91
  // Clean up outdated compile errors, if any.
84
- // eslint-disable-next-line no-console
85
92
  if (typeof console !== 'undefined' && typeof console.clear === 'function') {
86
93
  if (hasCompileErrors) {
87
- // eslint-disable-next-line no-console
88
94
  console.clear();
89
95
  }
90
96
  }
@@ -93,7 +99,7 @@ function clearOutdatedErrors() {
93
99
 
94
100
  function handleSuccess() {
95
101
  clearOutdatedErrors();
96
- const isHotUpdate = !isFirstCompilation;
102
+ var isHotUpdate = !isFirstCompilation;
97
103
  isFirstCompilation = false;
98
104
  hasCompileErrors = false; // Attempt to apply hot updates or reload.
99
105
 
@@ -109,26 +115,23 @@ function handleSuccess() {
109
115
 
110
116
  function handleWarnings(warnings) {
111
117
  clearOutdatedErrors();
112
- const isHotUpdate = !isFirstCompilation;
118
+ var isHotUpdate = !isFirstCompilation;
113
119
  isFirstCompilation = false;
114
120
  hasCompileErrors = false;
115
121
 
116
122
  function printWarnings() {
117
123
  // Print warnings to the console.
118
- const formatted = formatWebpackMessages({
119
- warnings,
124
+ var formatted = formatWebpackMessages({
125
+ warnings: warnings,
120
126
  errors: []
121
- }); // eslint-disable-next-line no-console
127
+ });
122
128
 
123
129
  if (typeof console !== 'undefined' && typeof console.warn === 'function') {
124
- // eslint-disable-next-line no-plusplus
125
- for (let i = 0; i < formatted.warnings.length; i++) {
130
+ for (var i = 0; i < formatted.warnings.length; i++) {
126
131
  if (i === 5) {
127
- // eslint-disable-next-line
128
132
  console.warn('There were more warnings in other files.\n' + 'You can find a complete log in the terminal.');
129
133
  break;
130
- } // eslint-disable-next-line no-console
131
-
134
+ }
132
135
 
133
136
  console.warn(stripAnsi(formatted.warnings[i]));
134
137
  }
@@ -152,18 +155,15 @@ function handleErrors(errors) {
152
155
  isFirstCompilation = false;
153
156
  hasCompileErrors = true; // "Massage" webpack messages.
154
157
 
155
- const formatted = formatWebpackMessages({
156
- errors,
158
+ var formatted = formatWebpackMessages({
159
+ errors: errors,
157
160
  warnings: []
158
161
  }); // Only show the first error.
159
162
 
160
163
  ErrorOverlay.reportBuildError(formatted.errors[0]); // Also log them to the console.
161
- // eslint-disable-next-line no-console
162
164
 
163
165
  if (typeof console !== 'undefined' && typeof console.error === 'function') {
164
- // eslint-disable-next-line no-plusplus
165
- for (let i = 0; i < formatted.errors.length; i++) {
166
- // eslint-disable-next-line no-console
166
+ for (var i = 0; i < formatted.errors.length; i++) {
167
167
  console.error(stripAnsi(formatted.errors[i]));
168
168
  }
169
169
  } // Do not attempt to reload now.
@@ -185,7 +185,7 @@ function handleAvailableHash(hash) {
185
185
 
186
186
 
187
187
  connection.onmessage = function (e) {
188
- const message = JSON.parse(e.data);
188
+ var message = JSON.parse(e.data);
189
189
 
190
190
  switch (message.type) {
191
191
  case 'hash':
@@ -226,6 +226,17 @@ function isUpdateAvailable() {
226
226
 
227
227
  function canApplyUpdates() {
228
228
  return module.hot.status() === 'idle';
229
+ }
230
+
231
+ function canAcceptErrors() {
232
+ // NOTE: This var is injected by Webpack's DefinePlugin, and is a boolean instead of string.
233
+ const hasReactRefresh = process.env.FAST_REFRESH;
234
+ const status = module.hot.status(); // React refresh can handle hot-reloading over errors.
235
+ // However, when hot-reload status is abort or fail,
236
+ // it indicates the current update cannot be applied safely,
237
+ // and thus we should bail out to a forced reload for consistency.
238
+
239
+ return hasReactRefresh && ['abort', 'fail'].indexOf(status) === -1;
229
240
  } // Attempt to update code on the fly, fall back to a hard reload.
230
241
 
231
242
 
@@ -241,7 +252,14 @@ function tryApplyUpdates(onHotUpdateSuccess) {
241
252
  }
242
253
 
243
254
  function handleApplyUpdates(err, updatedModules) {
244
- if (err || !updatedModules || hadRuntimeError) {
255
+ const haveErrors = err || hadRuntimeError; // When there is no error but updatedModules is unavailable,
256
+ // it indicates a critical failure in hot-reloading,
257
+ // e.g. server is not ready to serve new bundle,
258
+ // and hence we need to do a forced reload.
259
+
260
+ const needsForcedReload = !err && !updatedModules;
261
+
262
+ if (haveErrors && !canAcceptErrors() || needsForcedReload) {
245
263
  window.location.reload();
246
264
  return;
247
265
  }
@@ -258,7 +276,7 @@ function tryApplyUpdates(onHotUpdateSuccess) {
258
276
  } // https://webpack.github.io/docs/hot-module-replacement.html#check
259
277
 
260
278
 
261
- const result = module.hot.check(
279
+ var result = module.hot.check(
262
280
  /* autoApply */
263
281
  true, handleApplyUpdates); // // webpack 2 returns a Promise instead of invoking a callback
264
282
 
@@ -271,4 +289,4 @@ function tryApplyUpdates(onHotUpdateSuccess) {
271
289
  }
272
290
  }
273
291
 
274
- //# sourceMappingURL=react-hot-dev-client.js.map
292
+ //# sourceMappingURL=webpackHotDevClient.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["webpackHotDevClient.js"],"names":["stripAnsi","require","url","launchEditorEndpoint","formatWebpackMessages","ErrorOverlay","setEditorHandler","editorHandler","errorLocation","fetch","window","encodeURIComponent","fileName","lineNumber","colNumber","hadRuntimeError","startReportingRuntimeErrors","onError","filename","module","hot","dispose","stopReportingRuntimeErrors","querystring","id","substring","indexOf","urlParams","URLSearchParams","connection","WebSocket","format","protocol","location","hostname","port","pathname","get","slashes","onclose","console","info","isFirstCompilation","mostRecentCompilationHash","hasCompileErrors","clearOutdatedErrors","clear","handleSuccess","isHotUpdate","tryApplyUpdates","onHotUpdateSuccess","tryDismissErrorOverlay","handleWarnings","warnings","printWarnings","formatted","errors","warn","i","length","onSuccessfulHotUpdate","handleErrors","reportBuildError","error","dismissBuildError","handleAvailableHash","hash","onmessage","e","message","JSON","parse","data","type","reload","isUpdateAvailable","__webpack_hash__","canApplyUpdates","status","canAcceptErrors","hasReactRefresh","process","env","FAST_REFRESH","handleApplyUpdates","err","updatedModules","haveErrors","needsForcedReload","result","check","then"],"mappings":"AAAA;;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AAEA,a,CAEA;AACA;AACA;AAEA;AACA;AACA;AACA;;;;;;;;AAEA,IAAIA,SAAS,GAAGC,OAAO,CAAC,YAAD,CAAvB;;AACA,IAAIC,GAAG,GAAGD,OAAO,CAAC,KAAD,CAAjB;;AACA,IAAIE,oBAAoB,GAAGF,OAAO,CAAC,wBAAD,CAAlC;;AACA,IAAIG,qBAAqB,GAAGH,OAAO,CAAC,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AnC2C,CAqC3C;;AACA,MAAIK,MAAM,IAAIA,MAAM,CAACE,IAArB,EAA2B;AACzBF,IAAAA,MAAM,CAACE,IAAP,CACE,UAAUL,cAAV,EAA0B;AACxBF,MAAAA,kBAAkB,CAAC,IAAD,EAAOE,cAAP,CAAlB;AACD,KAHH,EAIE,UAAUD,GAAV,EAAe;AACbD,MAAAA,kBAAkB,CAACC,GAAD,EAAM,IAAN,CAAlB;AACD,KANH;AAQD;AACF","sourcesContent":["/* eslint-disable */\n/*\n * this file was copied as is from `react-dev-utils/webpackHotDevClient`\n * and adjusted for our socket url.\n *\n * we use just set process.env.WDS_* with the EnvironmentPlugin or DefinePlugin\n * once we get react-error-overlay up and running again\n */\n\n/**\n * Copyright (c) 2015-present, Facebook, Inc.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\n'use strict';\n\n// This alternative WebpackDevServer combines the functionality of:\n// https://github.com/webpack/webpack-dev-server/blob/webpack-1/client/index.js\n// https://github.com/webpack/webpack/blob/webpack-1/hot/dev-server.js\n\n// It only supports their simplest configuration (hot updates on same server).\n// It makes some opinionated choices on top, like adding a syntax error overlay\n// that looks similar to our console output. The error overlay is inspired by:\n// https://github.com/glenjamin/webpack-hot-middleware\n\nvar stripAnsi = require('strip-ansi');\nvar url = require('url');\nvar launchEditorEndpoint = require('./launchEditorEndpoint');\nvar formatWebpackMessages = require('./formatWebpackMessages');\nvar ErrorOverlay = require('react-error-overlay');\n\nErrorOverlay.setEditorHandler(function editorHandler(errorLocation) {\n // Keep this sync with errorOverlayMiddleware.js\n fetch(\n launchEditorEndpoint +\n '?fileName=' +\n window.encodeURIComponent(errorLocation.fileName) +\n '&lineNumber=' +\n window.encodeURIComponent(errorLocation.lineNumber || 1) +\n '&colNumber=' +\n window.encodeURIComponent(errorLocation.colNumber || 1)\n );\n});\n\n// We need to keep track of if there has been a runtime error.\n// Essentially, we cannot guarantee application state was not corrupted by the\n// runtime error. To prevent confusing behavior, we forcibly reload the entire\n// application. This is handled below when we are notified of a compile (code\n// change).\n// See https://github.com/facebook/create-react-app/issues/3096\nvar hadRuntimeError = false;\nErrorOverlay.startReportingRuntimeErrors({\n onError: function () {\n hadRuntimeError = true;\n },\n filename: '/static/js/bundle.js',\n});\n\nif (module.hot && typeof module.hot.dispose === 'function') {\n module.hot.dispose(function () {\n // TODO: why do we need this?\n ErrorOverlay.stopReportingRuntimeErrors();\n });\n}\n\nconst querystring = module.id.substring(module.id.indexOf('?'));\nconst urlParams = new URLSearchParams(querystring);\n\n// Connect to WebpackDevServer via a socket.\nvar connection = new WebSocket(\n url.format({\n protocol: window.location.protocol === 'https:' ? 'wss' : 'ws',\n hostname: window.location.hostname,\n port: window.location.port,\n pathname: urlParams.get('sockPath') || '/ws',\n slashes: true,\n })\n);\n\n// Unlike WebpackDevServer client, we won't try to reconnect\n// to avoid spamming the console. Disconnect usually happens\n// when developer stops the server.\nconnection.onclose = function () {\n if (typeof console !== 'undefined' && typeof console.info === 'function') {\n console.info('The development server has disconnected.\\nRefresh the page if necessary.');\n }\n};\n\n// Remember some state related to hot module replacement.\nvar isFirstCompilation = true;\nvar mostRecentCompilationHash = null;\nvar hasCompileErrors = false;\n\nfunction clearOutdatedErrors() {\n // Clean up outdated compile errors, if any.\n if (typeof console !== 'undefined' && typeof console.clear === 'function') {\n if (hasCompileErrors) {\n console.clear();\n }\n }\n}\n\n// Successful compilation.\nfunction handleSuccess() {\n clearOutdatedErrors();\n\n var isHotUpdate = !isFirstCompilation;\n isFirstCompilation = false;\n hasCompileErrors = false;\n\n // Attempt to apply hot updates or reload.\n if (isHotUpdate) {\n tryApplyUpdates(function onHotUpdateSuccess() {\n // Only dismiss it when we're sure it's a hot update.\n // Otherwise it would flicker right before the reload.\n tryDismissErrorOverlay();\n });\n }\n}\n\n// Compilation with warnings (e.g. ESLint).\nfunction handleWarnings(warnings) {\n clearOutdatedErrors();\n\n var isHotUpdate = !isFirstCompilation;\n isFirstCompilation = false;\n hasCompileErrors = false;\n\n function printWarnings() {\n // Print warnings to the console.\n var formatted = formatWebpackMessages({\n warnings: warnings,\n errors: [],\n });\n\n if (typeof console !== 'undefined' && typeof console.warn === 'function') {\n for (var i = 0; i < formatted.warnings.length; i++) {\n if (i === 5) {\n console.warn('There were more warnings in other files.\\n' + 'You can find a complete log in the terminal.');\n break;\n }\n console.warn(stripAnsi(formatted.warnings[i]));\n }\n }\n }\n\n printWarnings();\n\n // Attempt to apply hot updates or reload.\n if (isHotUpdate) {\n tryApplyUpdates(function onSuccessfulHotUpdate() {\n // Only dismiss it when we're sure it's a hot update.\n // Otherwise it would flicker right before the reload.\n tryDismissErrorOverlay();\n });\n }\n}\n\n// Compilation with errors (e.g. syntax error or missing modules).\nfunction handleErrors(errors) {\n clearOutdatedErrors();\n\n isFirstCompilation = false;\n hasCompileErrors = true;\n\n // \"Massage\" webpack messages.\n var formatted = formatWebpackMessages({\n errors: errors,\n warnings: [],\n });\n\n // Only show the first error.\n ErrorOverlay.reportBuildError(formatted.errors[0]);\n\n // Also log them to the console.\n if (typeof console !== 'undefined' && typeof console.error === 'function') {\n for (var i = 0; i < formatted.errors.length; i++) {\n console.error(stripAnsi(formatted.errors[i]));\n }\n }\n\n // Do not attempt to reload now.\n // We will reload on next success instead.\n}\n\nfunction tryDismissErrorOverlay() {\n if (!hasCompileErrors) {\n ErrorOverlay.dismissBuildError();\n }\n}\n\n// There is a newer version of the code available.\nfunction handleAvailableHash(hash) {\n // Update last known compilation hash.\n mostRecentCompilationHash = hash;\n}\n\n// Handle messages from the server.\nconnection.onmessage = function (e) {\n var message = JSON.parse(e.data);\n switch (message.type) {\n case 'hash':\n handleAvailableHash(message.data);\n break;\n case 'still-ok':\n case 'ok':\n handleSuccess();\n break;\n case 'content-changed':\n // Triggered when a file from `contentBase` changed.\n window.location.reload();\n break;\n case 'warnings':\n handleWarnings(message.data);\n break;\n case 'errors':\n handleErrors(message.data);\n break;\n default:\n // Do nothing.\n }\n};\n\n// Is there a newer version of this code available?\nfunction isUpdateAvailable() {\n /* globals __webpack_hash__ */\n // __webpack_hash__ is the hash of the current compilation.\n // It's a global variable injected by webpack.\n return mostRecentCompilationHash !== __webpack_hash__;\n}\n\n// webpack disallows updates in other states.\nfunction canApplyUpdates() {\n return module.hot.status() === 'idle';\n}\n\nfunction canAcceptErrors() {\n // NOTE: This var is injected by Webpack's DefinePlugin, and is a boolean instead of string.\n const hasReactRefresh = process.env.FAST_REFRESH;\n\n const status = module.hot.status();\n // React refresh can handle hot-reloading over errors.\n // However, when hot-reload status is abort or fail,\n // it indicates the current update cannot be applied safely,\n // and thus we should bail out to a forced reload for consistency.\n return hasReactRefresh && ['abort', 'fail'].indexOf(status) === -1;\n}\n\n// Attempt to update code on the fly, fall back to a hard reload.\nfunction tryApplyUpdates(onHotUpdateSuccess) {\n if (!module.hot) {\n // HotModuleReplacementPlugin is not in webpack configuration.\n window.location.reload();\n return;\n }\n\n if (!isUpdateAvailable() || !canApplyUpdates()) {\n return;\n }\n\n function handleApplyUpdates(err, updatedModules) {\n const haveErrors = err || hadRuntimeError;\n // When there is no error but updatedModules is unavailable,\n // it indicates a critical failure in hot-reloading,\n // e.g. server is not ready to serve new bundle,\n // and hence we need to do a forced reload.\n const needsForcedReload = !err && !updatedModules;\n if ((haveErrors && !canAcceptErrors()) || needsForcedReload) {\n window.location.reload();\n return;\n }\n\n if (typeof onHotUpdateSuccess === 'function') {\n // Maybe we want to do something.\n onHotUpdateSuccess();\n }\n\n if (isUpdateAvailable()) {\n // While we were updating, there was a new update! Do it again.\n tryApplyUpdates();\n }\n }\n\n // https://webpack.github.io/docs/hot-module-replacement.html#check\n var result = module.hot.check(/* autoApply */ true, handleApplyUpdates);\n\n // // webpack 2 returns a Promise instead of invoking a callback\n if (result && result.then) {\n result.then(\n function (updatedModules) {\n handleApplyUpdates(null, updatedModules);\n },\n function (err) {\n handleApplyUpdates(err, null);\n }\n );\n }\n}\n"]}
@@ -108,10 +108,9 @@ function _default(workDir, envId) {
108
108
  new (_reactRefreshWebpackPlugin().default)({
109
109
  overlay: {
110
110
  sockPath: `_hmr/${envId}`,
111
- // TODO: check why webpackHotDevClient and react-error-overlay are not responding for runtime
112
- // errors
113
- entry: require.resolve('./react-hot-dev-client'),
114
- module: require.resolve('./refresh')
111
+ // TODO - react-error-overlay not showing runtime errors - https://github.com/teambit/bit/issues/5452
112
+ entry: require.resolve('./overlay/webpackHotDevClient'),
113
+ module: require.resolve('./overlay/refreshOverlayInterop')
115
114
  },
116
115
  // we use '@pmmmwh/react-refresh-webpack-plugin/loader' directly where relevant.
117
116
  // FYI, original defaults of the plugin are:
@@ -1 +1 @@
1
- {"version":3,"sources":["webpack.config.component.dev.ts"],"names":["matchNothingRegex","workDir","envId","module","rules","test","enforce","include","path","join","descriptionData","componentId","value","use","require","resolve","ComponentID","isValidObject","loader","options","babelrc","configFile","plugins","compact","minified","presets","ReactRefreshWebpackPlugin","overlay","sockPath","entry"],"mappings":";;;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAGA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAHA;AACA;AAIA,MAAMA,iBAAiB,GAAG,IAA1B,C,CAEA;AACA;AACA;AACA;;AACe,kBAAUC,OAAV,EAA2BC,KAA3B,EAAyD;AACtE,SAAO;AACLC,IAAAA,MAAM,EAAE;AACNC,MAAAA,KAAK,EAAE,CACL;AACEC,QAAAA,IAAI,EAAE,OADR;AAEEC,QAAAA,OAAO,EAAE,KAFX;AAGE;AACA;AACAC,QAAAA,OAAO,EAAEC,gBAAKC,IAAL,CAAUR,OAAV,EAAmB,cAAnB,CALX;AAME;AACAS,QAAAA,eAAe,EAAE;AAAEC,UAAAA,WAAW,EAAGC,KAAD,IAAW,CAAC,CAACA;AAA5B,SAPnB;AAQEC,QAAAA,GAAG,EAAE,CAACC,OAAO,CAACC,OAAR,CAAgB,mBAAhB,CAAD;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gB,mBAAhB,CAAzC,CAHF;AAIPO,YAAAA,OAAO,EAAE,CAACR,OAAO,CAACC,OAAR,CAAgB,qBAAhB,CAAD;AAJF;AAFX,SAFG,EAWH;AACEG,UAAAA,MAAM,EAAEJ,OAAO,CAACC,OAAR,CAAgB,iCAAhB;AADV,SAXG;AANP,OAtCK;AADD,KADH;AAgELO,IAAAA,OAAO,EAAE,CACP;AACA;AACA,SAAII,oCAAJ,EAA8B;AAC5BC,MAAAA,OAAO,EAAE;AACPC,QAAAA,QAAQ,EAAG,QAAO1B,KAAM,EADjB;AAEP;AACA;AACA2B,QAAAA,KAAK,EAAEf,OAAO,CAACC,OAAR,CAAgB,wBAAhB,CAJA;AAKPZ,QAAAA,MAAM,EAAEW,OAAO,CAACC,OAAR,CAAgB,WAAhB;AALD,OADmB;AAS5B;AACA;AACA;AACAR,MAAAA,OAAO,EAAEP;AAZmB,KAA9B,CAHO;AAhEJ,GAAP;AAmFD","sourcesContent":["import path from 'path';\nimport { Configuration } from 'webpack';\nimport { ComponentID } from '@teambit/component-id';\n// Make sure the bit-react-transformer is a dependency\n// TODO: remove it once we can set policy from component to component then set it via the component.json\nimport '@teambit/react.babel.bit-react-transformer';\nimport ReactRefreshWebpackPlugin from '@pmmmwh/react-refresh-webpack-plugin';\n\nconst matchNothingRegex = 'a^';\n\n// This is the production and development configuration.\n// It is focused on developer experience, fast rebuilds, and a minimal bundle.\n// eslint-disable-next-line complexity\n// export default function (workDir: string, envId: string): Configuration {\nexport default function (workDir: string, envId: string): Configuration {\n return {\n module: {\n rules: [\n {\n test: /\\.js$/,\n enforce: 'pre',\n // limit loader to files in the current project,\n // to skip any files linked from other projects (like Bit itself)\n include: path.join(workDir, 'node_modules'),\n // only apply to packages with componentId in their package.json (ie. bit components)\n descriptionData: { componentId: (value) => !!value },\n use: [require.resolve('source-map-loader')],\n },\n {\n test: /\\.js$/,\n // limit loader to files in the current project,\n // to skip any files linked from other projects (like Bit itself)\n include: path.join(workDir, 'node_modules'),\n // only apply to packages with componentId in their package.json (ie. bit components)\n descriptionData: { componentId: ComponentID.isValidObject },\n use: [\n require.resolve('@pmmmwh/react-refresh-webpack-plugin/loader'),\n {\n loader: require.resolve('babel-loader'),\n options: {\n babelrc: false,\n configFile: false,\n plugins: [\n require.resolve('react-refresh/babel'),\n // for component highlighting in preview.\n [require.resolve('@teambit/react.babel.bit-react-transformer')],\n ],\n // turn off all optimizations (only slow down for node_modules)\n compact: false,\n minified: false,\n },\n },\n ],\n },\n // MDX support (move to the mdx aspect and extend from there)\n {\n test: /\\.mdx?$/,\n // to skip any files linked from other projects (like Bit itself)\n include: path.join(workDir, 'node_modules'),\n // only apply to packages with componentId in their package.json (ie. bit components)\n descriptionData: { componentId: (value) => !!value },\n use: [\n require.resolve('@pmmmwh/react-refresh-webpack-plugin/loader'),\n {\n loader: require.resolve('babel-loader'),\n options: {\n babelrc: false,\n configFile: false,\n presets: [require.resolve('@babel/preset-react'), require.resolve('@babel/preset-env')],\n plugins: [require.resolve('react-refresh/babel')],\n },\n },\n {\n loader: require.resolve('@teambit/mdx.modules.mdx-loader'),\n },\n ],\n },\n ],\n },\n plugins: [\n // No need here as we have `hot: true` in the dev server\n // new webpack.HotModuleReplacementPlugin({}),\n new ReactRefreshWebpackPlugin({\n overlay: {\n sockPath: `_hmr/${envId}`,\n // TODO: check why webpackHotDevClient and react-error-overlay are not responding for runtime\n // errors\n entry: require.resolve('./react-hot-dev-client'),\n module: require.resolve('./refresh'),\n },\n\n // we use '@pmmmwh/react-refresh-webpack-plugin/loader' directly where relevant.\n // FYI, original defaults of the plugin are:\n // include: /\\.([cm]js|[jt]sx?|flow)$/i, exclude: /node_modules/,\n include: matchNothingRegex,\n }),\n ],\n };\n}\n"]}
1
+ {"version":3,"sources":["webpack.config.component.dev.ts"],"names":["matchNothingRegex","workDir","envId","module","rules","test","enforce","include","path","join","descriptionData","componentId","value","use","require","resolve","ComponentID","isValidObject","loader","options","babelrc","configFile","plugins","compact","minified","presets","ReactRefresh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,KAA9B,CAHO;AAhEJ,GAAP;AAkFD","sourcesContent":["import path from 'path';\nimport { Configuration } from 'webpack';\nimport { ComponentID } from '@teambit/component-id';\n// Make sure the bit-react-transformer is a dependency\n// TODO: remove it once we can set policy from component to component then set it via the component.json\nimport '@teambit/react.babel.bit-react-transformer';\nimport ReactRefreshWebpackPlugin from '@pmmmwh/react-refresh-webpack-plugin';\n\nconst matchNothingRegex = 'a^';\n\n// This is the production and development configuration.\n// It is focused on developer experience, fast rebuilds, and a minimal bundle.\n// eslint-disable-next-line complexity\n// export default function (workDir: string, envId: string): Configuration {\nexport default function (workDir: string, envId: string): Configuration {\n return {\n module: {\n rules: [\n {\n test: /\\.js$/,\n enforce: 'pre',\n // limit loader to files in the current project,\n // to skip any files linked from other projects (like Bit itself)\n include: path.join(workDir, 'node_modules'),\n // only apply to packages with componentId in their package.json (ie. bit components)\n descriptionData: { componentId: (value) => !!value },\n use: [require.resolve('source-map-loader')],\n },\n {\n test: /\\.js$/,\n // limit loader to files in the current project,\n // to skip any files linked from other projects (like Bit itself)\n include: path.join(workDir, 'node_modules'),\n // only apply to packages with componentId in their package.json (ie. bit components)\n descriptionData: { componentId: ComponentID.isValidObject },\n use: [\n require.resolve('@pmmmwh/react-refresh-webpack-plugin/loader'),\n {\n loader: require.resolve('babel-loader'),\n options: {\n babelrc: false,\n configFile: false,\n plugins: [\n require.resolve('react-refresh/babel'),\n // for component highlighting in preview.\n [require.resolve('@teambit/react.babel.bit-react-transformer')],\n ],\n // turn off all optimizations (only slow down for node_modules)\n compact: false,\n minified: false,\n },\n },\n ],\n },\n // MDX support (move to the mdx aspect and extend from there)\n {\n test: /\\.mdx?$/,\n // to skip any files linked from other projects (like Bit itself)\n include: path.join(workDir, 'node_modules'),\n // only apply to packages with componentId in their package.json (ie. bit components)\n descriptionData: { componentId: (value) => !!value },\n use: [\n require.resolve('@pmmmwh/react-refresh-webpack-plugin/loader'),\n {\n loader: require.resolve('babel-loader'),\n options: {\n babelrc: false,\n configFile: false,\n presets: [require.resolve('@babel/preset-react'), require.resolve('@babel/preset-env')],\n plugins: [require.resolve('react-refresh/babel')],\n },\n },\n {\n loader: require.resolve('@teambit/mdx.modules.mdx-loader'),\n },\n ],\n },\n ],\n },\n plugins: [\n // No need here as we have `hot: true` in the dev server\n // new webpack.HotModuleReplacementPlugin({}),\n new ReactRefreshWebpackPlugin({\n overlay: {\n sockPath: `_hmr/${envId}`,\n // TODO - react-error-overlay not showing runtime errors - https://github.com/teambit/bit/issues/5452\n entry: require.resolve('./overlay/webpackHotDevClient'),\n module: require.resolve('./overlay/refreshOverlayInterop'),\n },\n\n // we use '@pmmmwh/react-refresh-webpack-plugin/loader' directly where relevant.\n // FYI, original defaults of the plugin are:\n // include: /\\.([cm]js|[jt]sx?|flow)$/i, exclude: /node_modules/,\n include: matchNothingRegex,\n }),\n ],\n };\n}\n"]}
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@teambit/react",
3
- "version": "0.0.658",
3
+ "version": "0.0.661",
4
4
  "homepage": "https://bit.dev/teambit/react/react",
5
5
  "main": "dist/index.js",
6
6
  "componentId": {
7
7
  "scope": "teambit.react",
8
8
  "name": "react",
9
- "version": "0.0.658"
9
+ "version": "0.0.661"
10
10
  },
11
11
  "dependencies": {
12
12
  "react-error-boundary": "^3.0.0",
@@ -32,8 +32,6 @@
32
32
  "@babel/preset-typescript": "7.12.17",
33
33
  "expose-loader": "3.1.0",
34
34
  "postcss-preset-env": "6.7.0",
35
- "react-error-overlay": "6.0.9",
36
- "strip-ansi": "6.0.0",
37
35
  "css-minimizer-webpack-plugin": "3.0.2",
38
36
  "terser-webpack-plugin": "5.2.0",
39
37
  "webpack": "5.51.1",
@@ -41,7 +39,9 @@
41
39
  "mini-css-extract-plugin": "2.2.2",
42
40
  "react-dev-utils": "11.0.4",
43
41
  "style-loader": "^2.0.0",
44
- "@pmmmwh/react-refresh-webpack-plugin": "0.5.1",
42
+ "@pmmmwh/react-refresh-webpack-plugin": "0.5.4",
43
+ "react-error-overlay": "6.0.10",
44
+ "strip-ansi": "6.0.0",
45
45
  "@dreysolano/prerender-spa-plugin": "1.0.3",
46
46
  "comment-json": "3.0.3",
47
47
  "react-refresh": "0.10.0",
@@ -79,39 +79,39 @@
79
79
  "@teambit/react.instructions.react.adding-compositions": "0.0.6",
80
80
  "@teambit/react.instructions.react.adding-tests": "0.0.6",
81
81
  "@teambit/design.ui.pages.standalone-not-found-page": "0.0.355",
82
- "@teambit/preview": "0.0.658",
82
+ "@teambit/preview": "0.0.661",
83
83
  "@teambit/react.ui.error-fallback": "0.0.110",
84
84
  "@teambit/react.ui.loader-fallback": "0.0.89",
85
85
  "@teambit/compositions.ui.hooks.use-composition": "0.0.163",
86
86
  "@teambit/design.ui.input.option-button": "0.0.26",
87
87
  "@teambit/design.ui.tooltip": "0.0.352",
88
- "@teambit/builder": "0.0.658",
89
- "@teambit/bundler": "0.0.658",
90
- "@teambit/compiler": "0.0.658",
88
+ "@teambit/builder": "0.0.661",
89
+ "@teambit/bundler": "0.0.661",
90
+ "@teambit/compiler": "0.0.661",
91
91
  "@teambit/component.modules.component-url": "0.0.123",
92
- "@teambit/component": "0.0.658",
93
- "@teambit/envs": "0.0.658",
94
- "@teambit/eslint": "0.0.658",
95
- "@teambit/formatter": "0.0.209",
96
- "@teambit/jest": "0.0.658",
97
- "@teambit/linter": "0.0.658",
98
- "@teambit/pkg": "0.0.658",
99
- "@teambit/prettier": "0.0.209",
92
+ "@teambit/component": "0.0.661",
93
+ "@teambit/envs": "0.0.661",
94
+ "@teambit/eslint": "0.0.661",
95
+ "@teambit/formatter": "0.0.212",
96
+ "@teambit/jest": "0.0.661",
97
+ "@teambit/linter": "0.0.661",
98
+ "@teambit/pkg": "0.0.661",
99
+ "@teambit/prettier": "0.0.212",
100
100
  "@teambit/react.ui.highlighter.component-metadata.bit-component-meta": "0.0.21",
101
- "@teambit/schema": "0.0.658",
102
- "@teambit/tester": "0.0.658",
103
- "@teambit/typescript": "0.0.658",
104
- "@teambit/webpack": "0.0.658",
105
- "@teambit/workspace": "0.0.658",
106
- "@teambit/application": "0.0.300",
107
- "@teambit/cli": "0.0.448",
108
- "@teambit/dependency-resolver": "0.0.658",
109
- "@teambit/generator": "0.0.658",
110
- "@teambit/graphql": "0.0.658",
101
+ "@teambit/schema": "0.0.661",
102
+ "@teambit/tester": "0.0.661",
103
+ "@teambit/typescript": "0.0.661",
104
+ "@teambit/webpack": "0.0.661",
105
+ "@teambit/workspace": "0.0.661",
106
+ "@teambit/application": "0.0.303",
107
+ "@teambit/cli": "0.0.449",
108
+ "@teambit/dependency-resolver": "0.0.661",
109
+ "@teambit/generator": "0.0.661",
110
+ "@teambit/graphql": "0.0.661",
111
111
  "@teambit/react.ui.highlighter-provider": "0.0.184",
112
- "@teambit/compositions": "0.0.658",
113
- "@teambit/ui": "0.0.658",
114
- "@teambit/react.eslint-config-bit-react": "0.0.525",
112
+ "@teambit/compositions": "0.0.661",
113
+ "@teambit/ui": "0.0.661",
114
+ "@teambit/react.eslint-config-bit-react": "0.0.526",
115
115
  "@teambit/webpack.modules.generate-expose-loaders": "0.0.3",
116
116
  "@teambit/webpack.modules.generate-externals": "0.0.3",
117
117
  "@teambit/webpack.modules.config-mutator": "0.0.137",
@@ -121,7 +121,7 @@
121
121
  "@teambit/webpack.modules.style-regexps": "0.0.132",
122
122
  "@teambit/component-id": "0.0.401",
123
123
  "@teambit/toolbox.network.get-port": "0.0.113",
124
- "@teambit/config": "0.0.461"
124
+ "@teambit/config": "0.0.462"
125
125
  },
126
126
  "devDependencies": {
127
127
  "@types/react": "^17.0.8",
@@ -131,6 +131,7 @@
131
131
  "@types/lodash.flatten": "4.4.6",
132
132
  "@types/webpack": "5.28.0",
133
133
  "@types/mini-css-extract-plugin": "2.2.0",
134
+ "@types/react-dev-utils": "9.0.10",
134
135
  "@types/postcss-normalize": "9.0.1",
135
136
  "@types/node": "12.20.4",
136
137
  "@types/mocha": "9.1.0",
@@ -139,7 +140,7 @@
139
140
  "@teambit/react.aspect-docs.react": "0.0.132"
140
141
  },
141
142
  "peerDependencies": {
142
- "@teambit/legacy": "1.0.227",
143
+ "@teambit/legacy": "1.0.228",
143
144
  "react-dom": "^16.8.0 || ^17.0.0",
144
145
  "react": "^16.8.0 || ^17.0.0"
145
146
  },
@@ -201,7 +202,7 @@
201
202
  "@types/jest": "^26.0.0"
202
203
  },
203
204
  "peerDependencies": {
204
- "@teambit/legacy": "1.0.227",
205
+ "@teambit/legacy": "1.0.228",
205
206
  "react-dom": "^16.8.0 || ^17.0.0",
206
207
  "react": "^16.8.0 || ^17.0.0"
207
208
  }
@@ -1,9 +1,13 @@
1
+ /* eslint-disable */
1
2
  /**
2
3
  * Copyright (c) 2015-present, Facebook, Inc.
3
4
  *
4
5
  * This source code is licensed under the MIT license found in the
5
6
  * LICENSE file in the root directory of this source tree.
6
7
  */
8
+
9
+ 'use strict';
10
+
7
11
  const friendlySyntaxErrorLabel = 'Syntax error:';
8
12
 
9
13
  function isLikelyASyntaxError(message) {
@@ -11,9 +15,20 @@ function isLikelyASyntaxError(message) {
11
15
  }
12
16
 
13
17
  // Cleans up webpack error messages.
14
- function formatMessage(error) {
15
- let message = error.message;
16
- let lines = message.split('\n');
18
+ function formatMessage(message) {
19
+ let lines = [];
20
+
21
+ if (typeof message === 'string') {
22
+ lines = message.split('\n');
23
+ } else if ('message' in message) {
24
+ lines = message['message'].split('\n');
25
+ } else if (Array.isArray(message)) {
26
+ message.forEach((message) => {
27
+ if ('message' in message) {
28
+ lines = message['message'].split('\n');
29
+ }
30
+ });
31
+ }
17
32
 
18
33
  // Strip webpack-added headers off errors/warnings
19
34
  // https://github.com/webpack/webpack/blob/master/lib/ModuleError.js
@@ -64,9 +79,9 @@ function formatMessage(error) {
64
79
  }
65
80
 
66
81
  // Add helpful message for users trying to use Sass for the first time
67
- if (lines[1] && lines[1].match(/Cannot find module.+node-sass/)) {
68
- lines[1] = 'To import Sass files, you first need to install node-sass.\n';
69
- lines[1] += 'Run `npm install node-sass` or `yarn add node-sass` inside your workspace.';
82
+ if (lines[1] && lines[1].match(/Cannot find module.+sass/)) {
83
+ lines[1] = 'To import Sass files, you first need to install sass.\n';
84
+ lines[1] += 'Run `bit install sass` inside your workspace.';
70
85
  }
71
86
 
72
87
  message = lines.join('\n');
@@ -1,8 +1,11 @@
1
+ /* eslint-disable */
1
2
  /**
2
3
  * Copyright (c) 2015-present, Facebook, Inc.
3
4
  *
4
5
  * This source code is licensed under the MIT license found in the
5
6
  * LICENSE file in the root directory of this source tree.
6
7
  */
8
+ 'use strict';
9
+
7
10
  // TODO: we might want to make this injectable to support DEV-time non-root URLs.
8
11
  module.exports = '/__open-stack-frame-in-editor';
@@ -1,3 +1,6 @@
1
+ /* eslint-disable */
2
+ /** this file was copied as is from react-dev-utils/refreshOverlayInterop */
3
+
1
4
  // @remove-on-eject-begin
2
5
  /**
3
6
  * Copyright (c) 2015-present, Facebook, Inc.