@module-federation/bridge-react-webpack-plugin 0.0.0-next-20241118092546 → 0.0.0-next-20241118095355

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,11 +1,10 @@
1
1
  # @module-federation/bridge-react-webpack-plugin
2
2
 
3
- ## 0.0.0-next-20241118092546
3
+ ## 0.0.0-next-20241118095355
4
4
 
5
5
  ### Patch Changes
6
6
 
7
- - 0309fb5: fix: wrap try catch with react-router-dom path resolve
8
- - @module-federation/sdk@0.0.0-next-20241118092546
7
+ - @module-federation/sdk@0.0.0-next-20241118095355
9
8
 
10
9
  ## 0.7.4
11
10
 
package/dist/index.cjs.js CHANGED
@@ -1695,25 +1695,11 @@ const setRouterAlias = (majorVersion, reactRouterDomPath) => {
1695
1695
  };
1696
1696
  const getBridgeRouterAlias = (originalAlias) => {
1697
1697
  const userDependencies = getDependencies();
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);
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);
1717
1703
  const bridgeRouterAlias = setRouterAlias(majorVersion, reactRouterDomPath);
1718
1704
  console.log(
1719
1705
  "<<<<<<<<<<<<< bridgeRouterAlias >>>>>>>>>>>>>",
package/dist/index.es.js CHANGED
@@ -1673,25 +1673,11 @@ const setRouterAlias = (majorVersion, reactRouterDomPath) => {
1673
1673
  };
1674
1674
  const getBridgeRouterAlias = (originalAlias) => {
1675
1675
  const userDependencies = getDependencies();
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);
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);
1695
1681
  const bridgeRouterAlias = setRouterAlias(majorVersion, reactRouterDomPath);
1696
1682
  console.log(
1697
1683
  "<<<<<<<<<<<<< bridgeRouterAlias >>>>>>>>>>>>>",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@module-federation/bridge-react-webpack-plugin",
3
- "version": "0.0.0-next-20241118092546",
3
+ "version": "0.0.0-next-20241118095355",
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.0.0-next-20241118092546"
28
+ "@module-federation/sdk": "0.0.0-next-20241118095355"
29
29
  },
30
30
  "devDependencies": {
31
31
  "typescript": "^5.2.2",
package/src/utis.ts CHANGED
@@ -87,28 +87,18 @@ export const getBridgeRouterAlias = (
87
87
  originalAlias: string,
88
88
  ): Record<string, string> => {
89
89
  const userDependencies = getDependencies();
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
-
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
+ : '';
105
98
  // if find react-router-dom in package.json
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);
99
+ if (packageJsonPath) {
100
+ const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'));
101
+ const majorVersion = checkVersion(packageJson.version);
112
102
  const bridgeRouterAlias = setRouterAlias(majorVersion, reactRouterDomPath);
113
103
  console.log(
114
104
  '<<<<<<<<<<<<< bridgeRouterAlias >>>>>>>>>>>>>',