@iobroker/adapter-react-v5 4.0.27 → 4.1.0

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
@@ -661,8 +661,11 @@ socket.getObjectViewCustom('custom', 'state', 'startKey', 'endKey')
661
661
  -->
662
662
 
663
663
  ## Changelog
664
+ ### 4.1.0 (2023-05-10)
665
+ * (bluefox) `craco-module-federation.js` was added. For node 16
666
+
664
667
  ### 4.0.27 (2023-05-09)
665
- * (bluefox) Allowed to show only specific root in SelectIDDialog
668
+ * (bluefox) Allowed showing only specific root in SelectIDDialog
666
669
 
667
670
  ### 4.0.26 (2023-05-08)
668
671
  * (bluefox) Added IDs to the buttons in the dialog for GUI tests
@@ -0,0 +1,70 @@
1
+ // const webpack = require('webpack');
2
+ const paths = require('react-scripts/config/paths');
3
+
4
+ const getModuleFederationConfigPath = (additionalPaths = []) => {
5
+ const path = require('path');
6
+ const fs = require('fs');
7
+ const appDirectory = fs.realpathSync(process.cwd());
8
+ const resolveApp = relativePath => path.resolve(appDirectory, relativePath);
9
+
10
+ const moduleFederationConfigFiles = [
11
+ 'modulefederation.config.js',
12
+ ...additionalPaths,
13
+ ];
14
+ return moduleFederationConfigFiles
15
+ .map(resolveApp)
16
+ .filter(fs.existsSync)
17
+ .shift();
18
+ };
19
+
20
+ module.exports = {
21
+ overrideWebpackConfig: ({webpackConfig, pluginOptions}) => {
22
+ const moduleFederationConfigPath = getModuleFederationConfigPath();
23
+
24
+ if (moduleFederationConfigPath) {
25
+ webpackConfig.output.publicPath = 'auto';
26
+
27
+ if (pluginOptions?.useNamedChunkIds) {
28
+ webpackConfig.optimization.chunkIds = 'named';
29
+ }
30
+
31
+ const htmlWebpackPlugin = webpackConfig.plugins.find(
32
+ plugin => plugin.constructor.name === 'HtmlWebpackPlugin'
33
+ );
34
+
35
+ const myModule = require(moduleFederationConfigPath);
36
+
37
+ htmlWebpackPlugin.userOptions = {
38
+ ...htmlWebpackPlugin.userOptions,
39
+ publicPath: paths.publicUrlOrPath,
40
+ excludeChunks: [myModule.name],
41
+ };
42
+
43
+ const ModuleFederationPlugin = require('webpack/lib/container/ModuleFederationPlugin');
44
+
45
+ webpackConfig.plugins = [
46
+ ...webpackConfig.plugins,
47
+ new ModuleFederationPlugin(myModule),
48
+ ];
49
+
50
+ // webpackConfig.module = {
51
+ // ...webpackConfig.module,
52
+ // generator: {
53
+ // "asset/resource": {
54
+ // publicPath: paths.publicUrlOrPath,
55
+ // },
56
+ // },
57
+ // };
58
+ }
59
+ return webpackConfig;
60
+ },
61
+ overrideDevServerConfig: ({devServerConfig}) => {
62
+ devServerConfig.headers = {
63
+ 'Access-Control-Allow-Origin': '*',
64
+ 'Access-Control-Allow-Methods': '*',
65
+ 'Access-Control-Allow-Headers': '*',
66
+ };
67
+
68
+ return devServerConfig;
69
+ },
70
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@iobroker/adapter-react-v5",
3
- "version": "4.0.27",
3
+ "version": "4.1.0",
4
4
  "description": "React classes to develop admin interfaces for ioBroker with react.",
5
5
  "author": {
6
6
  "name": "bluefox",