@module-federation/bridge-react-webpack-plugin 0.7.3 → 0.7.5

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/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # @module-federation/bridge-react-webpack-plugin
2
2
 
3
+ ## 0.7.5
4
+
5
+ ### Patch Changes
6
+
7
+ - 0309fb5: fix: wrap try catch with react-router-dom path resolve
8
+ - @module-federation/sdk@0.7.5
9
+
10
+ ## 0.7.4
11
+
12
+ ### Patch Changes
13
+
14
+ - @module-federation/sdk@0.7.4
15
+
3
16
  ## 0.7.3
4
17
 
5
18
  ### Patch Changes
package/dist/index.cjs.js CHANGED
@@ -1695,11 +1695,25 @@ const setRouterAlias = (majorVersion, reactRouterDomPath) => {
1695
1695
  };
1696
1696
  const getBridgeRouterAlias = (originalAlias) => {
1697
1697
  const userDependencies = getDependencies();
1698
- const reactRouterDomPath = originalAlias ? originalAlias : userDependencies["react-router-dom"] ? require.resolve("react-router-dom") : "";
1699
- const packageJsonPath = reactRouterDomPath ? findPackageJson(reactRouterDomPath) : "";
1700
- if (packageJsonPath) {
1701
- const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf-8"));
1702
- const majorVersion = checkVersion(packageJson.version);
1698
+ let reactRouterDomPath = "";
1699
+ if (originalAlias) {
1700
+ reactRouterDomPath = originalAlias;
1701
+ } else if (userDependencies["react-router-dom"]) {
1702
+ try {
1703
+ reactRouterDomPath = path.resolve(
1704
+ process.cwd(),
1705
+ "node_modules/react-router-dom"
1706
+ );
1707
+ } catch (error) {
1708
+ console.log(error);
1709
+ }
1710
+ }
1711
+ if (reactRouterDomPath) {
1712
+ const packageJsonPath = findPackageJson(reactRouterDomPath) || "";
1713
+ const packageJsonContent = JSON.parse(
1714
+ fs.readFileSync(packageJsonPath, "utf-8")
1715
+ );
1716
+ const majorVersion = checkVersion(packageJsonContent.version);
1703
1717
  const bridgeRouterAlias = setRouterAlias(majorVersion, reactRouterDomPath);
1704
1718
  console.log(
1705
1719
  "<<<<<<<<<<<<< bridgeRouterAlias >>>>>>>>>>>>>",
package/dist/index.es.js CHANGED
@@ -1673,11 +1673,25 @@ const setRouterAlias = (majorVersion, reactRouterDomPath) => {
1673
1673
  };
1674
1674
  const getBridgeRouterAlias = (originalAlias) => {
1675
1675
  const userDependencies = getDependencies();
1676
- const reactRouterDomPath = originalAlias ? originalAlias : userDependencies["react-router-dom"] ? require.resolve("react-router-dom") : "";
1677
- const packageJsonPath = reactRouterDomPath ? findPackageJson(reactRouterDomPath) : "";
1678
- if (packageJsonPath) {
1679
- const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf-8"));
1680
- const majorVersion = checkVersion(packageJson.version);
1676
+ let reactRouterDomPath = "";
1677
+ if (originalAlias) {
1678
+ reactRouterDomPath = originalAlias;
1679
+ } else if (userDependencies["react-router-dom"]) {
1680
+ try {
1681
+ reactRouterDomPath = path.resolve(
1682
+ process.cwd(),
1683
+ "node_modules/react-router-dom"
1684
+ );
1685
+ } catch (error) {
1686
+ console.log(error);
1687
+ }
1688
+ }
1689
+ if (reactRouterDomPath) {
1690
+ const packageJsonPath = findPackageJson(reactRouterDomPath) || "";
1691
+ const packageJsonContent = JSON.parse(
1692
+ fs.readFileSync(packageJsonPath, "utf-8")
1693
+ );
1694
+ const majorVersion = checkVersion(packageJsonContent.version);
1681
1695
  const bridgeRouterAlias = setRouterAlias(majorVersion, reactRouterDomPath);
1682
1696
  console.log(
1683
1697
  "<<<<<<<<<<<<< bridgeRouterAlias >>>>>>>>>>>>>",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@module-federation/bridge-react-webpack-plugin",
3
- "version": "0.7.3",
3
+ "version": "0.7.5",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -25,7 +25,7 @@
25
25
  "dependencies": {
26
26
  "semver": "7.6.3",
27
27
  "@types/semver": "7.5.8",
28
- "@module-federation/sdk": "0.7.3"
28
+ "@module-federation/sdk": "0.7.5"
29
29
  },
30
30
  "devDependencies": {
31
31
  "typescript": "^5.2.2",
package/src/utis.ts CHANGED
@@ -87,18 +87,28 @@ export const getBridgeRouterAlias = (
87
87
  originalAlias: string,
88
88
  ): Record<string, string> => {
89
89
  const userDependencies = getDependencies();
90
- const reactRouterDomPath = originalAlias
91
- ? originalAlias
92
- : userDependencies['react-router-dom']
93
- ? require.resolve('react-router-dom')
94
- : '';
95
- const packageJsonPath = reactRouterDomPath
96
- ? findPackageJson(reactRouterDomPath)
97
- : '';
90
+ let reactRouterDomPath = '';
91
+
92
+ if (originalAlias) {
93
+ reactRouterDomPath = originalAlias;
94
+ } else if (userDependencies['react-router-dom']) {
95
+ try {
96
+ reactRouterDomPath = path.resolve(
97
+ process.cwd(),
98
+ 'node_modules/react-router-dom',
99
+ );
100
+ } catch (error) {
101
+ console.log(error);
102
+ }
103
+ }
104
+
98
105
  // if find react-router-dom in package.json
99
- if (packageJsonPath) {
100
- const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'));
101
- const majorVersion = checkVersion(packageJson.version);
106
+ if (reactRouterDomPath) {
107
+ const packageJsonPath = findPackageJson(reactRouterDomPath) || '';
108
+ const packageJsonContent = JSON.parse(
109
+ fs.readFileSync(packageJsonPath, 'utf-8'),
110
+ );
111
+ const majorVersion = checkVersion(packageJsonContent.version);
102
112
  const bridgeRouterAlias = setRouterAlias(majorVersion, reactRouterDomPath);
103
113
  console.log(
104
114
  '<<<<<<<<<<<<< bridgeRouterAlias >>>>>>>>>>>>>',