@teambit/react 0.0.554 → 0.0.558

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 (98) hide show
  1. package/dist/mount.d.ts +5 -0
  2. package/dist/react-app-options.d.ts +25 -0
  3. package/dist/react.env.d.ts +87 -1
  4. package/dist/react.main.runtime.d.ts +89 -1
  5. package/package.json +51 -43
  6. package/tsconfig.json +1 -2
  7. package/compositions-app.tsx +0 -31
  8. package/eslint/eslintrc.js +0 -12
  9. package/highlighter-widget.tsx +0 -19
  10. package/index.ts +0 -9
  11. package/jest/css-transform.js +0 -12
  12. package/jest/file-transform.js +0 -38
  13. package/jest/jest.config.js +0 -30
  14. package/jest/setupTests.js +0 -7
  15. package/jest/transformer.js +0 -41
  16. package/mount.tsx +0 -17
  17. package/package-tar/teambit-react-0.0.554.tgz +0 -0
  18. package/prettier/prettier.config.js +0 -5
  19. package/react-app-options.ts +0 -45
  20. package/react.app-type.ts +0 -19
  21. package/react.application.ts +0 -96
  22. package/react.aspect.ts +0 -5
  23. package/react.composition.tsx +0 -7
  24. package/react.docs.mdx +0 -8
  25. package/react.env.ts +0 -363
  26. package/react.graphql.ts +0 -52
  27. package/react.main.runtime.ts +0 -437
  28. package/react.preview.runtime.ts +0 -44
  29. package/react.templates.ts +0 -29
  30. package/react.ui.runtime.tsx +0 -35
  31. package/templates/react-app/files/app-root.ts +0 -10
  32. package/templates/react-app/files/app.ts +0 -30
  33. package/templates/react-app/files/aspect.ts +0 -10
  34. package/templates/react-app/files/compositions.ts +0 -11
  35. package/templates/react-app/files/doc.ts +0 -29
  36. package/templates/react-app/files/index.ts +0 -10
  37. package/templates/react-app/files/main.runtime.ts +0 -22
  38. package/templates/react-app/index.ts +0 -47
  39. package/templates/react-component/files/component.ts +0 -25
  40. package/templates/react-component/files/composition.ts +0 -16
  41. package/templates/react-component/files/docs.ts +0 -32
  42. package/templates/react-component/files/test.ts +0 -19
  43. package/templates/react-component/index.ts +0 -40
  44. package/templates/react-component-js/files/component.ts +0 -18
  45. package/templates/react-component-js/files/composition.ts +0 -16
  46. package/templates/react-component-js/files/docs.ts +0 -32
  47. package/templates/react-component-js/files/test.ts +0 -21
  48. package/templates/react-component-js/index.ts +0 -38
  49. package/templates/react-context/files/composition.ts +0 -27
  50. package/templates/react-context/files/context-provider.ts +0 -27
  51. package/templates/react-context/files/context.ts +0 -21
  52. package/templates/react-context/files/docs.ts +0 -51
  53. package/templates/react-context/files/test.ts +0 -18
  54. package/templates/react-context/index.ts +0 -32
  55. package/templates/react-env/files/aspect.ts +0 -10
  56. package/templates/react-env/files/doc.ts +0 -163
  57. package/templates/react-env/files/index.ts +0 -10
  58. package/templates/react-env/files/jest.config.ts +0 -21
  59. package/templates/react-env/files/main.runtime.ts +0 -84
  60. package/templates/react-env/files/preview.runtime.ts +0 -27
  61. package/templates/react-env/files/typescript.config.ts +0 -21
  62. package/templates/react-env/files/webpack.config.ts +0 -48
  63. package/templates/react-env/index.ts +0 -51
  64. package/templates/react-hook/files/component.ts +0 -16
  65. package/templates/react-hook/files/composition.ts +0 -23
  66. package/templates/react-hook/files/docs.ts +0 -33
  67. package/templates/react-hook/files/test.ts +0 -20
  68. package/templates/react-hook/index.ts +0 -21
  69. package/templates/react-workspace/index.ts +0 -27
  70. package/templates/react-workspace-app/index.ts +0 -20
  71. package/templates/react-workspace-deprecated/index.ts +0 -28
  72. package/templates/react-workspace-lib/index.ts +0 -21
  73. package/templates/workspace-common/files/eslint-config.ts +0 -6
  74. package/templates/workspace-common/files/git-ignore.ts +0 -113
  75. package/templates/workspace-common/files/prettier-config.ts +0 -5
  76. package/templates/workspace-common/files/readme-file.ts +0 -36
  77. package/templates/workspace-common/files/ts-config.ts +0 -7
  78. package/templates/workspace-common/files/types/asset.ts +0 -28
  79. package/templates/workspace-common/files/types/style.ts +0 -43
  80. package/templates/workspace-common/files/workspace-config.ts +0 -58
  81. package/templates/workspace-common/generate-files.ts +0 -51
  82. package/templates/workspace-common/index.ts +0 -1
  83. package/types/asset.d.ts +0 -29
  84. package/types/style.d.ts +0 -42
  85. package/typescript/asset.d.ts +0 -29
  86. package/typescript/style.d.ts +0 -42
  87. package/typescript/tsconfig.build.json +0 -22
  88. package/typescript/tsconfig.json +0 -18
  89. package/webpack/format-webpack-messages.js +0 -102
  90. package/webpack/launch-editor-endpoint.js +0 -8
  91. package/webpack/postcss.config.ts +0 -21
  92. package/webpack/react-hot-dev-client.js +0 -274
  93. package/webpack/refresh.js +0 -16
  94. package/webpack/webpack.config.base.prod.ts +0 -123
  95. package/webpack/webpack.config.base.ts +0 -365
  96. package/webpack/webpack.config.component.dev.ts +0 -104
  97. package/webpack/webpack.config.component.prod.ts +0 -39
  98. package/webpack/webpack.config.env.dev.ts +0 -21
@@ -1,274 +0,0 @@
1
- /* eslint-disable promise/catch-or-return */
2
- /**
3
- * Copyright (c) 2015-present, Facebook, Inc.
4
- *
5
- * This source code is licensed under the MIT license found in the
6
- * LICENSE file in the root directory of this source tree.
7
- */
8
- const stripAnsi = require('strip-ansi');
9
- const ErrorOverlay = require('react-error-overlay');
10
- const url = require('url');
11
- const launchEditorEndpoint = require('./launch-editor-endpoint');
12
- const formatWebpackMessages = require('./format-webpack-messages');
13
-
14
- ErrorOverlay.setEditorHandler(function editorHandler(errorLocation) {
15
- // Keep this sync with errorOverlayMiddleware.js
16
- // eslint-disable-next-line @typescript-eslint/no-floating-promises
17
- fetch(
18
- `${launchEditorEndpoint}?fileName=${window.encodeURIComponent(
19
- errorLocation.fileName
20
- )}&lineNumber=${window.encodeURIComponent(errorLocation.lineNumber || 1)}&colNumber=${window.encodeURIComponent(
21
- errorLocation.colNumber || 1
22
- )}`
23
- );
24
- });
25
-
26
- // We need to keep track of if there has been a runtime error.
27
- // Essentially, we cannot guarantee application state was not corrupted by the
28
- // runtime error. To prevent confusing behavior, we forcibly reload the entire
29
- // application. This is handled below when we are notified of a compile (code
30
- // change).
31
- // See https://github.com/facebook/create-react-app/issues/3096
32
- let hadRuntimeError = false;
33
- ErrorOverlay.startReportingRuntimeErrors({
34
- onError() {
35
- hadRuntimeError = true;
36
- },
37
- filename: '/static/js/bundle.js',
38
- });
39
-
40
- if (module.hot && typeof module.hot.dispose === 'function') {
41
- module.hot.dispose(function () {
42
- // TODO: why do we need this?
43
- ErrorOverlay.stopReportingRuntimeErrors();
44
- });
45
- }
46
-
47
- // Connect to WebpackDevServer via a socket.
48
- const querystring = module.id.substring(module.id.indexOf('?'));
49
- const urlParams = new URLSearchParams(querystring);
50
-
51
- const connection = new WebSocket(
52
- url.format({
53
- protocol: window.location.protocol === 'https:' ? 'wss' : 'ws',
54
- hostname: window.location.hostname,
55
- port: window.location.port,
56
- // Hardcoded in WebpackDevServer
57
- pathname: urlParams.get('sockPath') || '/sockjs-node',
58
- // pathname: '_hmr/teambit.bad-jokes/extensions/harmony-react',
59
- slashes: true,
60
- })
61
- );
62
-
63
- // Unlike WebpackDevServer client, we won't try to reconnect
64
- // to avoid spamming the console. Disconnect usually happens
65
- // when developer stops the server.
66
- connection.onclose = function () {
67
- // eslint-disable-next-line no-console
68
- if (typeof console !== 'undefined' && typeof console.info === 'function') {
69
- // eslint-disable-next-line no-console
70
- console.info('The development server has disconnected.\nRefresh the page if necessary.');
71
- }
72
- };
73
-
74
- // Remember some state related to hot module replacement.
75
- let isFirstCompilation = true;
76
- let mostRecentCompilationHash = null;
77
- let hasCompileErrors = false;
78
-
79
- function clearOutdatedErrors() {
80
- // Clean up outdated compile errors, if any.
81
- // eslint-disable-next-line no-console
82
- if (typeof console !== 'undefined' && typeof console.clear === 'function') {
83
- if (hasCompileErrors) {
84
- // eslint-disable-next-line no-console
85
- console.clear();
86
- }
87
- }
88
- }
89
-
90
- // Successful compilation.
91
- function handleSuccess() {
92
- clearOutdatedErrors();
93
-
94
- const isHotUpdate = !isFirstCompilation;
95
- isFirstCompilation = false;
96
- hasCompileErrors = false;
97
-
98
- // Attempt to apply hot updates or reload.
99
- if (isHotUpdate) {
100
- tryApplyUpdates(function onHotUpdateSuccess() {
101
- // Only dismiss it when we're sure it's a hot update.
102
- // Otherwise it would flicker right before the reload.
103
- tryDismissErrorOverlay();
104
- });
105
- }
106
- }
107
-
108
- // Compilation with warnings (e.g. ESLint).
109
- function handleWarnings(warnings) {
110
- clearOutdatedErrors();
111
-
112
- const isHotUpdate = !isFirstCompilation;
113
- isFirstCompilation = false;
114
- hasCompileErrors = false;
115
-
116
- function printWarnings() {
117
- // Print warnings to the console.
118
- const formatted = formatWebpackMessages({
119
- warnings,
120
- errors: [],
121
- });
122
-
123
- // eslint-disable-next-line no-console
124
- if (typeof console !== 'undefined' && typeof console.warn === 'function') {
125
- // eslint-disable-next-line no-plusplus
126
- for (let i = 0; i < formatted.warnings.length; i++) {
127
- if (i === 5) {
128
- // eslint-disable-next-line
129
- console.warn('There were more warnings in other files.\n' + 'You can find a complete log in the terminal.');
130
- break;
131
- }
132
- // eslint-disable-next-line no-console
133
- console.warn(stripAnsi(formatted.warnings[i]));
134
- }
135
- }
136
- }
137
-
138
- printWarnings();
139
-
140
- // Attempt to apply hot updates or reload.
141
- if (isHotUpdate) {
142
- tryApplyUpdates(function onSuccessfulHotUpdate() {
143
- // Only dismiss it when we're sure it's a hot update.
144
- // Otherwise it would flicker right before the reload.
145
- tryDismissErrorOverlay();
146
- });
147
- }
148
- }
149
-
150
- // Compilation with errors (e.g. syntax error or missing modules).
151
- function handleErrors(errors) {
152
- clearOutdatedErrors();
153
-
154
- isFirstCompilation = false;
155
- hasCompileErrors = true;
156
-
157
- // "Massage" webpack messages.
158
- const formatted = formatWebpackMessages({
159
- errors,
160
- warnings: [],
161
- });
162
-
163
- // Only show the first error.
164
- ErrorOverlay.reportBuildError(formatted.errors[0]);
165
-
166
- // Also log them to the console.
167
- // eslint-disable-next-line no-console
168
- if (typeof console !== 'undefined' && typeof console.error === 'function') {
169
- // eslint-disable-next-line no-plusplus
170
- for (let i = 0; i < formatted.errors.length; i++) {
171
- // eslint-disable-next-line no-console
172
- console.error(stripAnsi(formatted.errors[i]));
173
- }
174
- }
175
-
176
- // Do not attempt to reload now.
177
- // We will reload on next success instead.
178
- }
179
-
180
- function tryDismissErrorOverlay() {
181
- if (!hasCompileErrors) {
182
- ErrorOverlay.dismissBuildError();
183
- }
184
- }
185
-
186
- // There is a newer version of the code available.
187
- function handleAvailableHash(hash) {
188
- // Update last known compilation hash.
189
- mostRecentCompilationHash = hash;
190
- }
191
-
192
- // Handle messages from the server.
193
- connection.onmessage = function (e) {
194
- const message = JSON.parse(e.data);
195
- switch (message.type) {
196
- case 'hash':
197
- handleAvailableHash(message.data);
198
- break;
199
- case 'still-ok':
200
- case 'ok':
201
- handleSuccess();
202
- break;
203
- case 'content-changed':
204
- // Triggered when a file from `contentBase` changed.
205
- window.location.reload();
206
- break;
207
- case 'warnings':
208
- handleWarnings(message.data);
209
- break;
210
- case 'errors':
211
- handleErrors(message.data);
212
- break;
213
- default:
214
- // Do nothing.
215
- }
216
- };
217
-
218
- // Is there a newer version of this code available?
219
- function isUpdateAvailable() {
220
- /* globals __webpack_hash__ */
221
- // __webpack_hash__ is the hash of the current compilation.
222
- // It's a global variable injected by webpack.
223
- return mostRecentCompilationHash !== __webpack_hash__;
224
- }
225
-
226
- // webpack disallows updates in other states.
227
- function canApplyUpdates() {
228
- return module.hot.status() === 'idle';
229
- }
230
-
231
- // Attempt to update code on the fly, fall back to a hard reload.
232
- function tryApplyUpdates(onHotUpdateSuccess) {
233
- if (!module.hot) {
234
- // HotModuleReplacementPlugin is not in webpack configuration.
235
- window.location.reload();
236
- return;
237
- }
238
-
239
- if (!isUpdateAvailable() || !canApplyUpdates()) {
240
- return;
241
- }
242
-
243
- function handleApplyUpdates(err, updatedModules) {
244
- if (err || !updatedModules || hadRuntimeError) {
245
- window.location.reload();
246
- return;
247
- }
248
-
249
- if (typeof onHotUpdateSuccess === 'function') {
250
- // Maybe we want to do something.
251
- onHotUpdateSuccess();
252
- }
253
-
254
- if (isUpdateAvailable()) {
255
- // While we were updating, there was a new update! Do it again.
256
- tryApplyUpdates();
257
- }
258
- }
259
-
260
- // https://webpack.github.io/docs/hot-module-replacement.html#check
261
- const result = module.hot.check(/* autoApply */ true, handleApplyUpdates);
262
-
263
- // // webpack 2 returns a Promise instead of invoking a callback
264
- if (result && result.then) {
265
- result.then(
266
- function (updatedModules) {
267
- handleApplyUpdates(null, updatedModules);
268
- },
269
- function (err) {
270
- handleApplyUpdates(err, null);
271
- }
272
- );
273
- }
274
- }
@@ -1,16 +0,0 @@
1
- // @remove-on-eject-begin
2
- /**
3
- * Copyright (c) 2015-present, Facebook, Inc.
4
- *
5
- * This source code is licensed under the MIT license found in the
6
- * LICENSE file in the root directory of this source tree.
7
- */
8
- // @remove-on-eject-end
9
- 'use strict';
10
-
11
- const { dismissRuntimeErrors, reportRuntimeError } = require('react-error-overlay');
12
-
13
- module.exports = {
14
- clearRuntimeErrors: dismissRuntimeErrors,
15
- handleRuntimeError: reportRuntimeError,
16
- };
@@ -1,123 +0,0 @@
1
- import WorkboxWebpackPlugin from 'workbox-webpack-plugin';
2
- import CssMinimizerPlugin from 'css-minimizer-webpack-plugin';
3
- import TerserPlugin from 'terser-webpack-plugin';
4
- import { Configuration } from 'webpack';
5
- import { WebpackManifestPlugin } from 'webpack-manifest-plugin';
6
-
7
- // This is the production and development configuration.
8
- // It is focused on developer experience, fast rebuilds, and a minimal bundle.
9
- // eslint-disable-next-line complexity
10
- export default function (): Configuration {
11
- return {
12
- optimization: {
13
- minimize: true,
14
- minimizer: [
15
- // This is only used in production mode
16
- new TerserPlugin({
17
- terserOptions: {
18
- parse: {
19
- // We want terser to parse ecma 8 code. However, we don't want it
20
- // to apply any minification steps that turns valid ecma 5 code
21
- // into invalid ecma 5 code. This is why the 'compress' and 'output'
22
- // sections only apply transformations that are ecma 5 safe
23
- // https://github.com/facebook/create-react-app/pull/4234
24
- ecma: 8,
25
- },
26
- compress: {
27
- ecma: 5,
28
- warnings: false,
29
- // Disabled because of an issue with Uglify breaking seemingly valid code:
30
- // https://github.com/facebook/create-react-app/issues/2376
31
- // Pending further investigation:
32
- // https://github.com/mishoo/UglifyJS2/issues/2011
33
- comparisons: false,
34
- // Disabled because of an issue with Terser breaking valid code:
35
- // https://github.com/facebook/create-react-app/issues/5250
36
- // Pending further investigation:
37
- // https://github.com/terser-js/terser/issues/120
38
- inline: 2,
39
- },
40
- mangle: {
41
- safari10: true,
42
- },
43
- output: {
44
- ecma: 5,
45
- comments: false,
46
- // Turned on because emoji and regex is not minified properly using default
47
- // https://github.com/facebook/create-react-app/issues/2488
48
- ascii_only: true,
49
- },
50
- },
51
- }),
52
- new CssMinimizerPlugin({
53
- minimizerOptions: {
54
- preset: [
55
- 'default',
56
- {
57
- minifyFontValues: { removeQuotes: false },
58
- },
59
- ],
60
- },
61
- }),
62
- ],
63
- // Automatically split vendor and commons
64
- // https://twitter.com/wSokra/status/969633336732905474
65
- // https://medium.com/webpack/webpack-4-code-splitting-chunk-graph-and-the-splitchunks-optimization-be739a861366
66
- splitChunks: {
67
- chunks: 'all',
68
- // name: false,
69
- },
70
- // Keep the runtime chunk separated to enable long term caching
71
- // https://twitter.com/wSokra/status/969679223278505985
72
- // https://github.com/facebook/create-react-app/issues/5358
73
- runtimeChunk: {
74
- name: (entrypoint) => `runtime-${entrypoint.name}`,
75
- },
76
- },
77
-
78
- plugins: [
79
- // Generate an asset manifest file with the following content:
80
- // - "files" key: Mapping of all asset filenames to their corresponding
81
- // output file so that tools can pick it up without having to parse
82
- // `index.html`
83
- // can be used to reconstruct the HTML if necessary
84
- new WebpackManifestPlugin({
85
- fileName: 'asset-manifest.json',
86
- publicPath: 'public',
87
- generate: (seed, files, entrypoints) => {
88
- const manifestFiles = files.reduce((manifest, file) => {
89
- manifest[file.name] = file.path;
90
- return manifest;
91
- }, seed);
92
- const entrypointFiles = entrypoints.main.filter((fileName) => !fileName.endsWith('.map'));
93
-
94
- // @ts-ignore - https://github.com/shellscape/webpack-manifest-plugin/issues/276
95
- return {
96
- files: manifestFiles,
97
- entrypoints: entrypointFiles,
98
- } as Record<string, string>;
99
- },
100
- }),
101
- // Generate a service worker script that will precache, and keep up to date,
102
- // the HTML & assets that are part of the webpack build.
103
- new WorkboxWebpackPlugin.GenerateSW({
104
- clientsClaim: true,
105
- exclude: [/\.map$/, /asset-manifest\.json$/],
106
- // importWorkboxFrom: 'cdn',
107
- navigateFallback: 'public/index.html',
108
- navigateFallbackDenylist: [
109
- // Exclude URLs starting with /_, as they're likely an API call
110
- new RegExp('^/_'),
111
- // Exclude any URLs whose last part seems to be a file extension
112
- // as they're likely a resource and not a SPA route.
113
- // URLs containing a "?" character won't be blacklisted as they're likely
114
- // a route with query params (e.g. auth callbacks).
115
- new RegExp('/[^/?]+\\.[^/]+$'),
116
- ],
117
- }),
118
- ].filter(Boolean),
119
- // Turn off performance processing because we utilize
120
- // our own hints via the FileSizeReporter
121
- performance: false,
122
- };
123
- }