@module-federation/bridge-react-webpack-plugin 0.0.0-perf-devtools-20260107043700 → 0.0.0-perf-website-code-usage-20260914033703
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/dist/index.cjs.d.ts +11 -14
- package/dist/index.cjs.js +3 -1605
- package/dist/index.es.js +3 -1605
- package/dist/types/index.d.ts +11 -0
- package/dist/types/router-alias.d.ts +1 -0
- package/dist/types/utils.d.ts +3 -0
- package/package.json +11 -9
- package/CHANGELOG.md +0 -639
- package/__tests__/mockRouterDir/router-v5/react-router-dom/package.json +0 -71
- package/__tests__/mockRouterDir/router-v6/react-router-dom/package.json +0 -49
- package/__tests__/mockRouterDir/router-v7/react-router/package.json +0 -45
- package/__tests__/utils.spec.ts +0 -102
- package/project.json +0 -29
- package/src/index.ts +0 -62
- package/src/router-alias.ts +0 -124
- package/src/utils.ts +0 -52
- package/tsconfig.json +0 -42
- package/tsconfig.node.json +0 -11
- package/vite.config.ts +0 -24
- package/vitest.config.ts +0 -22
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "react-router-dom",
|
|
3
|
-
"version": "5.3.4",
|
|
4
|
-
"description": "DOM bindings for React Router",
|
|
5
|
-
"homepage": "https://reactrouter.com/",
|
|
6
|
-
"repository": {
|
|
7
|
-
"url": "https://github.com/remix-run/react-router.git",
|
|
8
|
-
"type": "git",
|
|
9
|
-
"directory": "packages/react-router-dom"
|
|
10
|
-
},
|
|
11
|
-
"license": "MIT",
|
|
12
|
-
"author": "Remix Software <hello@remix.run>",
|
|
13
|
-
"files": [
|
|
14
|
-
"LICENSE",
|
|
15
|
-
"README.md",
|
|
16
|
-
"BrowserRouter.js",
|
|
17
|
-
"HashRouter.js",
|
|
18
|
-
"Link.js",
|
|
19
|
-
"MemoryRouter.js",
|
|
20
|
-
"NavLink.js",
|
|
21
|
-
"Prompt.js",
|
|
22
|
-
"Redirect.js",
|
|
23
|
-
"Route.js",
|
|
24
|
-
"Router.js",
|
|
25
|
-
"StaticRouter.js",
|
|
26
|
-
"Switch.js",
|
|
27
|
-
"cjs",
|
|
28
|
-
"es",
|
|
29
|
-
"esm",
|
|
30
|
-
"index.js",
|
|
31
|
-
"generatePath.js",
|
|
32
|
-
"matchPath.js",
|
|
33
|
-
"modules/*.js",
|
|
34
|
-
"modules/utils/*.js",
|
|
35
|
-
"withRouter.js",
|
|
36
|
-
"warnAboutDeprecatedCJSRequire.js",
|
|
37
|
-
"umd"
|
|
38
|
-
],
|
|
39
|
-
"main": "index.js",
|
|
40
|
-
"module": "esm/react-router-dom.js",
|
|
41
|
-
"sideEffects": false,
|
|
42
|
-
"scripts": {
|
|
43
|
-
"build": "rollup -c",
|
|
44
|
-
"lint": "eslint modules"
|
|
45
|
-
},
|
|
46
|
-
"peerDependencies": {
|
|
47
|
-
"react": ">=15"
|
|
48
|
-
},
|
|
49
|
-
"dependencies": {
|
|
50
|
-
"@babel/runtime": "^7.12.13",
|
|
51
|
-
"history": "^4.9.0",
|
|
52
|
-
"loose-envify": "^1.3.1",
|
|
53
|
-
"prop-types": "^15.6.2",
|
|
54
|
-
"react-router": "5.3.4",
|
|
55
|
-
"tiny-invariant": "^1.0.2",
|
|
56
|
-
"tiny-warning": "^1.0.0"
|
|
57
|
-
},
|
|
58
|
-
"browserify": {
|
|
59
|
-
"transform": [
|
|
60
|
-
"loose-envify"
|
|
61
|
-
]
|
|
62
|
-
},
|
|
63
|
-
"keywords": [
|
|
64
|
-
"react",
|
|
65
|
-
"router",
|
|
66
|
-
"route",
|
|
67
|
-
"routing",
|
|
68
|
-
"history",
|
|
69
|
-
"link"
|
|
70
|
-
]
|
|
71
|
-
}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "react-router-dom",
|
|
3
|
-
"version": "6.22.3",
|
|
4
|
-
"description": "Declarative routing for React web applications",
|
|
5
|
-
"keywords": [
|
|
6
|
-
"react",
|
|
7
|
-
"router",
|
|
8
|
-
"route",
|
|
9
|
-
"routing",
|
|
10
|
-
"history",
|
|
11
|
-
"link"
|
|
12
|
-
],
|
|
13
|
-
"repository": {
|
|
14
|
-
"type": "git",
|
|
15
|
-
"url": "https://github.com/remix-run/react-router",
|
|
16
|
-
"directory": "packages/react-router-dom"
|
|
17
|
-
},
|
|
18
|
-
"license": "MIT",
|
|
19
|
-
"author": "Remix Software <hello@remix.run>",
|
|
20
|
-
"sideEffects": false,
|
|
21
|
-
"main": "./dist/main.js",
|
|
22
|
-
"unpkg": "./dist/umd/react-router-dom.production.min.js",
|
|
23
|
-
"module": "./dist/index.js",
|
|
24
|
-
"types": "./dist/index.d.ts",
|
|
25
|
-
"dependencies": {
|
|
26
|
-
"@remix-run/router": "1.15.3",
|
|
27
|
-
"react-router": "6.22.3"
|
|
28
|
-
},
|
|
29
|
-
"devDependencies": {
|
|
30
|
-
"react": "^18.3.1",
|
|
31
|
-
"react-dom": "^18.3.1"
|
|
32
|
-
},
|
|
33
|
-
"peerDependencies": {
|
|
34
|
-
"react": ">=16.8",
|
|
35
|
-
"react-dom": ">=16.8"
|
|
36
|
-
},
|
|
37
|
-
"files": [
|
|
38
|
-
"dist/",
|
|
39
|
-
"CHANGELOG.md",
|
|
40
|
-
"LICENSE.md",
|
|
41
|
-
"README.md",
|
|
42
|
-
"server.d.ts",
|
|
43
|
-
"server.js",
|
|
44
|
-
"server.mjs"
|
|
45
|
-
],
|
|
46
|
-
"engines": {
|
|
47
|
-
"node": ">=14.0.0"
|
|
48
|
-
}
|
|
49
|
-
}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "react-router",
|
|
3
|
-
"version": "7.0.0",
|
|
4
|
-
"description": "Declarative routing for React applications",
|
|
5
|
-
"keywords": [
|
|
6
|
-
"react",
|
|
7
|
-
"router",
|
|
8
|
-
"route",
|
|
9
|
-
"routing",
|
|
10
|
-
"history",
|
|
11
|
-
"link"
|
|
12
|
-
],
|
|
13
|
-
"repository": {
|
|
14
|
-
"type": "git",
|
|
15
|
-
"url": "https://github.com/remix-run/react-router",
|
|
16
|
-
"directory": "packages/react-router"
|
|
17
|
-
},
|
|
18
|
-
"license": "MIT",
|
|
19
|
-
"author": "Remix Software <hello@remix.run>",
|
|
20
|
-
"sideEffects": false,
|
|
21
|
-
"main": "./dist/main.js",
|
|
22
|
-
"unpkg": "./dist/umd/react-router.production.min.js",
|
|
23
|
-
"module": "./dist/index.js",
|
|
24
|
-
"types": "./dist/index.d.ts",
|
|
25
|
-
"dependencies": {
|
|
26
|
-
"@remix-run/router": "2.0.0"
|
|
27
|
-
},
|
|
28
|
-
"devDependencies": {
|
|
29
|
-
"react": "^18.3.1",
|
|
30
|
-
"react-dom": "^18.3.1"
|
|
31
|
-
},
|
|
32
|
-
"peerDependencies": {
|
|
33
|
-
"react": ">=18.0.0",
|
|
34
|
-
"react-dom": ">=18.0.0"
|
|
35
|
-
},
|
|
36
|
-
"files": [
|
|
37
|
-
"dist/",
|
|
38
|
-
"CHANGELOG.md",
|
|
39
|
-
"LICENSE.md",
|
|
40
|
-
"README.md"
|
|
41
|
-
],
|
|
42
|
-
"engines": {
|
|
43
|
-
"node": ">=18.0.0"
|
|
44
|
-
}
|
|
45
|
-
}
|
package/__tests__/utils.spec.ts
DELETED
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
import path from 'node:path';
|
|
2
|
-
import { checkVersion, findPackageJson } from '../src/utils';
|
|
3
|
-
import { getBridgeRouterAlias } from '../src/router-alias';
|
|
4
|
-
|
|
5
|
-
const resolveRouterV5 = path.resolve(
|
|
6
|
-
__dirname,
|
|
7
|
-
'../__tests__/mockRouterDir/router-v5/react-router-dom',
|
|
8
|
-
);
|
|
9
|
-
const resolveRouterV5_PkgPath = path.resolve(
|
|
10
|
-
__dirname,
|
|
11
|
-
'../__tests__/mockRouterDir/router-v5/react-router-dom/package.json',
|
|
12
|
-
);
|
|
13
|
-
const resolveRouterV6 = path.resolve(
|
|
14
|
-
__dirname,
|
|
15
|
-
'../__tests__/mockRouterDir/router-v6/react-router-dom/dist/main.js',
|
|
16
|
-
);
|
|
17
|
-
const resolveRouterV6_PkgPath = path.resolve(
|
|
18
|
-
__dirname,
|
|
19
|
-
'../__tests__/mockRouterDir/router-v6/react-router-dom/package.json',
|
|
20
|
-
);
|
|
21
|
-
const resolveRouterV7 = path.resolve(
|
|
22
|
-
__dirname,
|
|
23
|
-
'../__tests__/mockRouterDir/router-v7/react-router',
|
|
24
|
-
);
|
|
25
|
-
const resolveRouterV7_PkgPath = path.resolve(
|
|
26
|
-
__dirname,
|
|
27
|
-
'../__tests__/mockRouterDir/router-v7/react-router/package.json',
|
|
28
|
-
);
|
|
29
|
-
|
|
30
|
-
describe('test checkVersion: should return the correct major version for react-router-dom', () => {
|
|
31
|
-
it('should return 5', () => {
|
|
32
|
-
expect(checkVersion('5.0.0')).toBe(5);
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
it('should return 5', () => {
|
|
36
|
-
expect(checkVersion('^5.0.0')).toBe(5);
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
it('should return 6', () => {
|
|
40
|
-
expect(checkVersion('6.0.0')).toBe(6);
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
it('should return 6', () => {
|
|
44
|
-
expect(checkVersion('~6.0.0')).toBe(6);
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
it('should return 6', () => {
|
|
48
|
-
expect(checkVersion('^6.0.0')).toBe(6);
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
it('should return 7', () => {
|
|
52
|
-
expect(checkVersion('7.0.0')).toBe(7);
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
it('should return 7', () => {
|
|
56
|
-
expect(checkVersion('~7.0.0')).toBe(7);
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
it('should return 7', () => {
|
|
60
|
-
expect(checkVersion('^7.0.0')).toBe(7);
|
|
61
|
-
});
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
describe('test findPackageJson: should return the correct package.json path for react-router-dom v5, v6 and react-router v7', () => {
|
|
65
|
-
it('should return the package.json path', () => {
|
|
66
|
-
expect(findPackageJson(resolveRouterV5)).toBe(resolveRouterV5_PkgPath);
|
|
67
|
-
expect(findPackageJson(resolveRouterV6)).toBe(resolveRouterV6_PkgPath);
|
|
68
|
-
expect(findPackageJson(resolveRouterV7)).toBe(resolveRouterV7_PkgPath);
|
|
69
|
-
});
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
describe('test getBridgeRouterAlias: should return the correct alias for react-router-dom v5, v6 and react-router v7', () => {
|
|
73
|
-
it('should return the correct alias for router v5', () => {
|
|
74
|
-
const res = getBridgeRouterAlias(resolveRouterV5);
|
|
75
|
-
expect(res).toEqual({
|
|
76
|
-
'react-router-dom$':
|
|
77
|
-
'@module-federation/bridge-react/dist/router-v5.es.js',
|
|
78
|
-
'react-router-dom/index.js': resolveRouterV5,
|
|
79
|
-
});
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
it('should return the correct alias for router v6', () => {
|
|
83
|
-
const res = getBridgeRouterAlias(resolveRouterV6);
|
|
84
|
-
expect(res).toEqual({
|
|
85
|
-
'react-router-dom$':
|
|
86
|
-
'@module-federation/bridge-react/dist/router-v6.es.js',
|
|
87
|
-
'react-router-dom/dist/index.js': resolveRouterV6,
|
|
88
|
-
});
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
it('should return the correct alias for router v7', () => {
|
|
92
|
-
const res = getBridgeRouterAlias(resolveRouterV7);
|
|
93
|
-
expect(res).toEqual({
|
|
94
|
-
'react-router$': '@module-federation/bridge-react/dist/router-v7.es.js',
|
|
95
|
-
'react-router-dom$':
|
|
96
|
-
'@module-federation/bridge-react/dist/router-v7.es.js',
|
|
97
|
-
'react-router/dist/development/index.js': resolveRouterV7,
|
|
98
|
-
'react-router/dist/production/index.js': resolveRouterV7,
|
|
99
|
-
'react-router-dom/dist/index.js': resolveRouterV7,
|
|
100
|
-
});
|
|
101
|
-
});
|
|
102
|
-
});
|
package/project.json
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "bridge-react-webpack-plugin",
|
|
3
|
-
"$schema": "../../node_modules/nx/schemas/project-schema.json",
|
|
4
|
-
"sourceRoot": "packages/bridge/bridge-react-webpack-plugin/src",
|
|
5
|
-
"projectType": "library",
|
|
6
|
-
"tags": ["type:pkg"],
|
|
7
|
-
"targets": {
|
|
8
|
-
"build": {
|
|
9
|
-
"executor": "nx:run-commands",
|
|
10
|
-
"options": {
|
|
11
|
-
"commands": [
|
|
12
|
-
"npm run build --prefix packages/bridge/bridge-react-webpack-plugin"
|
|
13
|
-
]
|
|
14
|
-
}
|
|
15
|
-
},
|
|
16
|
-
"test": {
|
|
17
|
-
"executor": "nx:run-commands",
|
|
18
|
-
"options": {
|
|
19
|
-
"parallel": false,
|
|
20
|
-
"commands": [
|
|
21
|
-
{
|
|
22
|
-
"command": "vitest run -c packages/bridge/bridge-react-webpack-plugin/vitest.config.ts",
|
|
23
|
-
"forwardAllArgs": false
|
|
24
|
-
}
|
|
25
|
-
]
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
}
|
package/src/index.ts
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import fs from 'node:fs';
|
|
2
|
-
import path from 'node:path';
|
|
3
|
-
import type { moduleFederationPlugin } from '@module-federation/sdk';
|
|
4
|
-
import { getBridgeRouterAlias } from './router-alias';
|
|
5
|
-
|
|
6
|
-
class ReactBridgeAliasChangerPlugin {
|
|
7
|
-
alias: string;
|
|
8
|
-
targetFile: string;
|
|
9
|
-
moduleFederationOptions: moduleFederationPlugin.ModuleFederationPluginOptions;
|
|
10
|
-
constructor(info: {
|
|
11
|
-
moduleFederationOptions: moduleFederationPlugin.ModuleFederationPluginOptions;
|
|
12
|
-
}) {
|
|
13
|
-
this.moduleFederationOptions = info.moduleFederationOptions;
|
|
14
|
-
this.alias = 'react-router-dom$';
|
|
15
|
-
this.targetFile = '@module-federation/bridge-react/dist/router.es.js';
|
|
16
|
-
|
|
17
|
-
if (this.moduleFederationOptions.shared) {
|
|
18
|
-
if (Array.isArray(this.moduleFederationOptions.shared)) {
|
|
19
|
-
if (this.moduleFederationOptions.shared.includes('react-router-dom')) {
|
|
20
|
-
throw Error(
|
|
21
|
-
'React-router-dom cannot be set to shared after react bridge is used',
|
|
22
|
-
);
|
|
23
|
-
}
|
|
24
|
-
} else {
|
|
25
|
-
if (this.moduleFederationOptions.shared['react-router-dom']) {
|
|
26
|
-
throw Error(
|
|
27
|
-
'React-router-dom cannot be set to shared after react bridge is used',
|
|
28
|
-
);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
apply(compiler: any) {
|
|
35
|
-
compiler.hooks.afterEnvironment.tap('ReactBridgeAliasPlugin', () => {
|
|
36
|
-
// Gets the path to the node_modules directory
|
|
37
|
-
const nodeModulesPath = path.resolve(compiler.context, 'node_modules');
|
|
38
|
-
const targetFilePath = path.join(nodeModulesPath, this.targetFile);
|
|
39
|
-
|
|
40
|
-
if (fs.existsSync(targetFilePath)) {
|
|
41
|
-
const originalResolve = compiler.options.resolve || {};
|
|
42
|
-
const originalAlias = originalResolve.alias || {};
|
|
43
|
-
|
|
44
|
-
// Update alias - set up router version alias
|
|
45
|
-
const updatedAlias: Record<string, string> = {
|
|
46
|
-
// allow `alias` can be override
|
|
47
|
-
// [this.alias]: targetFilePath,
|
|
48
|
-
...getBridgeRouterAlias(originalAlias['react-router-dom']),
|
|
49
|
-
...originalAlias,
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
// Update the webpack configuration
|
|
53
|
-
compiler.options.resolve = {
|
|
54
|
-
...originalResolve,
|
|
55
|
-
alias: updatedAlias,
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
export default ReactBridgeAliasChangerPlugin;
|
package/src/router-alias.ts
DELETED
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
import fs from 'node:fs';
|
|
2
|
-
import path from 'node:path';
|
|
3
|
-
import { checkVersion, findPackageJson, getDependencies } from './utils';
|
|
4
|
-
|
|
5
|
-
const reactRouterDomV5AliasPath =
|
|
6
|
-
'@module-federation/bridge-react/dist/router-v5.es.js';
|
|
7
|
-
const reactRouterDomV6AliasPath =
|
|
8
|
-
'@module-federation/bridge-react/dist/router-v6.es.js';
|
|
9
|
-
const reactRouterDomV7AliasPath =
|
|
10
|
-
'@module-federation/bridge-react/dist/router-v7.es.js';
|
|
11
|
-
|
|
12
|
-
const createReactRouterV7Alias = (
|
|
13
|
-
reactRouterDomPath: string,
|
|
14
|
-
): Record<string, string> => {
|
|
15
|
-
const baseAlias = {
|
|
16
|
-
'react-router$': reactRouterDomV7AliasPath,
|
|
17
|
-
'react-router-dom$': reactRouterDomV7AliasPath, // Keep compatibility for old imports
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
const resolvedDistPaths: Record<string, string> = {
|
|
21
|
-
'react-router/dist/development/index.js': reactRouterDomPath,
|
|
22
|
-
'react-router/dist/production/index.js': reactRouterDomPath,
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
const legacyCompatibility: Record<string, string> = {
|
|
26
|
-
'react-router-dom/dist/index.js': reactRouterDomPath,
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
return {
|
|
30
|
-
...baseAlias,
|
|
31
|
-
...resolvedDistPaths,
|
|
32
|
-
...legacyCompatibility,
|
|
33
|
-
};
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
const createReactRouterV5Alias = (
|
|
37
|
-
reactRouterDomPath: string,
|
|
38
|
-
): Record<string, string> => {
|
|
39
|
-
return {
|
|
40
|
-
'react-router-dom$': reactRouterDomV5AliasPath,
|
|
41
|
-
'react-router-dom/index.js': reactRouterDomPath,
|
|
42
|
-
};
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
const createReactRouterV6Alias = (
|
|
46
|
-
reactRouterDomPath: string,
|
|
47
|
-
): Record<string, string> => {
|
|
48
|
-
return {
|
|
49
|
-
'react-router-dom$': reactRouterDomV6AliasPath,
|
|
50
|
-
'react-router-dom/dist/index.js': reactRouterDomPath,
|
|
51
|
-
};
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
const setRouterAlias = (
|
|
55
|
-
majorVersion: number,
|
|
56
|
-
reactRouterDomPath: string,
|
|
57
|
-
): Record<string, string> => {
|
|
58
|
-
switch (majorVersion) {
|
|
59
|
-
case 5:
|
|
60
|
-
return createReactRouterV5Alias(reactRouterDomPath);
|
|
61
|
-
case 6:
|
|
62
|
-
return createReactRouterV6Alias(reactRouterDomPath);
|
|
63
|
-
case 7:
|
|
64
|
-
return createReactRouterV7Alias(reactRouterDomPath);
|
|
65
|
-
default:
|
|
66
|
-
console.warn(
|
|
67
|
-
`Unsupported React Router version: ${majorVersion}. Defaulting to v7.`,
|
|
68
|
-
);
|
|
69
|
-
return createReactRouterV7Alias(reactRouterDomPath);
|
|
70
|
-
}
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
export const getBridgeRouterAlias = (
|
|
74
|
-
originalAlias: string,
|
|
75
|
-
): Record<string, string> => {
|
|
76
|
-
const userDependencies = getDependencies();
|
|
77
|
-
let reactRouterDomPath = '';
|
|
78
|
-
|
|
79
|
-
if (originalAlias) {
|
|
80
|
-
reactRouterDomPath = originalAlias;
|
|
81
|
-
} else if (userDependencies['react-router']) {
|
|
82
|
-
// React Router v7 uses 'react-router' package name
|
|
83
|
-
reactRouterDomPath = path.resolve(
|
|
84
|
-
process.cwd(),
|
|
85
|
-
'node_modules/react-router',
|
|
86
|
-
);
|
|
87
|
-
} else if (userDependencies['react-router-dom']) {
|
|
88
|
-
// React Router v5/v6 uses 'react-router-dom' package name
|
|
89
|
-
reactRouterDomPath = path.resolve(
|
|
90
|
-
process.cwd(),
|
|
91
|
-
'node_modules/react-router-dom',
|
|
92
|
-
);
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
// Generate alias based on detected router package
|
|
96
|
-
if (reactRouterDomPath) {
|
|
97
|
-
const packageJsonPath = findPackageJson(reactRouterDomPath);
|
|
98
|
-
if (packageJsonPath) {
|
|
99
|
-
const packageJsonContent = JSON.parse(
|
|
100
|
-
fs.readFileSync(packageJsonPath, 'utf-8'),
|
|
101
|
-
);
|
|
102
|
-
const majorVersion = checkVersion(packageJsonContent.version);
|
|
103
|
-
const bridgeRouterAlias = setRouterAlias(
|
|
104
|
-
majorVersion,
|
|
105
|
-
reactRouterDomPath,
|
|
106
|
-
);
|
|
107
|
-
console.log(
|
|
108
|
-
'<<<<<<<<<<<<< bridgeRouterAlias >>>>>>>>>>>>>',
|
|
109
|
-
bridgeRouterAlias,
|
|
110
|
-
);
|
|
111
|
-
return bridgeRouterAlias;
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
// Default to v6 which uses 'react-router-dom'
|
|
116
|
-
const bridgeRouterAlias = {
|
|
117
|
-
'react-router-dom$': reactRouterDomV6AliasPath,
|
|
118
|
-
};
|
|
119
|
-
console.log(
|
|
120
|
-
'<<<<<<<<<<<<< default bridgeRouterAlias >>>>>>>>>>>>>',
|
|
121
|
-
bridgeRouterAlias,
|
|
122
|
-
);
|
|
123
|
-
return bridgeRouterAlias;
|
|
124
|
-
};
|
package/src/utils.ts
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import fs from 'node:fs';
|
|
2
|
-
import path from 'node:path';
|
|
3
|
-
import semver from 'semver';
|
|
4
|
-
|
|
5
|
-
export const checkVersion = (version: string) => {
|
|
6
|
-
// Extract the version number starting from the first digit
|
|
7
|
-
const versionMatch = version.match(/\d.*/);
|
|
8
|
-
if (!versionMatch) return 0;
|
|
9
|
-
|
|
10
|
-
const cleanVersion = versionMatch[0];
|
|
11
|
-
|
|
12
|
-
if (semver.gte(cleanVersion, '5.0.0') && semver.lt(cleanVersion, '6.0.0')) {
|
|
13
|
-
return 5;
|
|
14
|
-
} else if (
|
|
15
|
-
semver.gte(cleanVersion, '6.0.0') &&
|
|
16
|
-
semver.lt(cleanVersion, '7.0.0')
|
|
17
|
-
) {
|
|
18
|
-
return 6;
|
|
19
|
-
} else if (semver.gte(cleanVersion, '7.0.0')) {
|
|
20
|
-
return 7;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
return 0;
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
export const findPackageJson = (startPath: string): string | null => {
|
|
27
|
-
let currentPath = startPath;
|
|
28
|
-
while (currentPath !== path.parse(currentPath).root) {
|
|
29
|
-
const packageJsonPath = path.join(currentPath, 'package.json');
|
|
30
|
-
if (fs.existsSync(packageJsonPath)) {
|
|
31
|
-
return packageJsonPath;
|
|
32
|
-
}
|
|
33
|
-
currentPath = path.dirname(currentPath);
|
|
34
|
-
}
|
|
35
|
-
return null;
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
export const getDependencies = () => {
|
|
39
|
-
const userPackageJsonPath = path.resolve(process.cwd(), 'package.json');
|
|
40
|
-
let userDependencies: Record<string, string> = {};
|
|
41
|
-
|
|
42
|
-
if (fs.existsSync(userPackageJsonPath)) {
|
|
43
|
-
const userPackageJson = JSON.parse(
|
|
44
|
-
fs.readFileSync(userPackageJsonPath, 'utf-8'),
|
|
45
|
-
);
|
|
46
|
-
userDependencies = {
|
|
47
|
-
...userPackageJson.dependencies,
|
|
48
|
-
...userPackageJson.devDependencies,
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
return userDependencies;
|
|
52
|
-
};
|
package/tsconfig.json
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"useDefineForClassFields": true,
|
|
4
|
-
|
|
5
|
-
/* Bundler mode */
|
|
6
|
-
"allowImportingTsExtensions": true,
|
|
7
|
-
"resolveJsonModule": true,
|
|
8
|
-
|
|
9
|
-
"declarationDir": "./dist/types",
|
|
10
|
-
"rootDir": "./src",
|
|
11
|
-
"module": "commonjs",
|
|
12
|
-
"target": "es5",
|
|
13
|
-
|
|
14
|
-
/* Linting */
|
|
15
|
-
"noUnusedLocals": true,
|
|
16
|
-
"noUnusedParameters": true,
|
|
17
|
-
"noFallthroughCasesInSwitch": true,
|
|
18
|
-
"declaration": true,
|
|
19
|
-
"emitDeclarationOnly": true,
|
|
20
|
-
"outDir": "dist",
|
|
21
|
-
"skipLibCheck": true,
|
|
22
|
-
"strict": true,
|
|
23
|
-
"moduleResolution": "node",
|
|
24
|
-
"lib": ["esnext", "dom"],
|
|
25
|
-
"jsx": "preserve",
|
|
26
|
-
"esModuleInterop": true,
|
|
27
|
-
"allowSyntheticDefaultImports": true,
|
|
28
|
-
"sourceMap": true,
|
|
29
|
-
"baseUrl": ".",
|
|
30
|
-
"paths": {
|
|
31
|
-
"@/*": ["src/*"]
|
|
32
|
-
}
|
|
33
|
-
},
|
|
34
|
-
"include": [
|
|
35
|
-
"src/**/*.ts",
|
|
36
|
-
"src/**/*.tsx",
|
|
37
|
-
"src/**/*.vue",
|
|
38
|
-
"src/remoteApp.tsx",
|
|
39
|
-
"src/create.ts"
|
|
40
|
-
],
|
|
41
|
-
"references": [{ "path": "./tsconfig.node.json" }]
|
|
42
|
-
}
|
package/tsconfig.node.json
DELETED
package/vite.config.ts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { defineConfig } from 'vite';
|
|
2
|
-
import path from 'path';
|
|
3
|
-
import dts from 'vite-plugin-dts';
|
|
4
|
-
|
|
5
|
-
export default defineConfig({
|
|
6
|
-
plugins: [
|
|
7
|
-
dts({
|
|
8
|
-
rollupTypes: true,
|
|
9
|
-
}),
|
|
10
|
-
],
|
|
11
|
-
build: {
|
|
12
|
-
lib: {
|
|
13
|
-
entry: {
|
|
14
|
-
index: path.resolve(__dirname, 'src/index.ts'),
|
|
15
|
-
},
|
|
16
|
-
formats: ['cjs', 'es'],
|
|
17
|
-
fileName: (format, entryName) => `${entryName}.${format}.js`,
|
|
18
|
-
},
|
|
19
|
-
rollupOptions: {
|
|
20
|
-
external: ['node:fs', 'node:path'],
|
|
21
|
-
},
|
|
22
|
-
minify: false,
|
|
23
|
-
},
|
|
24
|
-
});
|
package/vitest.config.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { defineConfig } from 'vitest/config';
|
|
2
|
-
import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin';
|
|
3
|
-
import path from 'path';
|
|
4
|
-
export default defineConfig({
|
|
5
|
-
define: {
|
|
6
|
-
__DEV__: true,
|
|
7
|
-
__TEST__: true,
|
|
8
|
-
__BROWSER__: false,
|
|
9
|
-
__VERSION__: '"unknown"',
|
|
10
|
-
__APP_VERSION__: '"0.0.0"',
|
|
11
|
-
},
|
|
12
|
-
plugins: [nxViteTsPaths()],
|
|
13
|
-
test: {
|
|
14
|
-
environment: 'jsdom',
|
|
15
|
-
include: [
|
|
16
|
-
path.resolve(__dirname, '__tests__/*.spec.ts'),
|
|
17
|
-
path.resolve(__dirname, '__tests__/*.spec.tsx'),
|
|
18
|
-
],
|
|
19
|
-
globals: true,
|
|
20
|
-
testTimeout: 10000,
|
|
21
|
-
},
|
|
22
|
-
});
|