blob: 29118f13b77c0009e97fd06210e6874a49be6a89 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
import { version as ReactVersion } from 'react-dom';
export type SupportedReactVersion = keyof typeof versionsConfig;
export type ReactVersionConfig = (typeof versionsConfig)[SupportedReactVersion];
export function getReactMajorVersion(): number {
const matches = /\d+\./.exec(ReactVersion);
if (!matches) {
return NaN;
}
return Number(matches[0]);
}
export function isUnsupportedVersion(majorVersion: number) {
return majorVersion < 17 || majorVersion > 19 || Number.isNaN(majorVersion);
}
export const versionsConfig = {
17: {
server: '@astrojs/react/server-v17.js',
client: '@astrojs/react/client-v17.js',
},
18: {
server: '@astrojs/react/server.js',
client: '@astrojs/react/client.js',
},
19: {
server: '@astrojs/react/server.js',
client: '@astrojs/react/client.js',
},
};
|