@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
@@ -41,103 +41,124 @@ function _terserWebpackPlugin() {
41
41
  return data;
42
42
  }
43
43
 
44
- function _webpackManifestPlugin() {
45
- const data = require("webpack-manifest-plugin");
44
+ function _getExternals() {
45
+ const data = require("./get-externals");
46
46
 
47
- _webpackManifestPlugin = function () {
47
+ _getExternals = function () {
48
48
  return data;
49
49
  };
50
50
 
51
51
  return data;
52
52
  }
53
53
 
54
+ function _getExposedRules() {
55
+ const data = require("./get-exposed-rules");
56
+
57
+ _getExposedRules = function () {
58
+ return data;
59
+ };
60
+
61
+ return data;
62
+ }
63
+
64
+ // import { WebpackManifestPlugin } from 'webpack-manifest-plugin';
54
65
  // This is the production and development configuration.
55
66
  // It is focused on developer experience, fast rebuilds, and a minimal bundle.
56
67
  // eslint-disable-next-line complexity
57
- function _default() {
58
- return {
59
- optimization: {
60
- minimize: true,
61
- minimizer: [// This is only used in production mode
62
- new (_terserWebpackPlugin().default)({
63
- terserOptions: {
64
- parse: {
65
- // We want terser to parse ecma 8 code. However, we don't want it
66
- // to apply any minification steps that turns valid ecma 5 code
67
- // into invalid ecma 5 code. This is why the 'compress' and 'output'
68
- // sections only apply transformations that are ecma 5 safe
69
- // https://github.com/facebook/create-react-app/pull/4234
70
- ecma: 8
71
- },
72
- compress: {
73
- ecma: 5,
74
- warnings: false,
75
- // Disabled because of an issue with Uglify breaking seemingly valid code:
76
- // https://github.com/facebook/create-react-app/issues/2376
77
- // Pending further investigation:
78
- // https://github.com/mishoo/UglifyJS2/issues/2011
79
- comparisons: false,
80
- // Disabled because of an issue with Terser breaking valid code:
81
- // https://github.com/facebook/create-react-app/issues/5250
82
- // Pending further investigation:
83
- // https://github.com/terser-js/terser/issues/120
84
- inline: 2
85
- },
86
- mangle: {
87
- safari10: true
88
- },
89
- output: {
90
- ecma: 5,
91
- comments: false,
92
- // Turned on because emoji and regex is not minified properly using default
93
- // https://github.com/facebook/create-react-app/issues/2488
94
- ascii_only: true
95
- }
96
- }
97
- }), new (_cssMinimizerWebpackPlugin().default)({
98
- minimizerOptions: {
99
- preset: ['default', {
100
- minifyFontValues: {
101
- removeQuotes: false
102
- }
103
- }]
68
+ function _default(externalizePeer, peers, dev) {
69
+ const externals = externalizePeer ? (0, _getExternals().getExternals)(peers) : undefined;
70
+ const exposedRules = externalizePeer ? undefined : (0, _getExposedRules().getExposedRules)(peers);
71
+ const module = externalizePeer ? undefined : {
72
+ rules: exposedRules
73
+ };
74
+ const optimization = dev ? undefined : {
75
+ minimize: true,
76
+ minimizer: [// This is only used in production mode
77
+ new (_terserWebpackPlugin().default)({
78
+ extractComments: false,
79
+ terserOptions: {
80
+ parse: {
81
+ // We want terser to parse ecma 8 code. However, we don't want it
82
+ // to apply any minification steps that turns valid ecma 5 code
83
+ // into invalid ecma 5 code. This is why the 'compress' and 'output'
84
+ // sections only apply transformations that are ecma 5 safe
85
+ // https://github.com/facebook/create-react-app/pull/4234
86
+ ecma: 8
87
+ },
88
+ compress: {
89
+ ecma: 5,
90
+ warnings: false,
91
+ // Disabled because of an issue with Uglify breaking seemingly valid code:
92
+ // https://github.com/facebook/create-react-app/issues/2376
93
+ // Pending further investigation:
94
+ // https://github.com/mishoo/UglifyJS2/issues/2011
95
+ comparisons: false,
96
+ // Disabled because of an issue with Terser breaking valid code:
97
+ // https://github.com/facebook/create-react-app/issues/5250
98
+ // Pending further investigation:
99
+ // https://github.com/terser-js/terser/issues/120
100
+ inline: 2
101
+ },
102
+ mangle: {
103
+ safari10: true
104
+ },
105
+ output: {
106
+ ecma: 5,
107
+ comments: false,
108
+ // Turned on because emoji and regex is not minified properly using default
109
+ // https://github.com/facebook/create-react-app/issues/2488
110
+ ascii_only: true
104
111
  }
105
- })],
106
- // Automatically split vendor and commons
107
- // https://twitter.com/wSokra/status/969633336732905474
108
- // https://medium.com/webpack/webpack-4-code-splitting-chunk-graph-and-the-splitchunks-optimization-be739a861366
109
- splitChunks: {
110
- chunks: 'all' // name: false,
111
-
112
- },
113
- // Keep the runtime chunk separated to enable long term caching
114
- // https://twitter.com/wSokra/status/969679223278505985
115
- // https://github.com/facebook/create-react-app/issues/5358
116
- runtimeChunk: {
117
- name: entrypoint => `runtime-${entrypoint.name}`
118
112
  }
119
- },
113
+ }), new (_cssMinimizerWebpackPlugin().default)({
114
+ minimizerOptions: {
115
+ preset: ['default', {
116
+ minifyFontValues: {
117
+ removeQuotes: false
118
+ }
119
+ }]
120
+ }
121
+ })] // Automatically split vendor and commons
122
+ // https://twitter.com/wSokra/status/969633336732905474
123
+ // https://medium.com/webpack/webpack-4-code-splitting-chunk-graph-and-the-splitchunks-optimization-be739a861366
124
+ // splitChunks: {
125
+ // chunks: 'all',
126
+ // name: false,
127
+ // },
128
+ // Keep the runtime chunk separated to enable long term caching
129
+ // https://twitter.com/wSokra/status/969679223278505985
130
+ // https://github.com/facebook/create-react-app/issues/5358
131
+ // runtimeChunk: {
132
+ // name: (entrypoint) => `runtime-${entrypoint.name}`,
133
+ // },
134
+
135
+ };
136
+ return {
137
+ module,
138
+ externals,
139
+ optimization,
120
140
  plugins: [// Generate an asset manifest file with the following content:
121
141
  // - "files" key: Mapping of all asset filenames to their corresponding
122
142
  // output file so that tools can pick it up without having to parse
123
143
  // `index.html`
124
144
  // can be used to reconstruct the HTML if necessary
125
- new (_webpackManifestPlugin().WebpackManifestPlugin)({
126
- fileName: 'asset-manifest.json',
127
- publicPath: 'public',
128
- generate: (seed, files, entrypoints) => {
129
- const manifestFiles = files.reduce((manifest, file) => {
130
- manifest[file.name] = file.path;
131
- return manifest;
132
- }, seed);
133
- const entrypointFiles = entrypoints.main.filter(fileName => !fileName.endsWith('.map')); // @ts-ignore - https://github.com/shellscape/webpack-manifest-plugin/issues/276
134
-
135
- return {
136
- files: manifestFiles,
137
- entrypoints: entrypointFiles
138
- };
139
- }
140
- }), // Generate a service worker script that will precache, and keep up to date,
145
+ // new WebpackManifestPlugin({
146
+ // fileName: 'asset-manifest.json',
147
+ // publicPath: 'public',
148
+ // generate: (seed, files, entrypoints) => {
149
+ // const manifestFiles = files.reduce((manifest, file) => {
150
+ // manifest[file.name] = file.path;
151
+ // return manifest;
152
+ // }, seed);
153
+ // const entrypointFiles = entrypoints.main.filter((fileName) => !fileName.endsWith('.map'));
154
+ // // @ts-ignore - https://github.com/shellscape/webpack-manifest-plugin/issues/276
155
+ // return {
156
+ // files: manifestFiles,
157
+ // entrypoints: entrypointFiles,
158
+ // } as Record<string, string>;
159
+ // },
160
+ // }),
161
+ // Generate a service worker script that will precache, and keep up to date,
141
162
  // the HTML & assets that are part of the webpack build.
142
163
  new (_workboxWebpackPlugin().default.GenerateSW)({
143
164
  clientsClaim: true,
@@ -1 +1 @@
1
- {"version":3,"sources":["webpack.config.base.prod.ts"],"names":["optimization","minimize","minimizer","TerserPlugin","terserOptions","parse","ecma","compress","warnings","comparisons","inline","mangle","safari10","output","comments","ascii_only","CssMinimizerPlugin","minimizerOptions","preset","minifyFontValues","removeQuotes","splitChunks","chunks","runtimeChunk","name","entrypoint","plugins","WebpackManifestPlugin","fileName","publicPath","generate","seed","files","entrypoints","manifestFiles","reduce","manifest","file","path","entrypointFiles","main","filter","endsWith","WorkboxWebpackPlugin","GenerateSW","clientsClaim","exclude","navigateFallback","navigateFallbackDenylist","RegExp","Boolean","performance"],"mappings":"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","sourcesContent":["import WorkboxWebpackPlugin from 'workbox-webpack-plugin';\nimport CssMinimizerPlugin from 'css-minimizer-webpack-plugin';\nimport TerserPlugin from 'terser-webpack-plugin';\nimport { Configuration } from 'webpack';\nimport { WebpackManifestPlugin } from 'webpack-manifest-plugin';\n\n// This is the production and development configuration.\n// It is focused on developer experience, fast rebuilds, and a minimal bundle.\n// eslint-disable-next-line complexity\nexport default function (): Configuration {\n return {\n optimization: {\n minimize: true,\n minimizer: [\n // This is only used in production mode\n new TerserPlugin({\n terserOptions: {\n parse: {\n // We want terser to parse ecma 8 code. However, we don't want it\n // to apply any minification steps that turns valid ecma 5 code\n // into invalid ecma 5 code. This is why the 'compress' and 'output'\n // sections only apply transformations that are ecma 5 safe\n // https://github.com/facebook/create-react-app/pull/4234\n ecma: 8,\n },\n compress: {\n ecma: 5,\n warnings: false,\n // Disabled because of an issue with Uglify breaking seemingly valid code:\n // https://github.com/facebook/create-react-app/issues/2376\n // Pending further investigation:\n // https://github.com/mishoo/UglifyJS2/issues/2011\n comparisons: false,\n // Disabled because of an issue with Terser breaking valid code:\n // https://github.com/facebook/create-react-app/issues/5250\n // Pending further investigation:\n // https://github.com/terser-js/terser/issues/120\n inline: 2,\n },\n mangle: {\n safari10: true,\n },\n output: {\n ecma: 5,\n comments: false,\n // Turned on because emoji and regex is not minified properly using default\n // https://github.com/facebook/create-react-app/issues/2488\n ascii_only: true,\n },\n },\n }),\n new CssMinimizerPlugin({\n minimizerOptions: {\n preset: [\n 'default',\n {\n minifyFontValues: { removeQuotes: false },\n },\n ],\n },\n }),\n ],\n // Automatically split vendor and commons\n // https://twitter.com/wSokra/status/969633336732905474\n // https://medium.com/webpack/webpack-4-code-splitting-chunk-graph-and-the-splitchunks-optimization-be739a861366\n splitChunks: {\n chunks: 'all',\n // name: false,\n },\n // Keep the runtime chunk separated to enable long term caching\n // https://twitter.com/wSokra/status/969679223278505985\n // https://github.com/facebook/create-react-app/issues/5358\n runtimeChunk: {\n name: (entrypoint) => `runtime-${entrypoint.name}`,\n },\n },\n\n plugins: [\n // Generate an asset manifest file with the following content:\n // - \"files\" key: Mapping of all asset filenames to their corresponding\n // output file so that tools can pick it up without having to parse\n // `index.html`\n // can be used to reconstruct the HTML if necessary\n new WebpackManifestPlugin({\n fileName: 'asset-manifest.json',\n publicPath: 'public',\n generate: (seed, files, entrypoints) => {\n const manifestFiles = files.reduce((manifest, file) => {\n manifest[file.name] = file.path;\n return manifest;\n }, seed);\n const entrypointFiles = entrypoints.main.filter((fileName) => !fileName.endsWith('.map'));\n\n // @ts-ignore - https://github.com/shellscape/webpack-manifest-plugin/issues/276\n return {\n files: manifestFiles,\n entrypoints: entrypointFiles,\n } as Record<string, string>;\n },\n }),\n // Generate a service worker script that will precache, and keep up to date,\n // the HTML & assets that are part of the webpack build.\n new WorkboxWebpackPlugin.GenerateSW({\n clientsClaim: true,\n exclude: [/\\.map$/, /asset-manifest\\.json$/],\n // importWorkboxFrom: 'cdn',\n navigateFallback: 'public/index.html',\n navigateFallbackDenylist: [\n // Exclude URLs starting with /_, as they're likely an API call\n new RegExp('^/_'),\n // Exclude any URLs whose last part seems to be a file extension\n // as they're likely a resource and not a SPA route.\n // URLs containing a \"?\" character won't be blacklisted as they're likely\n // a route with query params (e.g. auth callbacks).\n new RegExp('/[^/?]+\\\\.[^/]+$'),\n ],\n }),\n ].filter(Boolean),\n // Turn off performance processing because we utilize\n // our own hints via the FileSizeReporter\n performance: false,\n };\n}\n"]}
1
+ {"version":3,"sources":["webpack.config.base.prod.ts"],"names":["externalizePeer","peers","dev","externals","undefined","exposedRules","module","rules","optimization","minimize","minimizer","TerserPlugin","extractComments","terserOptions","parse","ecma","compress","warnings","comparisons","inline","mangle","safari10","output","comments","ascii_only","CssMinimizerPlugin","minimizerOptions","preset","minifyFontValues","removeQuotes","plugins","WorkboxWebpackPlugin","GenerateSW","clientsClaim","exclude","navigateFallback","navigateFallbackDenylist","RegExp","filter","Boolean","performance"],"mappings":";;;;;;;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAEA;AACA;AACA;AACe,kBAAUA,eAAV,EAAoCC,KAApC,EAAqDC,GAArD,EAAmF;AAChG,QAAMC,SAAS,GAAGH,eAAe,GAAI,kCAAaC,KAAb,CAAJ,GAAkCG,SAAnE;AACA,QAAMC,YAAY,GAAGL,eAAe,GAAGI,SAAH,GAAe,wCAAgBH,KAAhB,CAAnD;AAEA,QAAMK,MAAM,GAAGN,eAAe,GAC1BI,SAD0B,GAE1B;AACEG,IAAAA,KAAK,EAAEF;AADT,GAFJ;AAMA,QAAMG,YAAY,GAAGN,GAAG,GACpBE,SADoB,GAEpB;AACEK,IAAAA,QAAQ,EAAE,IADZ;AAEEC,IAAAA,SAAS,EAAE,CACT;AACA,SAAIC,8BAAJ,EAAiB;AACfC,MAAAA,eAAe,EAAE,KADF;AAEfC,MAAAA,aAAa,EAAE;AACbC,QAAAA,KAAK,EAAE;AACL;AACA;AACA;AACA;AACA;AACAC,UAAAA,IAAI,EAAE;AAND,SADM;AASbC,QAAAA,QAAQ,EAAE;AACRD,UAAAA,IAAI,EAAE,CADE;AAERE,UAAAA,QAAQ,EAAE,KAFF;AAGR;AACA;AACA;AACA;AACAC,UAAAA,WAAW,EAAE,KAPL;AAQR;AACA;AACA;AACA;AACAC,UAAAA,MAAM,EAAE;AAZA,SATG;AAuBbC,QAAAA,MAAM,EAAE;AACNC,UAAAA,QAAQ,EAAE;AADJ,SAvBK;AA0BbC,QAAAA,MAAM,EAAE;AACNP,UAAAA,IAAI,EAAE,CADA;AAENQ,UAAAA,QAAQ,EAAE,KAFJ;AAGN;AACA;AACAC,UAAAA,UAAU,EAAE;AALN;AA1BK;AAFA,KAAjB,CAFS,EAuCT,KAAIC,oCAAJ,EAAuB;AACrBC,MAAAA,gBAAgB,EAAE;AAChBC,QAAAA,MAAM,EAAE,CACN,SADM,EAEN;AACEC,UAAAA,gBAAgB,EAAE;AAAEC,YAAAA,YAAY,EAAE;AAAhB;AADpB,SAFM;AADQ;AADG,KAAvB,CAvCS,CAFb,CAoDE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAhEF,GAFJ;AAqEA,SAAO;AACLvB,IAAAA,MADK;AAELH,IAAAA,SAFK;AAGLK,IAAAA,YAHK;AAKLsB,IAAAA,OAAO,EAAE,CACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAIC,gCAAqBC,UAAzB,EAAoC;AAClCC,MAAAA,YAAY,EAAE,IADoB;AAElCC,MAAAA,OAAO,EAAE,CAAC,QAAD,EAAW,uBAAX,CAFyB;AAGlC;AACAC,MAAAA,gBAAgB,EAAE,mBAJgB;AAKlCC,MAAAA,wBAAwB,EAAE,CACxB;AACA,UAAIC,MAAJ,CAAW,KAAX,CAFwB,EAGxB;AACA;AACA;AACA;AACA,UAAIA,MAAJ,CAAW,kBAAX,CAPwB;AALQ,KAApC,CAzBO,EAwCPC,MAxCO,CAwCAC,OAxCA,CALJ;AA8CL;AACA;AACAC,IAAAA,WAAW,EAAE;AAhDR,GAAP;AAkDD","sourcesContent":["import WorkboxWebpackPlugin from 'workbox-webpack-plugin';\nimport CssMinimizerPlugin from 'css-minimizer-webpack-plugin';\nimport TerserPlugin from 'terser-webpack-plugin';\nimport { Configuration } from 'webpack';\nimport { getExternals } from './get-externals';\nimport { getExposedRules } from './get-exposed-rules';\n// import { WebpackManifestPlugin } from 'webpack-manifest-plugin';\n\n// This is the production and development configuration.\n// It is focused on developer experience, fast rebuilds, and a minimal bundle.\n// eslint-disable-next-line complexity\nexport default function (externalizePeer: boolean, peers: string[], dev?: boolean): Configuration {\n const externals = externalizePeer ? (getExternals(peers) as any) : undefined;\n const exposedRules = externalizePeer ? undefined : getExposedRules(peers);\n\n const module = externalizePeer\n ? undefined\n : {\n rules: exposedRules,\n };\n\n const optimization = dev\n ? undefined\n : {\n minimize: true,\n minimizer: [\n // This is only used in production mode\n new TerserPlugin({\n extractComments: false,\n terserOptions: {\n parse: {\n // We want terser to parse ecma 8 code. However, we don't want it\n // to apply any minification steps that turns valid ecma 5 code\n // into invalid ecma 5 code. This is why the 'compress' and 'output'\n // sections only apply transformations that are ecma 5 safe\n // https://github.com/facebook/create-react-app/pull/4234\n ecma: 8,\n },\n compress: {\n ecma: 5,\n warnings: false,\n // Disabled because of an issue with Uglify breaking seemingly valid code:\n // https://github.com/facebook/create-react-app/issues/2376\n // Pending further investigation:\n // https://github.com/mishoo/UglifyJS2/issues/2011\n comparisons: false,\n // Disabled because of an issue with Terser breaking valid code:\n // https://github.com/facebook/create-react-app/issues/5250\n // Pending further investigation:\n // https://github.com/terser-js/terser/issues/120\n inline: 2,\n },\n mangle: {\n safari10: true,\n },\n output: {\n ecma: 5,\n comments: false,\n // Turned on because emoji and regex is not minified properly using default\n // https://github.com/facebook/create-react-app/issues/2488\n ascii_only: true,\n },\n },\n }),\n new CssMinimizerPlugin({\n minimizerOptions: {\n preset: [\n 'default',\n {\n minifyFontValues: { removeQuotes: false },\n },\n ],\n },\n }),\n ],\n // Automatically split vendor and commons\n // https://twitter.com/wSokra/status/969633336732905474\n // https://medium.com/webpack/webpack-4-code-splitting-chunk-graph-and-the-splitchunks-optimization-be739a861366\n // splitChunks: {\n // chunks: 'all',\n // name: false,\n // },\n // Keep the runtime chunk separated to enable long term caching\n // https://twitter.com/wSokra/status/969679223278505985\n // https://github.com/facebook/create-react-app/issues/5358\n // runtimeChunk: {\n // name: (entrypoint) => `runtime-${entrypoint.name}`,\n // },\n };\n\n return {\n module,\n externals,\n optimization,\n\n plugins: [\n // Generate an asset manifest file with the following content:\n // - \"files\" key: Mapping of all asset filenames to their corresponding\n // output file so that tools can pick it up without having to parse\n // `index.html`\n // can be used to reconstruct the HTML if necessary\n // new WebpackManifestPlugin({\n // fileName: 'asset-manifest.json',\n // publicPath: 'public',\n // generate: (seed, files, entrypoints) => {\n // const manifestFiles = files.reduce((manifest, file) => {\n // manifest[file.name] = file.path;\n // return manifest;\n // }, seed);\n // const entrypointFiles = entrypoints.main.filter((fileName) => !fileName.endsWith('.map'));\n\n // // @ts-ignore - https://github.com/shellscape/webpack-manifest-plugin/issues/276\n // return {\n // files: manifestFiles,\n // entrypoints: entrypointFiles,\n // } as Record<string, string>;\n // },\n // }),\n // Generate a service worker script that will precache, and keep up to date,\n // the HTML & assets that are part of the webpack build.\n new WorkboxWebpackPlugin.GenerateSW({\n clientsClaim: true,\n exclude: [/\\.map$/, /asset-manifest\\.json$/],\n // importWorkboxFrom: 'cdn',\n navigateFallback: 'public/index.html',\n navigateFallbackDenylist: [\n // Exclude URLs starting with /_, as they're likely an API call\n new RegExp('^/_'),\n // Exclude any URLs whose last part seems to be a file extension\n // as they're likely a resource and not a SPA route.\n // URLs containing a \"?\" character won't be blacklisted as they're likely\n // a route with query params (e.g. auth callbacks).\n new RegExp('/[^/?]+\\\\.[^/]+$'),\n ],\n }),\n ].filter(Boolean),\n // Turn off performance processing because we utilize\n // our own hints via the FileSizeReporter\n performance: false,\n };\n}\n"]}
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@teambit/react",
3
- "version": "0.0.623",
3
+ "version": "0.0.630",
4
4
  "homepage": "https://bit.dev/teambit/react/react",
5
5
  "main": "dist/index.js",
6
6
  "componentId": {
7
7
  "scope": "teambit.react",
8
8
  "name": "react",
9
- "version": "0.0.623"
9
+ "version": "0.0.630"
10
10
  },
11
11
  "dependencies": {
12
12
  "react-error-boundary": "^3.0.0",
@@ -30,12 +30,12 @@
30
30
  "babel-plugin-transform-typescript-metadata": "0.3.1",
31
31
  "babel-preset-jest": "26.6.2",
32
32
  "@babel/preset-typescript": "7.12.17",
33
+ "expose-loader": "3.1.0",
33
34
  "postcss-preset-env": "6.7.0",
34
35
  "react-error-overlay": "6.0.9",
35
36
  "strip-ansi": "6.0.0",
36
37
  "css-minimizer-webpack-plugin": "3.0.2",
37
38
  "terser-webpack-plugin": "5.2.0",
38
- "webpack-manifest-plugin": "4.0.2",
39
39
  "webpack": "5.51.1",
40
40
  "workbox-webpack-plugin": "6.2.4",
41
41
  "mini-css-extract-plugin": "2.2.2",
@@ -79,47 +79,49 @@
79
79
  "@teambit/react.instructions.react.adding-compositions": "0.0.6",
80
80
  "@teambit/react.instructions.react.adding-tests": "0.0.6",
81
81
  "@teambit/design.ui.pages.standalone-not-found-page": "0.0.355",
82
- "@teambit/preview": "0.0.623",
82
+ "@teambit/preview": "0.0.630",
83
83
  "@teambit/react.ui.error-fallback": "0.0.109",
84
84
  "@teambit/react.ui.loader-fallback": "0.0.88",
85
85
  "@teambit/compositions.ui.hooks.use-composition": "0.0.162",
86
86
  "@teambit/design.ui.input.option-button": "0.0.26",
87
87
  "@teambit/design.ui.tooltip": "0.0.352",
88
- "@teambit/builder": "0.0.623",
89
- "@teambit/bundler": "0.0.623",
90
- "@teambit/compiler": "0.0.623",
91
- "@teambit/component.modules.component-url": "0.0.119",
92
- "@teambit/component": "0.0.623",
93
- "@teambit/envs": "0.0.623",
94
- "@teambit/eslint": "0.0.623",
95
- "@teambit/formatter": "0.0.174",
96
- "@teambit/jest": "0.0.623",
97
- "@teambit/linter": "0.0.623",
98
- "@teambit/pkg": "0.0.623",
99
- "@teambit/prettier": "0.0.174",
88
+ "@teambit/builder": "0.0.630",
89
+ "@teambit/bundler": "0.0.630",
90
+ "@teambit/compiler": "0.0.630",
91
+ "@teambit/component.modules.component-url": "0.0.121",
92
+ "@teambit/component": "0.0.630",
93
+ "@teambit/envs": "0.0.630",
94
+ "@teambit/eslint": "0.0.630",
95
+ "@teambit/formatter": "0.0.181",
96
+ "@teambit/jest": "0.0.630",
97
+ "@teambit/linter": "0.0.630",
98
+ "@teambit/pkg": "0.0.630",
99
+ "@teambit/prettier": "0.0.181",
100
100
  "@teambit/react.ui.highlighter.component-metadata.bit-component-meta": "0.0.20",
101
- "@teambit/schema": "0.0.623",
102
- "@teambit/tester": "0.0.623",
103
- "@teambit/typescript": "0.0.623",
104
- "@teambit/webpack": "0.0.623",
105
- "@teambit/workspace": "0.0.623",
106
- "@teambit/application": "0.0.265",
107
- "@teambit/cli": "0.0.427",
108
- "@teambit/dependency-resolver": "0.0.623",
109
- "@teambit/generator": "0.0.623",
110
- "@teambit/graphql": "0.0.623",
111
- "@teambit/react.ui.highlighter-provider": "0.0.180",
112
- "@teambit/compositions": "0.0.623",
113
- "@teambit/ui": "0.0.623",
114
- "@teambit/react.eslint-config-bit-react": "0.0.504",
101
+ "@teambit/schema": "0.0.630",
102
+ "@teambit/tester": "0.0.630",
103
+ "@teambit/typescript": "0.0.630",
104
+ "@teambit/webpack": "0.0.630",
105
+ "@teambit/workspace": "0.0.630",
106
+ "@teambit/application": "0.0.272",
107
+ "@teambit/cli": "0.0.433",
108
+ "@teambit/dependency-resolver": "0.0.630",
109
+ "@teambit/generator": "0.0.630",
110
+ "@teambit/graphql": "0.0.630",
111
+ "@teambit/react.ui.highlighter-provider": "0.0.182",
112
+ "@teambit/compositions": "0.0.630",
113
+ "@teambit/ui": "0.0.630",
114
+ "@teambit/react.eslint-config-bit-react": "0.0.510",
115
+ "@teambit/webpack.modules.generate-expose-loaders": "0.0.2",
116
+ "@teambit/webpack.modules.generate-externals": "0.0.2",
117
+ "@teambit/webpack.modules.config-mutator": "0.0.136",
115
118
  "@teambit/mdx.modules.mdx-loader": "0.0.488",
116
- "@teambit/react.babel.bit-react-transformer": "0.0.496",
119
+ "@teambit/react.babel.bit-react-transformer": "0.0.498",
117
120
  "@teambit/webpack.modules.generate-style-loaders": "0.0.102",
118
121
  "@teambit/webpack.modules.style-regexps": "0.0.131",
119
- "@teambit/component-id": "0.0.398",
120
- "@teambit/isolator": "0.0.623",
122
+ "@teambit/component-id": "0.0.400",
121
123
  "@teambit/toolbox.network.get-port": "0.0.112",
122
- "@teambit/config": "0.0.439"
124
+ "@teambit/config": "0.0.446"
123
125
  },
124
126
  "devDependencies": {
125
127
  "@types/react": "^17.0.8",
@@ -137,7 +139,7 @@
137
139
  "@teambit/react.aspect-docs.react": "0.0.131"
138
140
  },
139
141
  "peerDependencies": {
140
- "@teambit/legacy": "1.0.206",
142
+ "@teambit/legacy": "1.0.209",
141
143
  "react-dom": "^16.8.0 || ^17.0.0",
142
144
  "react": "^16.8.0 || ^17.0.0"
143
145
  },
@@ -199,7 +201,7 @@
199
201
  "@types/jest": "^26.0.0"
200
202
  },
201
203
  "peerDependencies": {
202
- "@teambit/legacy": "1.0.206",
204
+ "@teambit/legacy": "1.0.209",
203
205
  "react-dom": "^16.8.0 || ^17.0.0",
204
206
  "react": "^16.8.0 || ^17.0.0"
205
207
  }
@@ -3,8 +3,14 @@ import { ComponentContext } from '@teambit/generator';
3
3
  export function appRootFile({ namePascalCase: Name }: ComponentContext) {
4
4
  return `import React from 'react';
5
5
  import ReactDOM from 'react-dom';
6
+ import { BrowserRouter } from 'react-router-dom';
6
7
  import { ${Name}App } from './app';
7
8
 
8
- ReactDOM.render(<${Name}App />, document.getElementById('root'));
9
+ ReactDOM.render((
10
+ <BrowserRouter>
11
+ <${Name}App />
12
+ </BrowserRouter>
13
+ ), document.getElementById('root'));
14
+
9
15
  `;
10
16
  }
@@ -5,7 +5,7 @@ export function compositionsFile({ namePascalCase: Name }: ComponentContext) {
5
5
  import { ${Name}App } from './app';
6
6
 
7
7
  export const ${Name}Basic = () => {
8
- return <${Name}App></${Name}App>;
8
+ return <${Name}App />;
9
9
  };
10
10
  `;
11
11
  }
@@ -54,7 +54,7 @@ export async function workspaceConfig({ name, defaultScope }: WorkspaceContext)
54
54
  /**
55
55
  * configures components with namespaces 'envs' and 'aspects' to use the default Aspect development environment.
56
56
  */
57
- "{envs/**}, {aspects/**}": {
57
+ "{envs/**}, {aspects/**}, {apps/**}": {
58
58
  "teambit.harmony/aspect": {}
59
59
  }
60
60
  }`),
@@ -0,0 +1,12 @@
1
+ import camelcase from 'camelcase';
2
+ import 'expose-loader';
3
+ import { generateExposeLoaders } from '@teambit/webpack.modules.generate-expose-loaders';
4
+
5
+ export function getExposedRules(peers: string[]) {
6
+ const loaderPath = require.resolve('expose-loader');
7
+ const depsEntries = peers.map((peer) => ({
8
+ path: require.resolve(peer),
9
+ globalName: camelcase(peer.replace('@', '').replace('/', '-'), { pascalCase: true }),
10
+ }));
11
+ return generateExposeLoaders(depsEntries, { loaderPath });
12
+ }
@@ -0,0 +1,8 @@
1
+ import camelcase from 'camelcase';
2
+ import { generateExternals } from '@teambit/webpack.modules.generate-externals';
3
+
4
+ export function getExternals(deps: string[]) {
5
+ return generateExternals(deps, {
6
+ transformName: (depName) => camelcase(depName.replace('@', '').replace('/', '-'), { pascalCase: true }),
7
+ });
8
+ }
@@ -0,0 +1,22 @@
1
+ /** html template for Previews (docs, compositions, etc) */
2
+ export function html(title: string) {
3
+ return `
4
+ <!DOCTYPE html>
5
+ <html lang="en">
6
+ <head>
7
+ <meta charset="utf-8">
8
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
9
+ <title>${title}</title>
10
+ <script>
11
+ // Allow to use react dev-tools inside the examples
12
+ try { window.__REACT_DEVTOOLS_GLOBAL_HOOK__ = window.parent.__REACT_DEVTOOLS_GLOBAL_HOOK__; } catch {}
13
+ </script>
14
+ <!-- minimal css resets -->
15
+ <style> html { height: 100%; } body { margin: 0; height: 100%; } #root { height: 100%; } </style>
16
+ </head>
17
+ <body>
18
+ <div id="root"></div>
19
+ </body>
20
+ </html>
21
+ `;
22
+ }
@@ -0,0 +1 @@
1
+ export { html } from './html';
@@ -0,0 +1,12 @@
1
+ import { WebpackConfigMutator } from '@teambit/webpack.modules.config-mutator';
2
+
3
+ export function generateAddAliasesFromPeersTransformer(peers: string[]) {
4
+ const peerAliases = peers.reduce((acc, peerName) => {
5
+ acc[peerName] = require.resolve(peerName);
6
+ return acc;
7
+ }, {});
8
+ return (config: WebpackConfigMutator): WebpackConfigMutator => {
9
+ config.addAliases(peerAliases);
10
+ return config;
11
+ };
12
+ }