@teambit/react 0.0.565 → 0.0.569

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 (75) hide show
  1. package/compositions-app.tsx +31 -0
  2. package/dist/react.env.d.ts +0 -2
  3. package/dist/react.env.js +1 -38
  4. package/dist/react.env.js.map +1 -1
  5. package/dist/webpack/webpack.config.component.dev.d.ts +1 -1
  6. package/dist/webpack/webpack.config.component.dev.js +9 -13
  7. package/dist/webpack/webpack.config.component.dev.js.map +1 -1
  8. package/highlighter-widget.tsx +19 -0
  9. package/mount.tsx +17 -0
  10. package/package-tar/teambit-react-0.0.569.tgz +0 -0
  11. package/package.json +46 -61
  12. package/react.composition.tsx +7 -0
  13. package/react.ui.runtime.tsx +35 -0
  14. package/templates/react-app/files/app-root.ts +10 -0
  15. package/templates/react-app/files/app.ts +30 -0
  16. package/templates/react-app/files/aspect.ts +10 -0
  17. package/templates/react-app/files/compositions.ts +11 -0
  18. package/templates/react-app/files/doc.ts +29 -0
  19. package/templates/react-app/files/index.ts +10 -0
  20. package/templates/react-app/files/main.runtime.ts +22 -0
  21. package/templates/react-app/index.ts +47 -0
  22. package/templates/react-component/files/component.ts +25 -0
  23. package/templates/react-component/files/composition.ts +16 -0
  24. package/templates/react-component/files/docs.ts +32 -0
  25. package/templates/react-component/files/test.ts +19 -0
  26. package/templates/react-component/index.ts +40 -0
  27. package/templates/react-component-js/files/component.ts +18 -0
  28. package/templates/react-component-js/files/composition.ts +16 -0
  29. package/templates/react-component-js/files/docs.ts +32 -0
  30. package/templates/react-component-js/files/test.ts +21 -0
  31. package/templates/react-component-js/index.ts +38 -0
  32. package/templates/react-context/files/composition.ts +27 -0
  33. package/templates/react-context/files/context-provider.ts +27 -0
  34. package/templates/react-context/files/context.ts +21 -0
  35. package/templates/react-context/files/docs.ts +51 -0
  36. package/templates/react-context/files/test.ts +18 -0
  37. package/templates/react-context/index.ts +32 -0
  38. package/templates/react-env/files/aspect.ts +10 -0
  39. package/templates/react-env/files/doc.ts +163 -0
  40. package/templates/react-env/files/index.ts +10 -0
  41. package/templates/react-env/files/jest.config.ts +21 -0
  42. package/templates/react-env/files/main.runtime.ts +84 -0
  43. package/templates/react-env/files/preview.runtime.ts +27 -0
  44. package/templates/react-env/files/typescript.config.ts +21 -0
  45. package/templates/react-env/files/webpack.config.ts +48 -0
  46. package/templates/react-env/index.ts +51 -0
  47. package/templates/react-hook/files/component.ts +16 -0
  48. package/templates/react-hook/files/composition.ts +23 -0
  49. package/templates/react-hook/files/docs.ts +33 -0
  50. package/templates/react-hook/files/test.ts +20 -0
  51. package/templates/react-hook/index.ts +21 -0
  52. package/templates/react-workspace/index.ts +27 -0
  53. package/templates/react-workspace-app/index.ts +20 -0
  54. package/templates/react-workspace-deprecated/index.ts +28 -0
  55. package/templates/react-workspace-lib/index.ts +21 -0
  56. package/templates/workspace-common/files/eslint-config.ts +6 -0
  57. package/templates/workspace-common/files/git-ignore.ts +113 -0
  58. package/templates/workspace-common/files/prettier-config.ts +5 -0
  59. package/templates/workspace-common/files/readme-file.ts +36 -0
  60. package/templates/workspace-common/files/ts-config.ts +7 -0
  61. package/templates/workspace-common/files/types/asset.ts +28 -0
  62. package/templates/workspace-common/files/types/style.ts +43 -0
  63. package/templates/workspace-common/files/workspace-config.ts +58 -0
  64. package/templates/workspace-common/generate-files.ts +51 -0
  65. package/templates/workspace-common/index.ts +1 -0
  66. package/types/asset.d.ts +29 -0
  67. package/types/style.d.ts +42 -0
  68. package/typescript/asset.d.ts +29 -0
  69. package/typescript/style.d.ts +42 -0
  70. package/webpack/postcss.config.ts +21 -0
  71. package/webpack/webpack.config.base.prod.ts +123 -0
  72. package/webpack/webpack.config.base.ts +365 -0
  73. package/webpack/webpack.config.component.dev.ts +99 -0
  74. package/webpack/webpack.config.component.prod.ts +39 -0
  75. package/webpack/webpack.config.env.dev.ts +21 -0
@@ -0,0 +1,365 @@
1
+ import { merge } from 'lodash';
2
+ import 'style-loader';
3
+ import MiniCssExtractPlugin from 'mini-css-extract-plugin';
4
+ import getCSSModuleLocalIdent from 'react-dev-utils/getCSSModuleLocalIdent';
5
+ import { Configuration, IgnorePlugin } from 'webpack';
6
+ import * as stylesRegexps from '@teambit/webpack.modules.style-regexps';
7
+ import { generateStyleLoaders } from '@teambit/webpack.modules.generate-style-loaders';
8
+ import { postCssConfig } from './postcss.config';
9
+ // Make sure the bit-react-transformer is a dependency
10
+ // TODO: remove it once we can set policy from component to component then set it via the component.json
11
+ import '@teambit/react.babel.bit-react-transformer';
12
+ // Make sure the mdx-loader is a dependency
13
+ import '@teambit/mdx.modules.mdx-loader';
14
+
15
+ const styleLoaderPath = require.resolve('style-loader');
16
+
17
+ const moduleFileExtensions = [
18
+ 'web.mjs',
19
+ 'mjs',
20
+ 'web.js',
21
+ 'js',
22
+ 'web.ts',
23
+ 'ts',
24
+ 'web.tsx',
25
+ 'tsx',
26
+ 'json',
27
+ 'web.jsx',
28
+ 'jsx',
29
+ 'mdx',
30
+ 'md',
31
+ ];
32
+
33
+ // Source maps are resource heavy and can cause out of memory issue for large source files.
34
+ const shouldUseSourceMap = process.env.GENERATE_SOURCEMAP !== 'false';
35
+
36
+ const imageInlineSizeLimit = parseInt(process.env.IMAGE_INLINE_SIZE_LIMIT || '10000');
37
+
38
+ // This is the production and development configuration.
39
+ // It is focused on developer experience, fast rebuilds, and a minimal bundle.
40
+ // eslint-disable-next-line complexity
41
+ export default function (isEnvProduction = false): Configuration {
42
+ // Variable used for enabling profiling in Production
43
+ // passed into alias object. Uses a flag if passed into the build command
44
+ const isEnvProductionProfile = process.argv.includes('--profile');
45
+
46
+ const baseStyleLoadersOptions = {
47
+ injectingLoader: isEnvProduction ? MiniCssExtractPlugin.loader : styleLoaderPath,
48
+ cssLoaderPath: require.resolve('css-loader'),
49
+ postCssLoaderPath: require.resolve('postcss-loader'),
50
+ postCssConfig,
51
+ };
52
+
53
+ // We will provide `paths.publicUrlOrPath` to our app
54
+ // as %PUBLIC_URL% in `index.html` and `process.env.PUBLIC_URL` in JavaScript.
55
+ // Omit trailing slash as %PUBLIC_URL%/xyz looks better than %PUBLIC_URL%xyz.
56
+ // Get environment variables to inject into our app.
57
+ // const env = getClientEnvironment(publicUrlOrPath.slice(0, -1));
58
+
59
+ return {
60
+ resolve: {
61
+ // These are the reasonable defaults supported by the Node ecosystem.
62
+ // We also include JSX as a common component filename extension to support
63
+ // some tools, although we do not recommend using it, see:
64
+ // https://github.com/facebook/create-react-app/issues/290
65
+ // `web` extension prefixes have been added for better support
66
+ // for React Native Web.
67
+ extensions: moduleFileExtensions.map((ext) => `.${ext}`),
68
+
69
+ alias: {
70
+ 'react/jsx-dev-runtime': require.resolve('react/jsx-dev-runtime.js'),
71
+ 'react/jsx-runtime': require.resolve('react/jsx-runtime.js'),
72
+ // Support React Native Web
73
+ // https://www.smashingmagazine.com/2016/08/a-glimpse-into-the-future-with-react-native-for-web/
74
+ // TODO: @uri please remember to remove after publishing evangelist and base-ui
75
+ react: require.resolve('react'),
76
+ '@teambit/mdx.ui.mdx-scope-context': require.resolve('@teambit/mdx.ui.mdx-scope-context'),
77
+ 'react-dom/server': require.resolve('react-dom/server'),
78
+ 'react-dom': require.resolve('react-dom'),
79
+ '@mdx-js/react': require.resolve('@mdx-js/react'),
80
+
81
+ // Allows for better profiling with ReactDevTools
82
+ ...(isEnvProductionProfile && {
83
+ 'react-dom$': 'react-dom/profiling',
84
+ 'scheduler/tracing': 'scheduler/tracing-profiling',
85
+ }),
86
+ },
87
+ },
88
+ module: {
89
+ strictExportPresence: true,
90
+ rules: [
91
+ {
92
+ test: /\.m?js/,
93
+ resolve: {
94
+ fullySpecified: false,
95
+ },
96
+ },
97
+ {
98
+ // "oneOf" will traverse all following loaders until one will
99
+ // match the requirements. When no loader matches it will fall
100
+ // back to the "file" loader at the end of the loader list.
101
+ oneOf: [
102
+ // "postcss" loader applies autoprefixer to our CSS.
103
+ // "css" loader resolves paths in CSS and adds assets as dependencies.
104
+ // "style" loader turns CSS into JS modules that inject <style> tags.
105
+ // In production, we use MiniCSSExtractPlugin to extract that CSS
106
+ // to a file, but in development "style" loader enables hot editing
107
+ // of CSS.
108
+ // By default we support CSS Modules with the extension .module.css
109
+ {
110
+ test: stylesRegexps.cssNoModulesRegex,
111
+ use: generateStyleLoaders(
112
+ merge({}, baseStyleLoadersOptions, {
113
+ cssLoaderOpts: {
114
+ importLoaders: 1,
115
+ sourceMap: isEnvProduction || shouldUseSourceMap,
116
+ },
117
+ })
118
+ ),
119
+ // Don't consider CSS imports dead code even if the
120
+ // containing package claims to have no side effects.
121
+ // Remove this when webpack adds a warning or an error for this.
122
+ // See https://github.com/webpack/webpack/issues/6571
123
+ sideEffects: true,
124
+ },
125
+
126
+ // Process application JS with Babel.
127
+ // The preset includes JSX, Flow, TypeScript, and some ESnext features.
128
+ {
129
+ test: /\.(js|mjs|jsx|ts|tsx)$/,
130
+ exclude: [/node_modules/, /\/dist\//],
131
+ // consider: limit loader to files only in a capsule that has bitid in package.json
132
+ // descriptionData: { componentId: ComponentID.isValidObject },
133
+ // // or
134
+ // include: capsulePaths
135
+ loader: require.resolve('babel-loader'),
136
+ options: {
137
+ babelrc: false,
138
+ configFile: false,
139
+ customize: require.resolve('babel-preset-react-app/webpack-overrides'),
140
+ presets: [require.resolve('@babel/preset-react')],
141
+ // This is a feature of `babel-loader` for webpack (not Babel itself).
142
+ // It enables caching results in ./node_modules/.cache/babel-loader/
143
+ // directory for faster rebuilds.
144
+ cacheDirectory: true,
145
+ // See #6846 for context on why cacheCompression is disabled
146
+ cacheCompression: false,
147
+ compact: isEnvProduction,
148
+ },
149
+ },
150
+ // Process any JS outside of the app with Babel.
151
+ // Unlike the application JS, we only compile the standard ES features.
152
+ // Probably not needed in our use case
153
+ // {
154
+ // test: /\.(js|mjs)$/,
155
+ // exclude: /@babel(?:\/|\\{1,2})runtime/,
156
+ // loader: require.resolve('babel-loader'),
157
+ // options: {
158
+ // babelrc: false,
159
+ // configFile: false,
160
+ // compact: false,
161
+ // presets: [[require.resolve('babel-preset-react-app/dependencies'), { helpers: true }]],
162
+ // cacheDirectory: true,
163
+ // // See #6846 for context on why cacheCompression is disabled
164
+ // cacheCompression: false,
165
+
166
+ // // Babel sourcemaps are needed for debugging into node_modules
167
+ // // code. Without the options below, debuggers like VSCode
168
+ // // show incorrect code and set breakpoints on the wrong lines.
169
+ // sourceMaps: shouldUseSourceMap,
170
+ // inputSourceMap: shouldUseSourceMap,
171
+ // },
172
+ // },
173
+ // MDX support (move to the mdx aspect and extend from there)
174
+ {
175
+ test: /\.mdx?$/,
176
+ exclude: [/node_modules/],
177
+ use: [
178
+ {
179
+ loader: require.resolve('babel-loader'),
180
+ options: {
181
+ babelrc: false,
182
+ configFile: false,
183
+ presets: [require.resolve('@babel/preset-react'), require.resolve('@babel/preset-env')],
184
+ },
185
+ },
186
+ {
187
+ loader: require.resolve('@teambit/mdx.modules.mdx-loader'),
188
+ },
189
+ ],
190
+ },
191
+ // Adds support for CSS Modules (https://github.com/css-modules/css-modules)
192
+ // using the extension .module.css
193
+ {
194
+ test: stylesRegexps.cssModuleRegex,
195
+ use: generateStyleLoaders(
196
+ merge({}, baseStyleLoadersOptions, {
197
+ cssLoaderOpts: {
198
+ importLoaders: 1,
199
+ sourceMap: isEnvProduction || shouldUseSourceMap,
200
+ modules: {
201
+ getLocalIdent: getCSSModuleLocalIdent,
202
+ },
203
+ },
204
+ shouldUseSourceMap: isEnvProduction || shouldUseSourceMap,
205
+ })
206
+ ),
207
+ },
208
+ // Opt-in support for SASS (using .scss or .sass extensions).
209
+ // By default we support SASS Modules with the
210
+ // extensions .module.scss or .module.sass
211
+ {
212
+ test: stylesRegexps.sassNoModuleRegex,
213
+ use: generateStyleLoaders(
214
+ merge({}, baseStyleLoadersOptions, {
215
+ cssLoaderOpts: {
216
+ importLoaders: 3,
217
+ sourceMap: isEnvProduction || shouldUseSourceMap,
218
+ },
219
+ shouldUseSourceMap: isEnvProduction || shouldUseSourceMap,
220
+ preProcessOptions: {
221
+ resolveUrlLoaderPath: require.resolve('resolve-url-loader'),
222
+ preProcessorPath: require.resolve('sass-loader'),
223
+ },
224
+ })
225
+ ),
226
+ // Don't consider CSS imports dead code even if the
227
+ // containing package claims to have no side effects.
228
+ // Remove this when webpack adds a warning or an error for this.
229
+ // See https://github.com/webpack/webpack/issues/6571
230
+ sideEffects: true,
231
+ },
232
+ // Adds support for CSS Modules, but using SASS
233
+ // using the extension .module.scss or .module.sass
234
+ {
235
+ test: stylesRegexps.sassModuleRegex,
236
+ use: generateStyleLoaders(
237
+ merge({}, baseStyleLoadersOptions, {
238
+ cssLoaderOpts: {
239
+ importLoaders: 3,
240
+ sourceMap: isEnvProduction || shouldUseSourceMap,
241
+ modules: {
242
+ getLocalIdent: getCSSModuleLocalIdent,
243
+ },
244
+ },
245
+ shouldUseSourceMap: isEnvProduction || shouldUseSourceMap,
246
+ preProcessOptions: {
247
+ resolveUrlLoaderPath: require.resolve('resolve-url-loader'),
248
+ preProcessorPath: require.resolve('sass-loader'),
249
+ },
250
+ })
251
+ ),
252
+ },
253
+ {
254
+ test: stylesRegexps.lessNoModuleRegex,
255
+ use: generateStyleLoaders(
256
+ merge({}, baseStyleLoadersOptions, {
257
+ cssLoaderOpts: {
258
+ importLoaders: 1,
259
+ sourceMap: isEnvProduction || shouldUseSourceMap,
260
+ },
261
+ shouldUseSourceMap: isEnvProduction || shouldUseSourceMap,
262
+ preProcessOptions: {
263
+ resolveUrlLoaderPath: require.resolve('resolve-url-loader'),
264
+ preProcessorPath: require.resolve('less-loader'),
265
+ },
266
+ })
267
+ ),
268
+ // Don't consider CSS imports dead code even if the
269
+ // containing package claims to have no side effects.
270
+ // Remove this when webpack adds a warning or an error for this.
271
+ // See https://github.com/webpack/webpack/issues/6571
272
+ sideEffects: true,
273
+ },
274
+ {
275
+ test: stylesRegexps.lessModuleRegex,
276
+ use: generateStyleLoaders(
277
+ merge({}, baseStyleLoadersOptions, {
278
+ cssLoaderOpts: {
279
+ importLoaders: 1,
280
+ sourceMap: isEnvProduction || shouldUseSourceMap,
281
+ modules: {
282
+ getLocalIdent: getCSSModuleLocalIdent,
283
+ },
284
+ },
285
+ shouldUseSourceMap: isEnvProduction || shouldUseSourceMap,
286
+ preProcessOptions: {
287
+ resolveUrlLoaderPath: require.resolve('resolve-url-loader'),
288
+ preProcessorPath: require.resolve('less-loader'),
289
+ },
290
+ })
291
+ ),
292
+ },
293
+ {
294
+ test: [/\.bmp$/, /\.gif$/, /\.jpe?g$/, /\.png$/],
295
+ type: 'asset',
296
+ parser: {
297
+ dataUrlCondition: {
298
+ maxSize: imageInlineSizeLimit,
299
+ },
300
+ },
301
+ },
302
+ {
303
+ // loads svg as both inlineUrl and react component, like:
304
+ // import starUrl, { ReactComponent as StarIcon } from './star.svg';
305
+ // (remove when there is native support for both opitons from webpack5 / svgr)
306
+ test: /\.svg$/,
307
+ oneOf: [
308
+ {
309
+ dependency: { not: ['url'] }, // exclude new URL calls
310
+ use: [
311
+ {
312
+ loader: require.resolve('@svgr/webpack'),
313
+ options: { titleProp: true, ref: true },
314
+ },
315
+ require.resolve('new-url-loader'),
316
+ ],
317
+ },
318
+ {
319
+ type: 'asset', // export a data URI or emit a separate file
320
+ },
321
+ ],
322
+ },
323
+ // "file" loader makes sure those assets get served by WebpackDevServer.
324
+ // When you `import` an asset, you get its (virtual) filename.
325
+ // In production, they would get copied to the `build` folder.
326
+ // This loader doesn't use a "test" so it will catch all modules
327
+ // that fall through the other loaders.
328
+ {
329
+ // Exclude `js` files to keep "css" loader working as it injects
330
+ // its runtime that would otherwise be processed through "file" loader.
331
+ // Also exclude `html` and `json` extensions so they get processed
332
+ // by webpacks internal loaders.
333
+ exclude: [/\.(js|mjs|jsx|ts|tsx)$/, /\.html$/, /\.mdx?/, /\.json$/, /\.css$/],
334
+ type: 'asset',
335
+ },
336
+ // ** STOP ** Are you adding a new loader?
337
+ // Make sure to add the new loader(s) before the "type:asset" loader.
338
+ ],
339
+ },
340
+ ],
341
+ },
342
+ // @ts-ignore
343
+ plugins: [
344
+ isEnvProduction &&
345
+ new MiniCssExtractPlugin({
346
+ // Options similar to the same options in webpackOptions.output
347
+ // both options are optional
348
+ filename: 'static/css/[name].[contenthash:8].css',
349
+ chunkFilename: 'static/css/[name].[contenthash:8].chunk.css',
350
+ }),
351
+ // Moment.js is an extremely popular library that bundles large locale files
352
+ // by default due to how webpack interprets its code. This is a practical
353
+ // solution that requires the user to opt into importing specific locales.
354
+ // https://github.com/jmblog/how-to-optimize-momentjs-with-webpack
355
+ // You can remove this if you don't use Moment.js:
356
+ new IgnorePlugin({
357
+ resourceRegExp: /^\.\/locale$/,
358
+ contextRegExp: /moment$/,
359
+ }),
360
+ ].filter(Boolean),
361
+ // Turn off performance processing because we utilize
362
+ // our own hints via the FileSizeReporter
363
+ performance: false,
364
+ };
365
+ }
@@ -0,0 +1,99 @@
1
+ import path from 'path';
2
+ import { Configuration } from 'webpack';
3
+ import { ComponentID } from '@teambit/component-id';
4
+ // Make sure the bit-react-transformer is a dependency
5
+ // TODO: remove it once we can set policy from component to component then set it via the component.json
6
+ import '@teambit/react.babel.bit-react-transformer';
7
+ import ReactRefreshWebpackPlugin from '@pmmmwh/react-refresh-webpack-plugin';
8
+
9
+ const matchNothingRegex = 'a^';
10
+
11
+ // This is the production and development configuration.
12
+ // It is focused on developer experience, fast rebuilds, and a minimal bundle.
13
+ // eslint-disable-next-line complexity
14
+ // export default function (workDir: string, envId: string): Configuration {
15
+ export default function (workDir: string, envId: string): Configuration {
16
+ return {
17
+ module: {
18
+ rules: [
19
+ {
20
+ test: /\.js$/,
21
+ enforce: 'pre',
22
+ // limit loader to files in the current project,
23
+ // to skip any files linked from other projects (like Bit itself)
24
+ include: path.join(workDir, 'node_modules'),
25
+ // only apply to packages with componentId in their package.json (ie. bit components)
26
+ descriptionData: { componentId: (value) => !!value },
27
+ use: [require.resolve('source-map-loader')],
28
+ },
29
+ {
30
+ test: /\.js$/,
31
+ // limit loader to files in the current project,
32
+ // to skip any files linked from other projects (like Bit itself)
33
+ include: path.join(workDir, 'node_modules'),
34
+ // only apply to packages with componentId in their package.json (ie. bit components)
35
+ descriptionData: { componentId: ComponentID.isValidObject },
36
+ use: [
37
+ require.resolve('@pmmmwh/react-refresh-webpack-plugin/loader'),
38
+ {
39
+ loader: require.resolve('babel-loader'),
40
+ options: {
41
+ babelrc: false,
42
+ configFile: false,
43
+ plugins: [
44
+ require.resolve('react-refresh/babel'),
45
+ // for component highlighting in preview.
46
+ [require.resolve('@teambit/react.babel.bit-react-transformer')],
47
+ ],
48
+ // turn off all optimizations (only slow down for node_modules)
49
+ compact: false,
50
+ minified: false,
51
+ },
52
+ },
53
+ ],
54
+ },
55
+ // MDX support (move to the mdx aspect and extend from there)
56
+ {
57
+ test: /\.mdx?$/,
58
+ // to skip any files linked from other projects (like Bit itself)
59
+ include: path.join(workDir, 'node_modules'),
60
+ // only apply to packages with componentId in their package.json (ie. bit components)
61
+ descriptionData: { componentId: (value) => !!value },
62
+ use: [
63
+ require.resolve('@pmmmwh/react-refresh-webpack-plugin/loader'),
64
+ {
65
+ loader: require.resolve('babel-loader'),
66
+ options: {
67
+ babelrc: false,
68
+ configFile: false,
69
+ presets: [require.resolve('@babel/preset-react'), require.resolve('@babel/preset-env')],
70
+ plugins: [require.resolve('react-refresh/babel')],
71
+ },
72
+ },
73
+ {
74
+ loader: require.resolve('@teambit/mdx.modules.mdx-loader'),
75
+ },
76
+ ],
77
+ },
78
+ ],
79
+ },
80
+ plugins: [
81
+ // No need here as we have `hot: true` in the dev server
82
+ // new webpack.HotModuleReplacementPlugin({}),
83
+ new ReactRefreshWebpackPlugin({
84
+ overlay: {
85
+ sockPath: `_hmr/${envId}`,
86
+ // TODO: check why webpackHotDevClient and react-error-overlay are not responding for runtime
87
+ // errors
88
+ entry: require.resolve('./react-hot-dev-client'),
89
+ module: require.resolve('./refresh'),
90
+ },
91
+
92
+ // we use '@pmmmwh/react-refresh-webpack-plugin/loader' directly where relevant.
93
+ // FYI, original defaults of the plugin are:
94
+ // include: /\.([cm]js|[jt]sx?|flow)$/i, exclude: /node_modules/,
95
+ include: matchNothingRegex,
96
+ }),
97
+ ],
98
+ };
99
+ }
@@ -0,0 +1,39 @@
1
+ import { Configuration } from 'webpack';
2
+ import { ComponentID } from '@teambit/component-id';
3
+ // Make sure the bit-react-transformer is a dependency
4
+ // TODO: remove it once we can set policy from component to component then set it via the component.json
5
+ import '@teambit/react.babel.bit-react-transformer';
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
+ module: {
13
+ rules: [
14
+ {
15
+ test: /\.js$/,
16
+ include: [/node_modules/, /\/dist\//],
17
+ exclude: /@teambit\/legacy/,
18
+ descriptionData: { componentId: ComponentID.isValidObject },
19
+ use: [
20
+ {
21
+ loader: require.resolve('babel-loader'),
22
+ options: {
23
+ babelrc: false,
24
+ configFile: false,
25
+ plugins: [
26
+ // for component highlighting in preview.
27
+ [require.resolve('@teambit/react.babel.bit-react-transformer')],
28
+ ],
29
+ // turn off all optimizations (only slow down for node_modules)
30
+ compact: false,
31
+ minified: false,
32
+ },
33
+ },
34
+ ],
35
+ },
36
+ ],
37
+ },
38
+ };
39
+ }
@@ -0,0 +1,21 @@
1
+ import type { WebpackConfigWithDevServer } from '@teambit/webpack';
2
+
3
+ export default function envConfig(envId: string): WebpackConfigWithDevServer {
4
+ return {
5
+ devServer: {
6
+ webSocketServer: {
7
+ options: {
8
+ path: `/_hmr/${envId}`,
9
+ // port is automatically matchs WDS
10
+ },
11
+ },
12
+ client: {
13
+ // public, sockHost, sockPath, and sockPort options were removed in favor client.webSocketURL option:
14
+ webSocketURL: {
15
+ pathname: `_hmr/${envId}`,
16
+ // port is automatically matchs the website.
17
+ },
18
+ },
19
+ },
20
+ };
21
+ }