@teambit/react 0.0.880 → 0.0.882

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 (236) hide show
  1. package/artifacts/__bit_junit.xml +2 -2
  2. package/artifacts/env-template/public/{770.8cc321d531369e25ec1c.js → 700.fcb0085dcdf160cc65c9.js} +18 -20
  3. package/artifacts/env-template/public/assets-manifest.json +16 -16
  4. package/artifacts/env-template/public/{compositions.aab650d15edcf055899a.js → compositions.d36450c5ae70173e7a70.js} +1 -1
  5. package/artifacts/env-template/public/compositions.html +1 -1
  6. package/artifacts/env-template/public/{overview.5ef8ce1624e4c34dadf2.js → overview.ca1695b4bf4d507d7a28.js} +1 -1
  7. package/artifacts/env-template/public/overview.html +1 -1
  8. package/artifacts/env-template/public/peers.9642cecf0c09b9d93f54.js +1 -0
  9. package/artifacts/env-template/public/{preview-root.48c79384da92a8a7a512.js → preview-root.a829360e0cc95e341dfd.js} +1 -1
  10. package/artifacts/env-template/public/static/css/700.bd8655a5.css +1 -0
  11. package/artifacts/env-template/public/static/css/compositions.e163efe5.css +1 -0
  12. package/artifacts/env-template/public/static/css/{overview.367aeb5b.css → overview.18adf1ee.css} +1 -1
  13. package/artifacts/preview/teambit_react_react-preview.js +1 -1
  14. package/{compositions-1666312873430.js → compositions-1666496165706.js} +0 -0
  15. package/dist/apps/web/compute-results.js +0 -2
  16. package/dist/apps/web/compute-results.js.map +1 -1
  17. package/dist/apps/web/index.js +0 -3
  18. package/dist/apps/web/index.js.map +1 -1
  19. package/dist/apps/web/plugins/index.js +0 -3
  20. package/dist/apps/web/plugins/index.js.map +1 -1
  21. package/dist/apps/web/plugins/prerender.js +0 -14
  22. package/dist/apps/web/plugins/prerender.js.map +1 -1
  23. package/dist/apps/web/react.app-type.js +0 -7
  24. package/dist/apps/web/react.app-type.js.map +1 -1
  25. package/dist/apps/web/react.application.js +11 -76
  26. package/dist/apps/web/react.application.js.map +1 -1
  27. package/dist/apps/web/ssr/ssr-express.js +0 -31
  28. package/dist/apps/web/ssr/ssr-express.js.map +1 -1
  29. package/dist/apps/web/webpack/mutators.js +0 -13
  30. package/dist/apps/web/webpack/mutators.js.map +1 -1
  31. package/dist/apps/web/webpack/webpack.app.ssr.config.js +0 -11
  32. package/dist/apps/web/webpack/webpack.app.ssr.config.js.map +1 -1
  33. package/dist/eslint/eslintrc.js +1 -1
  34. package/dist/eslint/eslintrc.js.map +1 -1
  35. package/dist/highlighter-widget.js +0 -16
  36. package/dist/highlighter-widget.js.map +1 -1
  37. package/dist/index.js +0 -3
  38. package/dist/index.js.map +1 -1
  39. package/dist/jest/index.js +0 -7
  40. package/dist/jest/index.js.map +1 -1
  41. package/dist/jest/jest.base.config.js +3 -3
  42. package/dist/jest/jest.base.config.js.map +1 -1
  43. package/dist/jest/jest.cjs.config.js +0 -10
  44. package/dist/jest/jest.cjs.config.js.map +1 -1
  45. package/dist/jest/jest.config.js +1 -1
  46. package/dist/jest/jest.config.js.map +1 -1
  47. package/dist/jest/jest.esm.config.js +0 -10
  48. package/dist/jest/jest.esm.config.js.map +1 -1
  49. package/dist/jest/setupTests.js.map +1 -1
  50. package/dist/jest/transformers/base-transformer-plugins.js +1 -0
  51. package/dist/jest/transformers/base-transformer-plugins.js.map +1 -1
  52. package/dist/jest/transformers/base-transformer-presets.js +1 -0
  53. package/dist/jest/transformers/base-transformer-presets.js.map +1 -1
  54. package/dist/jest/transformers/base-transformer-process.js +0 -2
  55. package/dist/jest/transformers/base-transformer-process.js.map +1 -1
  56. package/dist/jest/transformers/cjs-transformer.js +0 -5
  57. package/dist/jest/transformers/cjs-transformer.js.map +1 -1
  58. package/dist/jest/transformers/css-transform.js +1 -2
  59. package/dist/jest/transformers/css-transform.js.map +1 -1
  60. package/dist/jest/transformers/esm-transformer.js +1 -5
  61. package/dist/jest/transformers/esm-transformer.js.map +1 -1
  62. package/dist/jest/transformers/file-transform.js +2 -6
  63. package/dist/jest/transformers/file-transform.js.map +1 -1
  64. package/dist/prettier/prettier.config.js.map +1 -1
  65. package/dist/react.aspect.js +0 -5
  66. package/dist/react.aspect.js.map +1 -1
  67. package/dist/react.composition.js +0 -6
  68. package/dist/react.composition.js.map +1 -1
  69. package/dist/react.env.js +34 -143
  70. package/dist/react.env.js.map +1 -1
  71. package/dist/react.graphql.js +0 -6
  72. package/dist/react.graphql.js.map +1 -1
  73. package/dist/react.main.runtime.js +23 -152
  74. package/dist/react.main.runtime.js.map +1 -1
  75. package/dist/react.preview.runtime.js +0 -32
  76. package/dist/react.preview.runtime.js.map +1 -1
  77. package/dist/react.templates.js +0 -46
  78. package/dist/react.templates.js.map +1 -1
  79. package/dist/react.ui.runtime.js +0 -35
  80. package/dist/react.ui.runtime.js.map +1 -1
  81. package/dist/templates/react-app/files/app-plugin.js +0 -1
  82. package/dist/templates/react-app/files/app-plugin.js.map +1 -1
  83. package/dist/templates/react-app/files/app-root.js +0 -1
  84. package/dist/templates/react-app/files/app-root.js.map +1 -1
  85. package/dist/templates/react-app/files/app.js +0 -1
  86. package/dist/templates/react-app/files/app.js.map +1 -1
  87. package/dist/templates/react-app/files/compositions.js +0 -1
  88. package/dist/templates/react-app/files/compositions.js.map +1 -1
  89. package/dist/templates/react-app/files/doc.js +0 -1
  90. package/dist/templates/react-app/files/doc.js.map +1 -1
  91. package/dist/templates/react-app/files/index.js +0 -1
  92. package/dist/templates/react-app/files/index.js.map +1 -1
  93. package/dist/templates/react-app/index.js +0 -19
  94. package/dist/templates/react-app/index.js.map +1 -1
  95. package/dist/templates/react-component/files/component.js +0 -2
  96. package/dist/templates/react-component/files/component.js.map +1 -1
  97. package/dist/templates/react-component/files/composition.js +0 -2
  98. package/dist/templates/react-component/files/composition.js.map +1 -1
  99. package/dist/templates/react-component/files/docs.js +0 -2
  100. package/dist/templates/react-component/files/docs.js.map +1 -1
  101. package/dist/templates/react-component/files/index-file.js +0 -2
  102. package/dist/templates/react-component/files/index-file.js.map +1 -1
  103. package/dist/templates/react-component/files/test.js +0 -2
  104. package/dist/templates/react-component/files/test.js.map +1 -1
  105. package/dist/templates/react-component/index.js +0 -24
  106. package/dist/templates/react-component/index.js.map +1 -1
  107. package/dist/templates/react-component-js/files/component.js +0 -2
  108. package/dist/templates/react-component-js/files/component.js.map +1 -1
  109. package/dist/templates/react-component-js/files/composition.js +0 -2
  110. package/dist/templates/react-component-js/files/composition.js.map +1 -1
  111. package/dist/templates/react-component-js/files/docs.js +0 -2
  112. package/dist/templates/react-component-js/files/docs.js.map +1 -1
  113. package/dist/templates/react-component-js/files/test.js +0 -2
  114. package/dist/templates/react-component-js/files/test.js.map +1 -1
  115. package/dist/templates/react-component-js/index.js +0 -21
  116. package/dist/templates/react-component-js/index.js.map +1 -1
  117. package/dist/templates/react-context/files/composition.js +0 -2
  118. package/dist/templates/react-context/files/composition.js.map +1 -1
  119. package/dist/templates/react-context/files/context-provider.js +0 -2
  120. package/dist/templates/react-context/files/context-provider.js.map +1 -1
  121. package/dist/templates/react-context/files/context.js +0 -2
  122. package/dist/templates/react-context/files/context.js.map +1 -1
  123. package/dist/templates/react-context/files/docs.js +0 -2
  124. package/dist/templates/react-context/files/docs.js.map +1 -1
  125. package/dist/templates/react-context/files/index-file.js +0 -2
  126. package/dist/templates/react-context/files/index-file.js.map +1 -1
  127. package/dist/templates/react-context/files/test.js +0 -2
  128. package/dist/templates/react-context/files/test.js.map +1 -1
  129. package/dist/templates/react-context/index.js +0 -19
  130. package/dist/templates/react-context/index.js.map +1 -1
  131. package/dist/templates/react-env/files/aspect.js +0 -1
  132. package/dist/templates/react-env/files/aspect.js.map +1 -1
  133. package/dist/templates/react-env/files/doc.js +0 -1
  134. package/dist/templates/react-env/files/doc.js.map +1 -1
  135. package/dist/templates/react-env/files/index.js +0 -1
  136. package/dist/templates/react-env/files/index.js.map +1 -1
  137. package/dist/templates/react-env/files/jest.config.js +0 -1
  138. package/dist/templates/react-env/files/jest.config.js.map +1 -1
  139. package/dist/templates/react-env/files/main.runtime.js +0 -1
  140. package/dist/templates/react-env/files/main.runtime.js.map +1 -1
  141. package/dist/templates/react-env/files/preview.runtime.js +0 -1
  142. package/dist/templates/react-env/files/preview.runtime.js.map +1 -1
  143. package/dist/templates/react-env/files/typescript/styles.js +0 -1
  144. package/dist/templates/react-env/files/typescript/styles.js.map +1 -1
  145. package/dist/templates/react-env/files/typescript/ts-transformer.js +0 -1
  146. package/dist/templates/react-env/files/typescript/ts-transformer.js.map +1 -1
  147. package/dist/templates/react-env/files/typescript/typescript.config.js +0 -1
  148. package/dist/templates/react-env/files/typescript/typescript.config.js.map +1 -1
  149. package/dist/templates/react-env/files/webpack.config.js +0 -1
  150. package/dist/templates/react-env/files/webpack.config.js.map +1 -1
  151. package/dist/templates/react-env/index.js +0 -31
  152. package/dist/templates/react-env/index.js.map +1 -1
  153. package/dist/templates/react-hook/files/component.js +0 -2
  154. package/dist/templates/react-hook/files/component.js.map +1 -1
  155. package/dist/templates/react-hook/files/composition.js +0 -2
  156. package/dist/templates/react-hook/files/composition.js.map +1 -1
  157. package/dist/templates/react-hook/files/docs.js +0 -2
  158. package/dist/templates/react-hook/files/docs.js.map +1 -1
  159. package/dist/templates/react-hook/files/index-file.js +0 -2
  160. package/dist/templates/react-hook/files/index-file.js.map +1 -1
  161. package/dist/templates/react-hook/files/index-file.spec.js +0 -6
  162. package/dist/templates/react-hook/files/index-file.spec.js.map +1 -1
  163. package/dist/templates/react-hook/files/test.js +0 -2
  164. package/dist/templates/react-hook/files/test.js.map +1 -1
  165. package/dist/templates/react-hook/index.js +0 -16
  166. package/dist/templates/react-hook/index.js.map +1 -1
  167. package/dist/templates/react-workspace/index.js +2 -6
  168. package/dist/templates/react-workspace/index.js.map +1 -1
  169. package/dist/templates/react-workspace-analytics/index.js +0 -5
  170. package/dist/templates/react-workspace-analytics/index.js.map +1 -1
  171. package/dist/templates/react-workspace-app/index.js +2 -13
  172. package/dist/templates/react-workspace-app/index.js.map +1 -1
  173. package/dist/templates/react-workspace-blog/index.js +0 -5
  174. package/dist/templates/react-workspace-blog/index.js.map +1 -1
  175. package/dist/templates/react-workspace-data-fetching/index.js +0 -5
  176. package/dist/templates/react-workspace-data-fetching/index.js.map +1 -1
  177. package/dist/templates/react-workspace-deprecated/index.js +0 -5
  178. package/dist/templates/react-workspace-deprecated/index.js.map +1 -1
  179. package/dist/templates/react-workspace-design-system/index.js +0 -5
  180. package/dist/templates/react-workspace-design-system/index.js.map +1 -1
  181. package/dist/templates/react-workspace-lib/index.js +0 -5
  182. package/dist/templates/react-workspace-lib/index.js.map +1 -1
  183. package/dist/templates/react-workspace-wiki/index.js +0 -5
  184. package/dist/templates/react-workspace-wiki/index.js.map +1 -1
  185. package/dist/templates/workspace-common/constants.js.map +1 -1
  186. package/dist/templates/workspace-common/files/eslint-config.js.map +1 -1
  187. package/dist/templates/workspace-common/files/git-ignore.js +0 -1
  188. package/dist/templates/workspace-common/files/git-ignore.js.map +1 -1
  189. package/dist/templates/workspace-common/files/launch-json.js +0 -2
  190. package/dist/templates/workspace-common/files/launch-json.js.map +1 -1
  191. package/dist/templates/workspace-common/files/prettier-config.js.map +1 -1
  192. package/dist/templates/workspace-common/files/readme-file.js +0 -1
  193. package/dist/templates/workspace-common/files/readme-file.js.map +1 -1
  194. package/dist/templates/workspace-common/files/ts-config.js.map +1 -1
  195. package/dist/templates/workspace-common/files/types/asset.js.map +1 -1
  196. package/dist/templates/workspace-common/files/types/style.js.map +1 -1
  197. package/dist/templates/workspace-common/files/workspace-config.js +0 -14
  198. package/dist/templates/workspace-common/files/workspace-config.js.map +1 -1
  199. package/dist/templates/workspace-common/generate-files.js +0 -29
  200. package/dist/templates/workspace-common/generate-files.js.map +1 -1
  201. package/dist/templates/workspace-common/index.js +0 -3
  202. package/dist/templates/workspace-common/index.js.map +1 -1
  203. package/dist/webpack/html.js +3 -2
  204. package/dist/webpack/html.js.map +1 -1
  205. package/dist/webpack/index.js +0 -3
  206. package/dist/webpack/index.js.map +1 -1
  207. package/dist/webpack/overlay/formatWebpackMessages.js +26 -37
  208. package/dist/webpack/overlay/formatWebpackMessages.js.map +1 -1
  209. package/dist/webpack/overlay/launchEditorEndpoint.js +2 -2
  210. package/dist/webpack/overlay/launchEditorEndpoint.js.map +1 -1
  211. package/dist/webpack/overlay/refreshOverlayInterop.js +1 -3
  212. package/dist/webpack/overlay/refreshOverlayInterop.js.map +1 -1
  213. package/dist/webpack/overlay/webpackHotDevClient.js +54 -71
  214. package/dist/webpack/overlay/webpackHotDevClient.js.map +1 -1
  215. package/dist/webpack/postcss.config.js +6 -3
  216. package/dist/webpack/postcss.config.js.map +1 -1
  217. package/dist/webpack/webpack.config.base.js +28 -53
  218. package/dist/webpack/webpack.config.base.js.map +1 -1
  219. package/dist/webpack/webpack.config.base.prod.js +10 -14
  220. package/dist/webpack/webpack.config.base.prod.js.map +1 -1
  221. package/dist/webpack/webpack.config.component.dev.js +10 -17
  222. package/dist/webpack/webpack.config.component.dev.js.map +1 -1
  223. package/dist/webpack/webpack.config.component.prod.js +3 -6
  224. package/dist/webpack/webpack.config.component.prod.js.map +1 -1
  225. package/dist/webpack/webpack.config.env.dev.js +5 -5
  226. package/dist/webpack/webpack.config.env.dev.js.map +1 -1
  227. package/dist/webpack/webpack.config.env.template.js +0 -1
  228. package/dist/webpack/webpack.config.env.template.js.map +1 -1
  229. package/{overview-1666312873430.js → overview-1666496165706.js} +0 -0
  230. package/package-tar/teambit-react-0.0.882.tgz +0 -0
  231. package/package.json +30 -30
  232. package/{preview-1666312873430.js → preview-1666496165706.js} +2 -2
  233. package/artifacts/env-template/public/peers.d8a0e658db2c8c4cd6c0.js +0 -1
  234. package/artifacts/env-template/public/static/css/770.a0238c25.css +0 -1
  235. package/artifacts/env-template/public/static/css/compositions.6d8c7702.css +0 -1
  236. package/package-tar/teambit-react-0.0.880.tgz +0 -0
package/dist/react.env.js CHANGED
@@ -1,195 +1,141 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  require("core-js/modules/es.array.iterator.js");
6
-
7
5
  require("core-js/modules/es.promise.js");
8
-
9
6
  require("core-js/modules/es.regexp.exec.js");
10
-
11
7
  require("core-js/modules/es.string.replace.js");
12
-
13
8
  Object.defineProperty(exports, "__esModule", {
14
9
  value: true
15
10
  });
16
11
  exports.ReactEnvType = exports.ReactEnv = void 0;
17
-
18
12
  function _defineProperty2() {
19
13
  const data = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
20
-
21
14
  _defineProperty2 = function () {
22
15
  return data;
23
16
  };
24
-
25
17
  return data;
26
18
  }
27
-
28
19
  function _typescript() {
29
20
  const data = _interopRequireDefault(require("typescript"));
30
-
31
21
  _typescript = function () {
32
22
  return data;
33
23
  };
34
-
35
24
  return data;
36
25
  }
37
-
38
26
  function _os() {
39
27
  const data = require("os");
40
-
41
28
  _os = function () {
42
29
  return data;
43
30
  };
44
-
45
31
  return data;
46
32
  }
47
-
48
33
  function _componentModules() {
49
34
  const data = require("@teambit/component.modules.component-url");
50
-
51
35
  _componentModules = function () {
52
36
  return data;
53
37
  };
54
-
55
38
  return data;
56
39
  }
57
-
58
40
  function _builder() {
59
41
  const data = require("@teambit/builder");
60
-
61
42
  _builder = function () {
62
43
  return data;
63
44
  };
64
-
65
45
  return data;
66
46
  }
67
-
68
47
  function _lodash() {
69
48
  const data = require("lodash");
70
-
71
49
  _lodash = function () {
72
50
  return data;
73
51
  };
74
-
75
52
  return data;
76
53
  }
77
-
78
54
  function _utils() {
79
55
  const data = require("@teambit/legacy/dist/utils");
80
-
81
56
  _utils = function () {
82
57
  return data;
83
58
  };
84
-
85
59
  return data;
86
60
  }
87
-
88
61
  function _path() {
89
62
  const data = require("path");
90
-
91
63
  _path = function () {
92
64
  return data;
93
65
  };
94
-
95
66
  return data;
96
67
  }
97
-
98
68
  function _fsExtra() {
99
69
  const data = require("fs-extra");
100
-
101
70
  _fsExtra = function () {
102
71
  return data;
103
72
  };
104
-
105
73
  return data;
106
74
  }
107
-
108
75
  function _react() {
109
76
  const data = require("./react.aspect");
110
-
111
77
  _react = function () {
112
78
  return data;
113
79
  };
114
-
115
80
  return data;
116
81
  }
117
-
118
82
  function _webpackConfig() {
119
83
  const data = _interopRequireDefault(require("./webpack/webpack.config.base"));
120
-
121
84
  _webpackConfig = function () {
122
85
  return data;
123
86
  };
124
-
125
87
  return data;
126
88
  }
127
-
128
89
  function _webpackConfigBase() {
129
90
  const data = _interopRequireDefault(require("./webpack/webpack.config.base.prod"));
130
-
131
91
  _webpackConfigBase = function () {
132
92
  return data;
133
93
  };
134
-
135
94
  return data;
136
95
  }
137
-
138
96
  function _webpackConfigEnv() {
139
97
  const data = _interopRequireDefault(require("./webpack/webpack.config.env.dev"));
140
-
141
98
  _webpackConfigEnv = function () {
142
99
  return data;
143
100
  };
144
-
145
101
  return data;
146
102
  }
147
-
148
103
  function _webpackConfigEnv2() {
149
104
  const data = require("./webpack/webpack.config.env.template");
150
-
151
105
  _webpackConfigEnv2 = function () {
152
106
  return data;
153
107
  };
154
-
155
108
  return data;
156
109
  }
157
-
158
110
  function _webpackConfigComponent() {
159
111
  const data = _interopRequireDefault(require("./webpack/webpack.config.component.prod"));
160
-
161
112
  _webpackConfigComponent = function () {
162
113
  return data;
163
114
  };
164
-
165
115
  return data;
166
116
  }
167
-
168
117
  function _webpackConfigComponent2() {
169
118
  const data = _interopRequireDefault(require("./webpack/webpack.config.component.dev"));
170
-
171
119
  _webpackConfigComponent2 = function () {
172
120
  return data;
173
121
  };
174
-
175
122
  return data;
176
123
  }
177
-
178
124
  // webpack configs for both components and envs
125
+
179
126
  // webpack configs for envs only
180
127
  // import devPreviewConfigFactory from './webpack/webpack.config.preview.dev';
128
+
181
129
  // webpack configs for components only
130
+
182
131
  const ReactEnvType = 'react';
183
132
  exports.ReactEnvType = ReactEnvType;
184
-
185
133
  const defaultTsConfig = require('./typescript/tsconfig.json');
186
-
187
134
  const buildTsConfig = require('./typescript/tsconfig.build.json');
188
-
189
135
  const eslintConfig = require('./eslint/eslintrc');
136
+ const prettierConfig = require('./prettier/prettier.config.js');
190
137
 
191
- const prettierConfig = require('./prettier/prettier.config.js'); // TODO: move to be taken from the key mode of compiler context
192
-
138
+ // TODO: move to be taken from the key mode of compiler context
193
139
 
194
140
  /**
195
141
  * a component environment built for [React](https://reactjs.org) .
@@ -239,68 +185,60 @@ class ReactEnv {
239
185
  this.compilerAspectId = compilerAspectId;
240
186
  (0, _defineProperty2().default)(this, "icon", 'https://static.bit.dev/extensions-icons/react.svg');
241
187
  }
242
-
243
188
  getTsConfig(targetTsConfig) {
244
189
  return targetTsConfig ? (0, _lodash().merge)({}, defaultTsConfig, targetTsConfig) : defaultTsConfig;
245
190
  }
246
-
247
191
  getBuildTsConfig(targetTsConfig) {
248
192
  return targetTsConfig ? (0, _lodash().merge)({}, buildTsConfig, targetTsConfig) : buildTsConfig;
249
193
  }
194
+
250
195
  /**
251
196
  * @deprecated use createCjsJestTester()
252
197
  */
253
-
254
-
255
198
  getCjsJestTester(jestConfigPath, jestModulePath) {
256
199
  return this.createCjsJestTester(jestConfigPath, jestModulePath);
257
200
  }
201
+
258
202
  /**
259
203
  * Get a jest tester instance with react config and cjs configs
260
204
  * @param jestConfigPath
261
205
  * @param jestModulePath
262
206
  * @returns
263
207
  */
264
-
265
-
266
208
  createCjsJestTester(jestConfigPath, jestModulePath) {
267
209
  const pathToSource = (0, _utils().pathNormalizeToLinux)(__dirname).replace('/dist', '');
268
210
  const defaultConfig = (0, _path().join)(pathToSource, './jest/jest.cjs.config.js');
269
211
  const config = jestConfigPath || defaultConfig;
270
212
  return this.jestAspect.createTester(config, jestModulePath || require.resolve('jest'));
271
213
  }
214
+
272
215
  /**
273
216
  * @deprecated use createEsmJestTester()
274
217
  */
275
-
276
-
277
218
  getEsmJestTester(jestConfigPath, jestModulePath) {
278
219
  return this.createEsmJestTester(jestConfigPath, jestModulePath);
279
220
  }
221
+
280
222
  /**
281
223
  * Get a jest tester instance with react config and esm configs
282
224
  * @param jestConfigPath
283
225
  * @param jestModulePath
284
226
  * @returns
285
227
  */
286
-
287
-
288
228
  createEsmJestTester(jestConfigPath, jestModulePath) {
289
229
  const pathToSource = (0, _utils().pathNormalizeToLinux)(__dirname).replace('/dist', '');
290
230
  const defaultConfig = (0, _path().join)(pathToSource, './jest/jest.esm.config.js');
291
231
  const config = jestConfigPath || defaultConfig;
292
232
  return this.jestAspect.createTester(config, jestModulePath || require.resolve('jest'));
293
233
  }
234
+
294
235
  /**
295
236
  * returns a component tester.
296
237
  */
297
-
298
-
299
238
  getTester(jestConfigPath, jestModulePath) {
300
239
  // return this.createEsmJestTester(jestConfigPath, jestModulePath);
301
240
  return this.createCjsJestTester(jestConfigPath, jestModulePath);
302
241
  }
303
-
304
242
  createTsCompilerOptions(mode = 'dev') {
305
243
  const tsconfig = mode === 'dev' ? (0, _lodash().cloneDeep)(defaultTsConfig) : (0, _lodash().cloneDeep)(buildTsConfig);
306
244
  const pathToSource = (0, _utils().pathNormalizeToLinux)(__dirname).replace('/dist/', '/src/');
@@ -314,14 +252,14 @@ class ReactEnv {
314
252
  compileJsx
315
253
  };
316
254
  }
255
+
317
256
  /**
318
257
  * @deprecated use createTsCjsCompiler()
319
258
  */
320
-
321
-
322
259
  getTsCjsCompiler(mode = 'dev', transformers = [], tsModule = _typescript().default) {
323
260
  return this.createTsCjsCompiler(mode, transformers, tsModule);
324
261
  }
262
+
325
263
  /**
326
264
  * Get a compiler instance with react config and set it to cjs module
327
265
  * @param mode
@@ -329,20 +267,18 @@ class ReactEnv {
329
267
  * @param tsModule
330
268
  * @returns
331
269
  */
332
-
333
-
334
270
  createTsCjsCompiler(mode = 'dev', transformers = [], tsModule = _typescript().default) {
335
271
  const tsCompileOptions = this.createTsCompilerOptions(mode);
336
272
  return this.tsAspect.createCjsCompiler(tsCompileOptions, transformers, tsModule);
337
273
  }
274
+
338
275
  /**
339
276
  * @deprecated use createTsEsmCompiler()
340
277
  */
341
-
342
-
343
278
  getTsEsmCompiler(mode = 'dev', transformers = [], tsModule = _typescript().default) {
344
279
  this.createTsEsmCompiler(mode, transformers, tsModule);
345
280
  }
281
+
346
282
  /**
347
283
  * Get a compiler instance with react config and set it to esm module
348
284
  * @param mode
@@ -350,31 +286,25 @@ class ReactEnv {
350
286
  * @param tsModule
351
287
  * @returns
352
288
  */
353
-
354
-
355
289
  createTsEsmCompiler(mode = 'dev', transformers = [], tsModule = _typescript().default) {
356
290
  const tsCompileOptions = this.createTsCompilerOptions(mode);
357
291
  return this.tsAspect.createEsmCompiler(tsCompileOptions, transformers, tsModule);
358
292
  }
359
-
360
293
  getCompiler(transformers = [], tsModule = _typescript().default) {
361
294
  // return this.getTsEsmCompiler('dev', transformers, tsModule);
362
295
  return this.createTsCjsCompiler('dev', transformers, tsModule);
363
296
  }
297
+
364
298
  /**
365
299
  * returns and configures the component linter.
366
300
  */
367
-
368
-
369
301
  getLinter(context, transformers = []) {
370
302
  const tsConfig = this.createTsCompilerOptions('dev').tsconfig;
371
-
372
303
  const defaultTransformer = configMutator => {
373
304
  configMutator.addExtensionTypes(['.md', '.mdx']);
374
305
  configMutator.setTsConfig(tsConfig);
375
306
  return configMutator;
376
307
  };
377
-
378
308
  const allTransformers = [defaultTransformer, ...transformers];
379
309
  return this.eslint.createLinter(context, {
380
310
  config: eslintConfig,
@@ -382,17 +312,15 @@ class ReactEnv {
382
312
  pluginPath: __dirname
383
313
  }, allTransformers);
384
314
  }
315
+
385
316
  /**
386
317
  * returns and configures the component formatter.
387
318
  */
388
-
389
-
390
319
  getFormatter(context, transformers = []) {
391
320
  return this.prettier.createFormatter(context, {
392
321
  config: prettierConfig
393
322
  }, transformers);
394
323
  }
395
-
396
324
  getFileMap(components, local = false) {
397
325
  return components.reduce((index, component) => {
398
326
  component.state.filesystem.files.forEach(file => {
@@ -404,112 +332,93 @@ class ReactEnv {
404
332
  return index;
405
333
  }, {});
406
334
  }
407
-
408
335
  writeFileMap(components, local) {
409
336
  const fileMap = this.getFileMap(components, local);
410
337
  const path = (0, _path().join)((0, _os().tmpdir)(), `${Math.random().toString(36).slice(2, 11)}.json`);
411
338
  (0, _fsExtra().outputFileSync)(path, JSON.stringify(fileMap));
412
339
  return path;
413
340
  }
341
+
414
342
  /**
415
343
  * required for `bit start`
416
344
  */
417
-
418
-
419
345
  getDevEnvId(id) {
420
346
  if (typeof id !== 'string') return _react().ReactAspect.id;
421
347
  return id || _react().ReactAspect.id;
422
348
  }
349
+
423
350
  /**
424
351
  * get a schema generator instance configured with the correct tsconfig.
425
352
  */
426
-
427
-
428
353
  getSchemaExtractor(tsconfig) {
429
354
  return this.tsAspect.createSchemaExtractor(this.getTsConfig(tsconfig));
430
355
  }
356
+
431
357
  /**
432
358
  * returns and configures the React component dev server.
433
359
  * required for `bit start`
434
360
  */
435
-
436
-
437
361
  getDevServer(context, transformers = []) {
438
362
  const baseConfig = (0, _webpackConfig().default)(false);
439
363
  const envDevConfig = (0, _webpackConfigEnv().default)(context.id);
440
364
  const componentDevConfig = (0, _webpackConfigComponent2().default)(this.workspace.path, context.id);
441
-
442
365
  const defaultTransformer = configMutator => {
443
366
  const merged = configMutator.merge([baseConfig, envDevConfig, componentDevConfig]);
444
367
  return merged;
445
368
  };
446
-
447
369
  return this.webpack.createDevServer(context, [defaultTransformer, ...transformers]);
448
370
  }
449
-
450
371
  async getBundler(context, transformers = []) {
451
372
  return this.createComponentsWebpackBundler(context, transformers);
452
373
  }
453
-
454
374
  async createComponentsWebpackBundler(context, transformers = []) {
455
375
  const baseConfig = (0, _webpackConfig().default)(!context.development);
456
376
  const baseProdConfig = (0, _webpackConfigBase().default)(context.development);
457
377
  const componentProdConfig = (0, _webpackConfigComponent().default)();
458
-
459
378
  const defaultTransformer = configMutator => {
460
379
  const merged = configMutator.merge([baseConfig, baseProdConfig, componentProdConfig]);
461
380
  return merged;
462
381
  };
463
-
464
382
  const mergedTransformers = [defaultTransformer, ...transformers];
465
383
  return this.createWebpackBundler(context, mergedTransformers);
466
384
  }
467
-
468
385
  async createTemplateWebpackBundler(context, transformers = []) {
469
386
  const baseConfig = (0, _webpackConfig().default)(!context.development);
470
387
  const baseProdConfig = (0, _webpackConfigBase().default)(context.development);
471
388
  const templateConfig = (0, _webpackConfigEnv2().templateWebpackConfigFactory)();
472
-
473
389
  const defaultTransformer = configMutator => {
474
390
  const merged = configMutator.merge([baseConfig, baseProdConfig, templateConfig]);
475
391
  return merged;
476
392
  };
477
-
478
393
  const mergedTransformers = [defaultTransformer, ...transformers];
479
394
  return this.createWebpackBundler(context, mergedTransformers);
480
395
  }
481
-
482
396
  async createWebpackBundler(context, transformers = []) {
483
397
  return this.webpack.createBundler(context, transformers);
484
398
  }
399
+
485
400
  /**
486
401
  * Get the peers configured by the env on the components + the host deps configured by the env
487
402
  */
488
-
489
-
490
403
  getPeerDependenciesList() {
491
404
  return this.dependencyResolver.getPeerDependenciesListFromEnv(this);
492
405
  }
493
-
494
406
  getAdditionalHostDependencies() {
495
407
  return ['@teambit/mdx.ui.mdx-scope-context', '@mdx-js/react', 'react'];
496
408
  }
409
+
497
410
  /**
498
411
  * returns a path to a docs template.
499
412
  */
500
-
501
-
502
413
  getDocsTemplate() {
503
414
  return require.resolve('@teambit/react.ui.docs-app');
504
415
  }
505
-
506
416
  /**
507
417
  * returns the path to the compositions template
508
418
  */
509
419
  getMounter() {
510
420
  return require.resolve('@teambit/react.ui.compositions-app');
511
421
  }
512
-
513
422
  getPreviewConfig() {
514
423
  return {
515
424
  strategyName: 'component',
@@ -517,62 +426,55 @@ class ReactEnv {
517
426
  isScaling: true
518
427
  };
519
428
  }
429
+
520
430
  /**
521
431
  * define the package json properties to add to each component.
522
432
  */
523
-
524
-
525
433
  getPackageJsonProps() {
526
434
  // React compile by default to esm, so uses type module
527
435
  // return this.getEsmPackageJsonProps();
528
436
  return this.getCjsPackageJsonProps();
529
437
  }
438
+
530
439
  /**
531
440
  * @deprecated use createCjsPackageJsonProps()
532
441
  */
533
-
534
-
535
442
  getCjsPackageJsonProps() {
536
443
  return this.createCjsPackageJsonProps();
537
444
  }
445
+
538
446
  /**
539
447
  * Get the default package.json props for a cjs component
540
448
  * @returns
541
449
  */
542
-
543
-
544
450
  createCjsPackageJsonProps() {
545
451
  return this.tsAspect.getCjsPackageJsonProps();
546
452
  }
453
+
547
454
  /**
548
455
  * @deprecated use createEsmPackageJsonProps()
549
456
  */
550
-
551
-
552
457
  getEsmPackageJsonProps() {
553
458
  return this.createEsmPackageJsonProps();
554
459
  }
460
+
555
461
  /**
556
462
  * Get the default package.json props for an esm component
557
463
  * @returns
558
464
  */
559
-
560
-
561
465
  createEsmPackageJsonProps() {
562
466
  return this.tsAspect.getEsmPackageJsonProps();
563
467
  }
564
-
565
468
  getNpmIgnore() {
566
469
  // ignores only .ts files in the root directory, so d.ts files inside dists are unaffected.
567
470
  // without this change, the package has "index.ts" file in the root, causing typescript to parse it instead of the
568
471
  // d.ts files. (changing the "types" prop in the package.json file doesn't help).
569
472
  return [`${_builder().CAPSULE_ARTIFACTS_DIR}/`];
570
473
  }
474
+
571
475
  /**
572
476
  * adds dependencies to all configured components.
573
477
  */
574
-
575
-
576
478
  getDependencies() {
577
479
  return {
578
480
  dependencies: {
@@ -599,85 +501,74 @@ class ReactEnv {
599
501
  }
600
502
  };
601
503
  }
504
+
602
505
  /**
603
506
  * returns the component build pipeline.
604
507
  */
605
-
606
-
607
508
  getBuildPipe(modifiers = {}) {
608
509
  var _modifiers$tsModifier, _modifiers$tsModifier2;
609
-
610
510
  const transformers = (modifiers === null || modifiers === void 0 ? void 0 : (_modifiers$tsModifier = modifiers.tsModifier) === null || _modifiers$tsModifier === void 0 ? void 0 : _modifiers$tsModifier.transformers) || [];
611
511
  return [this.createCjsCompilerTask(transformers, (modifiers === null || modifiers === void 0 ? void 0 : (_modifiers$tsModifier2 = modifiers.tsModifier) === null || _modifiers$tsModifier2 === void 0 ? void 0 : _modifiers$tsModifier2.module) || _typescript().default), this.tester.task];
612
512
  }
513
+
613
514
  /**
614
515
  * @deprecated use createBuildPipeWithoutCompiler()
615
516
  */
616
-
617
-
618
517
  getBuildPipeWithoutCompiler() {
619
518
  return this.createBuildPipeWithoutCompiler();
620
519
  }
520
+
621
521
  /**
622
522
  * Get the react build pipeline without the compilation task.
623
523
  * This help in cases you want to only replace the compilation task with something else
624
524
  * @returns
625
525
  */
626
-
627
-
628
526
  createBuildPipeWithoutCompiler() {
629
527
  const pipeWithoutCompiler = this.getBuildPipe().filter(task => task.aspectId !== this.compilerAspectId);
630
528
  return pipeWithoutCompiler;
631
529
  }
530
+
632
531
  /**
633
532
  * @deprecated use createEsmCompilerTask()
634
533
  */
635
-
636
-
637
534
  getEsmCompilerTask(transformers = [], tsModule = _typescript().default) {
638
535
  return this.createEsmCompilerTask(transformers, tsModule);
639
536
  }
537
+
640
538
  /**
641
539
  * Get a compiler task with react config and set to esm module
642
540
  * @param transformers
643
541
  * @param tsModule
644
542
  * @returns
645
543
  */
646
-
647
-
648
544
  createEsmCompilerTask(transformers = [], tsModule = _typescript().default) {
649
545
  const tsCompiler = this.createTsEsmCompiler('build', transformers, tsModule);
650
546
  return this.compiler.createTask('TSCompiler', tsCompiler);
651
547
  }
548
+
652
549
  /**
653
550
  * @deprecated use createCjsCompilerTask()
654
551
  * */
655
-
656
-
657
552
  getCjsCompilerTask(transformers = [], tsModule = _typescript().default) {
658
553
  return this.createCjsCompilerTask(transformers, tsModule);
659
554
  }
555
+
660
556
  /**
661
557
  * Get a compiler task with react config and set to cjs module
662
558
  * @param transformers
663
559
  * @param tsModule
664
560
  * @returns
665
561
  */
666
-
667
-
668
562
  createCjsCompilerTask(transformers = [], tsModule = _typescript().default) {
669
563
  const tsCompiler = this.createTsCjsCompiler('build', transformers, tsModule);
670
564
  return this.compiler.createTask('TSCompiler', tsCompiler);
671
565
  }
672
-
673
566
  async __getDescriptor() {
674
567
  return {
675
568
  type: ReactEnvType
676
569
  };
677
570
  }
678
-
679
571
  }
680
-
681
572
  exports.ReactEnv = ReactEnv;
682
573
 
683
574
  //# sourceMappingURL=react.env.js.map