@redhat-cloud-services/frontend-components-config 4.7.2 → 5.0.0-beta.1

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/README.md CHANGED
@@ -7,7 +7,6 @@
7
7
  - [Removed features with webpack 5](#removed-features-with-webpack-5)
8
8
  - [useProxy](#useproxy)
9
9
  - [Attributes](#attributes)
10
- - [useChromeTemplate](#usechrometemplate)
11
10
  - [localChrome](#localchrome)
12
11
  - [keycloakUri](#keycloakuri)
13
12
  - [Registry](#registry)
@@ -69,7 +68,6 @@ const { config: webpackConfig, plugins } = config({
69
68
  |---------|----|-----------|
70
69
  |[useProxy](#useproxy)|`boolean`|Enables webpack proxy.|
71
70
  |[proxyURL](#proxyURL)|`string`|URL to proxy Akamai environment requests to.|
72
- |[useChromeTemplate](#useChromeTemplate)|`boolean`|Load chrome HTMl template.|
73
71
  |[localChrome](#localChrome)|`string`|Path to your local chrome build folder.|
74
72
  |[keycloakUri](#keycloakUri)|`string`|Uri to inject into proxied chrome assets.|
75
73
  |[registry](#registry)|`(({ app, server, compiler, standaloneConfig }) => void)[]`|Express middleware to register.|
@@ -83,23 +81,6 @@ const { config: webpackConfig, plugins } = config({
83
81
  |[bounceProd](#bounceProd)|`boolean` = `false`|Bounce all non-GET requests via server requests.|
84
82
 
85
83
 
86
- #### useChromeTemplate
87
-
88
- **This option will become the default. App-specific templates are deprecated**
89
-
90
- To load chrome HTML template instead of using the APP-specific template add `useChromeTemplate` flag to your config.
91
-
92
- ```js
93
- const config = require('@redhat-cloud-services/frontend-components-config');
94
-
95
- const { config: webpackConfig, plugins } = config({
96
- rootFolder: resolve(__dirname, '../'),
97
- useProxy: true,
98
- useChromeTemplate: true
99
- ...
100
- });
101
- ```
102
-
103
84
  #### localChrome
104
85
 
105
86
  You can also easily run you application with a local build of Chrome by adding `localChrome: <absolute_path_to_chrome_build_folder>`.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@redhat-cloud-services/frontend-components-config",
3
- "version": "4.7.2",
3
+ "version": "5.0.0-beta.1",
4
4
  "description": "Config plugins and settings for RedHat Cloud Services project.",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -21,7 +21,7 @@
21
21
  "homepage": "https://github.com/RedHatInsights/frontend-components/tree/master/packages/config#readme",
22
22
  "dependencies": {
23
23
  "@pmmmwh/react-refresh-webpack-plugin": "^0.5.8",
24
- "@redhat-cloud-services/frontend-components-config-utilities": "^1.5.31",
24
+ "@redhat-cloud-services/frontend-components-config-utilities": "^2.0.0-beta.1",
25
25
  "assert": "^2.0.0",
26
26
  "axios": "^0.27.2",
27
27
  "babel-loader": "^8.2.5",
@@ -39,7 +39,7 @@
39
39
  "html-webpack-plugin": "^5.5.0",
40
40
  "https-proxy-agent": "^5.0.1",
41
41
  "http-server": "^13.1.0",
42
- "mini-css-extract-plugin": "^1.6.2",
42
+ "mini-css-extract-plugin": "^2.7.3",
43
43
  "inquirer": "^8.2.4",
44
44
  "js-yaml": "^4.1.0",
45
45
  "jws": "^4.0.0",
package/src/config.js CHANGED
@@ -35,7 +35,6 @@ module.exports = ({
35
35
  registry,
36
36
  client = {},
37
37
  bundlePfModules = false,
38
- useChromeTemplate = true,
39
38
  bounceProd,
40
39
  useAgent,
41
40
  useDevBuild = true,
@@ -242,7 +241,7 @@ module.exports = ({
242
241
  target,
243
242
  registry,
244
243
  onBeforeSetupMiddleware: ({ chromePath }) => {
245
- if (useChromeTemplate && chromePath) {
244
+ if (chromePath) {
246
245
  copyTemplate(chromePath);
247
246
  }
248
247
  },
package/src/plugins.js CHANGED
@@ -2,29 +2,12 @@ const { SourceMapDevToolPlugin } = require('webpack');
2
2
  const { ProvidePlugin, DefinePlugin } = require('webpack');
3
3
  const MiniCssExtractPlugin = require('mini-css-extract-plugin');
4
4
  const { CleanWebpackPlugin } = require('clean-webpack-plugin');
5
- const HtmlWebpackPlugin = require('html-webpack-plugin');
6
- const HtmlReplaceWebpackPlugin = require('html-replace-webpack-plugin');
7
- const ChunkMapperPlugin = require('@redhat-cloud-services/frontend-components-config-utilities/chunk-mapper');
8
- const jsVarName = require('@redhat-cloud-services/frontend-components-config-utilities/jsVarName');
9
5
  const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
10
6
  const ReactRefreshWebpackPlugin = require('@pmmmwh/react-refresh-webpack-plugin');
11
7
  const { glob } = require('glob');
12
8
  const path = require('path');
13
9
 
14
- module.exports = ({
15
- rootFolder,
16
- appDeployment,
17
- htmlPlugin,
18
- replacePlugin,
19
- insights,
20
- modules,
21
- generateSourceMaps,
22
- plugins,
23
- useChromeTemplate = true,
24
- definePlugin = {},
25
- _unstableHotReload = false,
26
- useFileHash = true,
27
- } = {}) => {
10
+ module.exports = ({ rootFolder, insights, generateSourceMaps, plugins, definePlugin = {}, _unstableHotReload = false, useFileHash = true } = {}) => {
28
11
  const hasTsConfig = glob.sync(path.resolve(rootFolder, './{tsconfig.json,!(node_modules)/**/tsconfig.json}')).length > 0;
29
12
  const fileHash = !_unstableHotReload && useFileHash;
30
13
  return [
@@ -44,26 +27,8 @@ module.exports = ({
44
27
  }),
45
28
  new CleanWebpackPlugin({
46
29
  cleanStaleWebpackAssets: false,
47
- cleanOnceBeforeBuildPatterns: useChromeTemplate ? ['**/*', '!index.html'] : ['**/*'],
30
+ cleanOnceBeforeBuildPatterns: ['**/*', '!index.html'],
48
31
  }),
49
- ...(useChromeTemplate
50
- ? []
51
- : [
52
- new HtmlWebpackPlugin({
53
- title: 'My App',
54
- filename: 'index.html',
55
- template: `${rootFolder || ''}/src/index.html`,
56
- inject: false,
57
- ...(htmlPlugin || {}),
58
- }),
59
- new HtmlReplaceWebpackPlugin([
60
- {
61
- pattern: '@@env',
62
- replacement: appDeployment || '',
63
- },
64
- ...(replacePlugin || []),
65
- ]),
66
- ]),
67
32
  new DefinePlugin({
68
33
  // we have to wrap the appname string in another string because of how define plugin explodes strings
69
34
  CRC_APP_NAME: JSON.stringify(insights?.appname),
@@ -73,7 +38,6 @@ module.exports = ({
73
38
  process: 'process/browser.js',
74
39
  Buffer: ['buffer', 'Buffer'],
75
40
  }),
76
- new ChunkMapperPlugin({ _unstableHotReload, modules: [...(insights ? [jsVarName(insights.appname)] : []), ...(modules || [])] }),
77
41
  ...(hasTsConfig ? [new ForkTsCheckerWebpackPlugin()] : []),
78
42
  ...(plugins || []),
79
43
  ...(_unstableHotReload ? [new ReactRefreshWebpackPlugin()] : []),
@@ -1,72 +1,30 @@
1
1
  import plugins from './plugins';
2
2
  import path from 'path';
3
3
 
4
- const HTML_WEBPACK = 2;
5
- const REPLACE = 3;
6
- const DEFINE_PLUGIN = 4;
4
+ const DEFINE_PLUGIN = 2;
7
5
 
8
6
  describe('plugins generations, no option', () => {
9
- const enabledPlugins = plugins({ useChromeTemplate: false, rootFolder: '/foo/bar' });
7
+ const enabledPlugins = plugins({ rootFolder: '/foo/bar' });
10
8
 
11
9
  it('should generate plugins', () => {
12
- expect(enabledPlugins.length).toBe(7);
10
+ expect(enabledPlugins.length).toBe(4);
13
11
  });
14
12
 
15
13
  it('should generate plugins with sourceMaps', () => {
16
- const enabledPlugins = plugins({ generateSourceMaps: true, useChromeTemplate: false, rootFolder: '/foo/bar' });
17
- expect(enabledPlugins.length).toBe(8);
18
- });
19
-
20
- it('should generate correct template path for HtmlWebpackPlugin', () => {
21
- expect(enabledPlugins[HTML_WEBPACK].userOptions.template).toBe('/foo/bar/src/index.html');
14
+ const enabledPlugins = plugins({ generateSourceMaps: true, rootFolder: '/foo/bar' });
15
+ expect(enabledPlugins.length).toBe(5);
22
16
  });
23
17
  });
24
18
 
25
19
  describe('TS for plugins', () => {
26
- const pluginsWithTs = plugins({ generateSourceMaps: true, useChromeTemplate: false, rootFolder: path.resolve(__dirname, '../../../') });
27
- it('should have TSForkPlugin and 9 plugins in todal', () => {
28
- expect(pluginsWithTs).toHaveLength(9);
29
- });
30
- });
31
-
32
- describe('rootFolder', () => {
33
- const enabledPlugins = plugins({ rootFolder: '/test/folder', useChromeTemplate: false });
34
-
35
- it('should generate correct template path for HtmlWebpackPlugin', () => {
36
- expect(enabledPlugins[HTML_WEBPACK].userOptions.template).toBe('/test/folder/src/index.html');
37
- });
38
- });
39
-
40
- describe('appDeployment', () => {
41
- const enabledPlugins = plugins({ appDeployment: '/test/folder', useChromeTemplate: false, rootFolder: '/foo/bar' });
42
-
43
- it('should replace correct string', () => {
44
- enabledPlugins[REPLACE].replace({ html: 'string @@env' }, (_, { html }) => expect(html).toBe('string /test/folder'));
45
- });
46
- });
47
-
48
- it('htmlPlugin should update', () => {
49
- const enabledPlugins = plugins({ htmlPlugin: { title: 'myTitle' }, useChromeTemplate: false, rootFolder: '/foo/bar' });
50
- expect(enabledPlugins[HTML_WEBPACK].userOptions.title).toBe('myTitle');
51
- });
52
-
53
- it('replacePlugin should update', () => {
54
- const enabledPlugins = plugins({
55
- useChromeTemplate: false,
56
- rootFolder: '/foo/bar',
57
- replacePlugin: [
58
- {
59
- pattern: '@@another',
60
- replacement: 'test-string',
61
- },
62
- ],
20
+ const pluginsWithTs = plugins({ generateSourceMaps: true, rootFolder: path.resolve(__dirname, '../../../') });
21
+ it('should have TSForkPlugin and 6 plugins in todal', () => {
22
+ expect(pluginsWithTs).toHaveLength(6);
63
23
  });
64
- enabledPlugins[REPLACE].replace({ html: '@@another string @@env' }, (_, { html }) => expect(html).toBe('test-string string '));
65
24
  });
66
25
 
67
26
  it('definePlugin should have default replace of CRC_APP_NAME', () => {
68
27
  const enabledPlugins = plugins({
69
- useChromeTemplate: false,
70
28
  rootFolder: '/foo/bar',
71
29
  insights: { appname: 'test_app' },
72
30
  });
@@ -76,7 +34,6 @@ it('definePlugin should have default replace of CRC_APP_NAME', () => {
76
34
  it('definePlugin should update', () => {
77
35
  const enabledPlugins = plugins({
78
36
  rootFolder: '/foo/bar',
79
- useChromeTemplate: false,
80
37
  definePlugin: {
81
38
  SOME_VAR: JSON.stringify('test_val'),
82
39
  },
@@ -9,6 +9,7 @@ const plugins = [
9
9
  fedModulePlugin({
10
10
  root: rootDir,
11
11
  useFileHash: process.env.NODE_ENV === 'production',
12
+ separateRuntime: !!fecConfig._unstableHotReload,
12
13
  /** Load optional config for federated modules */
13
14
  ...fecConfig.moduleFederation,
14
15
  }),
package/chunk-mapper.js DELETED
@@ -1,3 +0,0 @@
1
- const chunkMapper = require('@redhat-cloud-services/frontend-components-config-utilities/chunk-mapper');
2
-
3
- module.exports = chunkMapper;