@redhat-cloud-services/frontend-components-config 4.6.25 → 4.6.27

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@redhat-cloud-services/frontend-components-config",
3
- "version": "4.6.25",
3
+ "version": "4.6.27",
4
4
  "description": "Config plugins and settings for RedHat Cloud Services project.",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -20,7 +20,8 @@
20
20
  },
21
21
  "homepage": "https://github.com/RedHatInsights/frontend-components/tree/master/packages/config#readme",
22
22
  "dependencies": {
23
- "@redhat-cloud-services/frontend-components-config-utilities": "^1.5.23",
23
+ "@pmmmwh/react-refresh-webpack-plugin": "^0.5.8",
24
+ "@redhat-cloud-services/frontend-components-config-utilities": "^1.5.24",
24
25
  "assert": "^2.0.0",
25
26
  "axios": "^0.27.2",
26
27
  "babel-loader": "^8.2.5",
@@ -45,6 +46,7 @@
45
46
  "lodash": "^4.17.21",
46
47
  "path-browserify": "^1.0.1",
47
48
  "process": "^0.11.10",
49
+ "react-refresh": "^0.14.0",
48
50
  "sass": "^1.55.0",
49
51
  "sass-loader": "^11.1.1",
50
52
  "source-map-loader": "^3.0.1",
package/src/config.js CHANGED
@@ -41,8 +41,10 @@ module.exports = ({
41
41
  useDevBuild = true,
42
42
  useCache = false,
43
43
  cacheConfig = {},
44
+ _unstableHotReload = false,
45
+ resolve = {},
44
46
  } = {}) => {
45
- const filenameMask = `js/[name]${useFileHash ? `.${Date.now()}.[fullhash]` : ''}.js`;
47
+ const filenameMask = `js/[name]${!_unstableHotReload && useFileHash ? `.${Date.now()}.[fullhash]` : ''}.js`;
46
48
  if (betaEnv) {
47
49
  env = `${betaEnv}-beta`;
48
50
  console.warn('betaEnv is deprecated in favor of env');
@@ -75,15 +77,29 @@ module.exports = ({
75
77
  },
76
78
  }
77
79
  : {}),
78
- entry: {
79
- App: appEntry,
80
- },
80
+ entry: _unstableHotReload
81
+ ? {
82
+ main: appEntry,
83
+ vendors: ['react', 'react-dom', 'react-refresh/runtime'],
84
+ }
85
+ : {
86
+ App: appEntry,
87
+ },
81
88
  output: {
82
89
  filename: filenameMask,
83
90
  path: outputPath,
84
91
  publicPath,
85
92
  chunkFilename: filenameMask,
86
93
  },
94
+ ...(_unstableHotReload
95
+ ? {
96
+ optimization: {
97
+ // for HMR all runtime chunks must be in a single file
98
+ runtimeChunk: 'single',
99
+ removeEmptyChunks: true,
100
+ },
101
+ }
102
+ : {}),
87
103
  module: {
88
104
  rules: [
89
105
  {
@@ -157,9 +173,11 @@ module.exports = ({
157
173
  ],
158
174
  },
159
175
  resolve: {
160
- extensions: ['.ts', '.tsx', '.mjs', '.js', '.scss'],
176
+ ...resolve,
177
+ extensions: ['.ts', '.tsx', '.mjs', '.js', '.scss', ...(resolve.extensions, [])],
161
178
  alias: {
162
179
  ...(bundlePfModules ? {} : searchIgnoredStyles(rootFolder)),
180
+ ...resolve.alias,
163
181
  },
164
182
  fallback: {
165
183
  path: require.resolve('path-browserify'),
@@ -170,6 +188,7 @@ module.exports = ({
170
188
  url: require.resolve('url/'),
171
189
  util: require.resolve('util/'),
172
190
  process: 'process/browser.js',
191
+ ...resolve.fallback,
173
192
  },
174
193
  },
175
194
  devServer: {
@@ -179,7 +198,8 @@ module.exports = ({
179
198
  port: devServerPort,
180
199
  https: https || Boolean(useProxy),
181
200
  host: '0.0.0.0', // This shares on local network. Needed for docker.host.internal
182
- hot: false, // Use livereload instead of HMR which is spotty with federated modules
201
+ hot: _unstableHotReload, // Use livereload instead of HMR which is spotty with federated modules
202
+ liveReload: !_unstableHotReload,
183
203
  allowedHosts: 'all',
184
204
  // https://github.com/bripkens/connect-history-api-fallback
185
205
  historyApiFallback: {
@@ -48,6 +48,7 @@ describe('should create dummy config with no options', () => {
48
48
  host: '0.0.0.0',
49
49
  port: 8002,
50
50
  hot: false,
51
+ liveReload: true,
51
52
  allowedHosts: 'all',
52
53
  historyApiFallback: {
53
54
  rewrites: [
package/src/plugins.js CHANGED
@@ -7,6 +7,7 @@ const HtmlReplaceWebpackPlugin = require('html-replace-webpack-plugin');
7
7
  const ChunkMapperPlugin = require('@redhat-cloud-services/frontend-components-config-utilities/chunk-mapper');
8
8
  const jsVarName = require('@redhat-cloud-services/frontend-components-config-utilities/jsVarName');
9
9
  const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
10
+ const ReactRefreshWebpackPlugin = require('@pmmmwh/react-refresh-webpack-plugin');
10
11
  const { glob } = require('glob');
11
12
  const path = require('path');
12
13
 
@@ -21,21 +22,24 @@ module.exports = ({
21
22
  plugins,
22
23
  useChromeTemplate = true,
23
24
  definePlugin = {},
25
+ _unstableHotReload = false,
26
+ useFileHash = true,
24
27
  } = {}) => {
25
28
  const hasTsConfig = glob.sync(path.resolve(rootFolder, './{tsconfig.json,!(node_modules)/**/tsconfig.json}')).length > 0;
29
+ const fileHash = !_unstableHotReload && useFileHash;
26
30
  return [
27
31
  ...(generateSourceMaps
28
32
  ? [
29
33
  new SourceMapDevToolPlugin({
30
34
  test: 'js',
31
35
  exclude: /(node_modules|bower_components)/i,
32
- filename: 'sourcemaps/[name].[contenthash].js.map',
36
+ filename: fileHash ? 'sourcemaps/[name].js.map' : 'sourcemaps/[name].[contenthash].js.map',
33
37
  }),
34
38
  ]
35
39
  : []),
36
40
  new MiniCssExtractPlugin({
37
- chunkFilename: 'css/[name].[contenthash].css',
38
- filename: 'css/[name].[contenthash].css',
41
+ chunkFilename: fileHash ? 'css/[name].css' : 'css/[name].[contenthash].css',
42
+ filename: fileHash ? 'css/[name].css' : 'css/[name].[contenthash].css',
39
43
  ignoreOrder: true,
40
44
  }),
41
45
  new CleanWebpackPlugin({
@@ -69,8 +73,9 @@ module.exports = ({
69
73
  process: 'process/browser.js',
70
74
  Buffer: ['buffer', 'Buffer'],
71
75
  }),
72
- new ChunkMapperPlugin({ modules: [...(insights ? [jsVarName(insights.appname)] : []), ...(modules || [])] }),
76
+ new ChunkMapperPlugin({ _unstableHotReload, modules: [...(insights ? [jsVarName(insights.appname)] : []), ...(modules || [])] }),
73
77
  ...(hasTsConfig ? [new ForkTsCheckerWebpackPlugin()] : []),
74
78
  ...(plugins || []),
79
+ ...(_unstableHotReload ? [new ReactRefreshWebpackPlugin()] : []),
75
80
  ];
76
81
  };