@module-federation/bridge-react 0.0.0-next-20240822090000 → 0.0.0-next-20240823062237

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/vite.config.ts CHANGED
@@ -22,6 +22,8 @@ export default defineConfig({
22
22
  entry: {
23
23
  index: path.resolve(__dirname, 'src/index.ts'),
24
24
  router: path.resolve(__dirname, 'src/router.tsx'),
25
+ 'router-v5': path.resolve(__dirname, 'src/router-v5.tsx'),
26
+ 'router-v6': path.resolve(__dirname, 'src/router-v6.tsx'),
25
27
  },
26
28
  formats: ['cjs', 'es'],
27
29
  fileName: (format, entryName) => `${entryName}.${format}.js`,
@@ -32,6 +34,33 @@ export default defineConfig({
32
34
  '@remix-run/router',
33
35
  'react-router',
34
36
  'react-router-dom/',
37
+ 'react-router-dom/index.js',
38
+ 'react-router-dom/dist/index.js',
39
+ ],
40
+ plugins: [
41
+ {
42
+ name: 'modify-output-plugin',
43
+ generateBundle(options, bundle) {
44
+ for (const fileName in bundle) {
45
+ const chunk = bundle[fileName];
46
+ // if (fileName.includes('router-v6') && chunk.type === 'chunk') {
47
+ // chunk.code = chunk.code.replace(
48
+ // // Match 'react-router-dom/' followed by single quotes, double quotes, or backticks, replacing only 'react-router-dom/' to react-router-v6 dist file structure
49
+ // /react-router-dom\/(?=[\'\"\`])/g,
50
+ // 'react-router-dom/dist/index.js',
51
+ // );
52
+ // }
53
+
54
+ if (fileName.includes('router-v5') && chunk.type === 'chunk') {
55
+ chunk.code = chunk.code.replace(
56
+ // Match 'react-router-dom/' followed by single quotes, double quotes, or backticks, replacing only 'react-router-dom/' to react-router-v5 dist file structure
57
+ /react-router-dom\/(?=[\'\"\`])/g,
58
+ 'react-router-dom/index.js',
59
+ );
60
+ }
61
+ }
62
+ },
63
+ },
35
64
  ],
36
65
  },
37
66
  minify: false,