@teambit/react 0.0.623 → 0.0.630

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 (90) hide show
  1. package/__compositions-1643028743431.js +7 -0
  2. package/__overview-1643028743431.js +7 -0
  3. package/__preview-1643028743431.js +2 -0
  4. package/apps/web/deploy-context.ts +4 -0
  5. package/apps/web/index.ts +3 -0
  6. package/apps/web/react-app-options.ts +3 -3
  7. package/apps/web/react-build-result.ts +9 -0
  8. package/apps/web/react.application.ts +32 -34
  9. package/artifacts/env-template/public/141.js +1 -0
  10. package/artifacts/env-template/public/181.js +1 -0
  11. package/artifacts/env-template/public/283.js +1 -0
  12. package/artifacts/env-template/public/664.js +128 -0
  13. package/artifacts/env-template/public/743.js +1 -0
  14. package/artifacts/env-template/public/848.js +1 -0
  15. package/artifacts/env-template/public/assets-manifest.json +74 -0
  16. package/artifacts/env-template/public/compositions.266a1b82df14e17f5a23.js +1 -0
  17. package/artifacts/env-template/public/compositions.html +2 -0
  18. package/artifacts/env-template/public/overview.0f89eba4ac5ae70e0dc7.js +1 -0
  19. package/artifacts/env-template/public/overview.html +2 -0
  20. package/artifacts/env-template/public/peers.23d97726152f744ec115.js +1 -0
  21. package/artifacts/env-template/public/preview-root.b33a2fef3cb8fc3d6479.js +1 -0
  22. package/artifacts/env-template/public/runtime.js +1 -0
  23. package/artifacts/env-template/public/service-worker.js +1 -0
  24. package/artifacts/env-template/public/static/css/664.0a9dfff4.css +1 -0
  25. package/artifacts/env-template/public/static/css/compositions.cd8be53f.css +1 -0
  26. package/artifacts/env-template/public/static/css/overview.71e25e30.css +1 -0
  27. package/artifacts/env-template/public/static/css/previewRoot.5ad41161.css +1 -0
  28. package/artifacts/env-template/public/workbox-ca45de73.js +1 -0
  29. package/artifacts/preview/teambit_react_react-preview.js +1 -0
  30. package/dist/apps/web/deploy-context.d.ts +3 -0
  31. package/dist/apps/web/deploy-context.js +3 -0
  32. package/dist/apps/web/deploy-context.js.map +1 -0
  33. package/dist/apps/web/index.d.ts +3 -0
  34. package/dist/apps/web/index.js +23 -0
  35. package/dist/apps/web/index.js.map +1 -0
  36. package/dist/apps/web/react-app-options.d.ts +2 -3
  37. package/dist/apps/web/react-app-options.js +0 -10
  38. package/dist/apps/web/react-app-options.js.map +1 -1
  39. package/dist/apps/web/react-build-result.d.ts +8 -0
  40. package/dist/apps/web/react-build-result.js +3 -0
  41. package/dist/apps/web/react-build-result.js.map +1 -0
  42. package/dist/apps/web/react.application.d.ts +7 -7
  43. package/dist/apps/web/react.application.js +41 -29
  44. package/dist/apps/web/react.application.js.map +1 -1
  45. package/dist/index.d.ts +1 -1
  46. package/dist/index.js.map +1 -1
  47. package/dist/react.env.d.ts +10 -1
  48. package/dist/react.env.js +60 -8
  49. package/dist/react.env.js.map +1 -1
  50. package/dist/react.main.runtime.js +11 -11
  51. package/dist/react.main.runtime.js.map +1 -1
  52. package/dist/templates/react-app/files/app-root.js +7 -1
  53. package/dist/templates/react-app/files/app-root.js.map +1 -1
  54. package/dist/templates/react-app/files/compositions.js +1 -1
  55. package/dist/templates/react-app/files/compositions.js.map +1 -1
  56. package/dist/templates/workspace-common/files/workspace-config.js +1 -1
  57. package/dist/templates/workspace-common/files/workspace-config.js.map +1 -1
  58. package/dist/webpack/get-exposed-rules.d.ts +2 -0
  59. package/dist/webpack/get-exposed-rules.js +50 -0
  60. package/dist/webpack/get-exposed-rules.js.map +1 -0
  61. package/dist/webpack/get-externals.d.ts +1 -0
  62. package/dist/webpack/get-externals.js +42 -0
  63. package/dist/webpack/get-externals.js.map +1 -0
  64. package/dist/webpack/html.d.ts +2 -0
  65. package/dist/webpack/html.js +31 -0
  66. package/dist/webpack/html.js.map +1 -0
  67. package/dist/webpack/index.d.ts +1 -0
  68. package/dist/webpack/index.js +23 -0
  69. package/dist/webpack/index.js.map +1 -0
  70. package/dist/webpack/transformers.d.ts +2 -0
  71. package/dist/webpack/transformers.js +19 -0
  72. package/dist/webpack/transformers.js.map +1 -0
  73. package/dist/webpack/webpack.config.base.js +3 -5
  74. package/dist/webpack/webpack.config.base.js.map +1 -1
  75. package/dist/webpack/webpack.config.base.prod.d.ts +1 -1
  76. package/dist/webpack/webpack.config.base.prod.js +101 -80
  77. package/dist/webpack/webpack.config.base.prod.js.map +1 -1
  78. package/package-tar/teambit-react-0.0.630.tgz +0 -0
  79. package/package.json +38 -36
  80. package/templates/react-app/files/app-root.ts +7 -1
  81. package/templates/react-app/files/compositions.ts +1 -1
  82. package/templates/workspace-common/files/workspace-config.ts +1 -1
  83. package/webpack/get-exposed-rules.ts +12 -0
  84. package/webpack/get-externals.ts +8 -0
  85. package/webpack/html.ts +22 -0
  86. package/webpack/index.ts +1 -0
  87. package/webpack/transformers.ts +12 -0
  88. package/webpack/webpack.config.base.prod.ts +99 -81
  89. package/webpack/webpack.config.base.ts +3 -5
  90. package/package-tar/teambit-react-0.0.623.tgz +0 -0
@@ -2,78 +2,96 @@ import WorkboxWebpackPlugin from 'workbox-webpack-plugin';
2
2
  import CssMinimizerPlugin from 'css-minimizer-webpack-plugin';
3
3
  import TerserPlugin from 'terser-webpack-plugin';
4
4
  import { Configuration } from 'webpack';
5
- import { WebpackManifestPlugin } from 'webpack-manifest-plugin';
5
+ import { getExternals } from './get-externals';
6
+ import { getExposedRules } from './get-exposed-rules';
7
+ // import { WebpackManifestPlugin } from 'webpack-manifest-plugin';
6
8
 
7
9
  // This is the production and development configuration.
8
10
  // It is focused on developer experience, fast rebuilds, and a minimal bundle.
9
11
  // 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,
12
+ export default function (externalizePeer: boolean, peers: string[], dev?: boolean): Configuration {
13
+ const externals = externalizePeer ? (getExternals(peers) as any) : undefined;
14
+ const exposedRules = externalizePeer ? undefined : getExposedRules(peers);
15
+
16
+ const module = externalizePeer
17
+ ? undefined
18
+ : {
19
+ rules: exposedRules,
20
+ };
21
+
22
+ const optimization = dev
23
+ ? undefined
24
+ : {
25
+ minimize: true,
26
+ minimizer: [
27
+ // This is only used in production mode
28
+ new TerserPlugin({
29
+ extractComments: false,
30
+ terserOptions: {
31
+ parse: {
32
+ // We want terser to parse ecma 8 code. However, we don't want it
33
+ // to apply any minification steps that turns valid ecma 5 code
34
+ // into invalid ecma 5 code. This is why the 'compress' and 'output'
35
+ // sections only apply transformations that are ecma 5 safe
36
+ // https://github.com/facebook/create-react-app/pull/4234
37
+ ecma: 8,
38
+ },
39
+ compress: {
40
+ ecma: 5,
41
+ warnings: false,
42
+ // Disabled because of an issue with Uglify breaking seemingly valid code:
43
+ // https://github.com/facebook/create-react-app/issues/2376
44
+ // Pending further investigation:
45
+ // https://github.com/mishoo/UglifyJS2/issues/2011
46
+ comparisons: false,
47
+ // Disabled because of an issue with Terser breaking valid code:
48
+ // https://github.com/facebook/create-react-app/issues/5250
49
+ // Pending further investigation:
50
+ // https://github.com/terser-js/terser/issues/120
51
+ inline: 2,
52
+ },
53
+ mangle: {
54
+ safari10: true,
55
+ },
56
+ output: {
57
+ ecma: 5,
58
+ comments: false,
59
+ // Turned on because emoji and regex is not minified properly using default
60
+ // https://github.com/facebook/create-react-app/issues/2488
61
+ ascii_only: true,
62
+ },
42
63
  },
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,
64
+ }),
65
+ new CssMinimizerPlugin({
66
+ minimizerOptions: {
67
+ preset: [
68
+ 'default',
69
+ {
70
+ minifyFontValues: { removeQuotes: false },
71
+ },
72
+ ],
49
73
  },
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',
74
+ }),
75
+ ],
76
+ // Automatically split vendor and commons
77
+ // https://twitter.com/wSokra/status/969633336732905474
78
+ // https://medium.com/webpack/webpack-4-code-splitting-chunk-graph-and-the-splitchunks-optimization-be739a861366
79
+ // splitChunks: {
80
+ // chunks: 'all',
68
81
  // 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
- },
82
+ // },
83
+ // Keep the runtime chunk separated to enable long term caching
84
+ // https://twitter.com/wSokra/status/969679223278505985
85
+ // https://github.com/facebook/create-react-app/issues/5358
86
+ // runtimeChunk: {
87
+ // name: (entrypoint) => `runtime-${entrypoint.name}`,
88
+ // },
89
+ };
90
+
91
+ return {
92
+ module,
93
+ externals,
94
+ optimization,
77
95
 
78
96
  plugins: [
79
97
  // Generate an asset manifest file with the following content:
@@ -81,23 +99,23 @@ export default function (): Configuration {
81
99
  // output file so that tools can pick it up without having to parse
82
100
  // `index.html`
83
101
  // 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'));
102
+ // new WebpackManifestPlugin({
103
+ // fileName: 'asset-manifest.json',
104
+ // publicPath: 'public',
105
+ // generate: (seed, files, entrypoints) => {
106
+ // const manifestFiles = files.reduce((manifest, file) => {
107
+ // manifest[file.name] = file.path;
108
+ // return manifest;
109
+ // }, seed);
110
+ // const entrypointFiles = entrypoints.main.filter((fileName) => !fileName.endsWith('.map'));
93
111
 
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
- }),
112
+ // // @ts-ignore - https://github.com/shellscape/webpack-manifest-plugin/issues/276
113
+ // return {
114
+ // files: manifestFiles,
115
+ // entrypoints: entrypointFiles,
116
+ // } as Record<string, string>;
117
+ // },
118
+ // }),
101
119
  // Generate a service worker script that will precache, and keep up to date,
102
120
  // the HTML & assets that are part of the webpack build.
103
121
  new WorkboxWebpackPlugin.GenerateSW({
@@ -57,6 +57,8 @@ export default function (isEnvProduction = false): Configuration {
57
57
  // const env = getClientEnvironment(publicUrlOrPath.slice(0, -1));
58
58
 
59
59
  return {
60
+ // TODO: make the dev tool according to shouldUseSourceMap and isEnvProduction
61
+ // devtool: 'inline-source-map',
60
62
  resolve: {
61
63
  // These are the reasonable defaults supported by the Node ecosystem.
62
64
  // We also include JSX as a common component filename extension to support
@@ -72,12 +74,8 @@ export default function (isEnvProduction = false): Configuration {
72
74
  // Support React Native Web
73
75
  // https://www.smashingmagazine.com/2016/08/a-glimpse-into-the-future-with-react-native-for-web/
74
76
  // 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
77
 
78
+ 'react-dom/server': require.resolve('react-dom/server'),
81
79
  // Allows for better profiling with ReactDevTools
82
80
  ...(isEnvProductionProfile && {
83
81
  'react-dom$': 'react-dom/profiling',