Skip to content

Commit 8d71343

Browse files
committed
refactor: change React imports to type imports and update chunks for splitting
1 parent 83741c5 commit 8d71343

File tree

10 files changed

+56
-29
lines changed

10 files changed

+56
-29
lines changed

src/components/GasSelector.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
* You should have received a copy of the GNU Affero General Public License
1616
* along with this program. If not, see <http://www.gnu.org/licenses/>.
1717
*/
18-
import React from "react";
18+
import type React from "react";
19+
1920
import { Select, SelectItem } from "@heroui/select";
2021
import { pureGasMixtures, type GasMixtureExt } from "@sctg/aga8-js";
2122

src/components/OrificeSelector.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import React from "react";
1+
import type React from "react";
2+
23
import { Select, SelectItem } from "@heroui/select";
34

45
interface OrificeSelectorProps {

src/components/PressureSlider.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import React from "react";
1+
import type React from "react";
2+
23
import { Slider } from "@heroui/slider";
34

45
interface PressureSliderProps {
@@ -27,4 +28,4 @@ export const PressureSlider: React.FC<PressureSliderProps> = ({
2728
}
2829
/>
2930
);
30-
};
31+
};

src/components/SonicNozzleTable.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import React from "react";
1+
import type React from "react";
2+
23
import {
34
Table,
45
TableHeader,

src/components/icons.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import * as React from "react";
1+
import type React from "react";
22

33
import { IconSvgProps } from "@/types";
44

src/components/theme-switch.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { FC, useState, useEffect } from "react";
1+
import { type FC, useState, useEffect } from "react";
22
import { VisuallyHidden } from "@react-aria/visually-hidden";
33
import { SwitchProps, useSwitch } from "@heroui/switch";
44
import clsx from "clsx";

src/main.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
import React from "react";
2-
import ReactDOM from "react-dom/client";
1+
import { StrictMode } from "react";
2+
import { createRoot } from "react-dom/client";
33
import { BrowserRouter } from "react-router-dom";
44

55
import App from "./App.tsx";
66
import { Provider } from "./provider.tsx";
77
import "@/styles/globals.css";
88

9-
ReactDOM.createRoot(document.getElementById("root")!).render(
10-
<React.StrictMode>
9+
createRoot(document.getElementById("root")!).render(
10+
<StrictMode>
1111
<BrowserRouter basename={import.meta.env.BASE_URL}>
1212
<Provider>
1313
<App />
1414
</Provider>
1515
</BrowserRouter>
16-
</React.StrictMode>,
16+
</StrictMode>,
1717
);

src/pages/index.tsx

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
* You should have received a copy of the GNU Affero General Public License
1616
* along with this program. If not, see <http://www.gnu.org/licenses/>.
1717
*/
18+
1819
import { Button } from "@heroui/button";
1920
import { Input } from "@heroui/input";
2021
import {
@@ -30,26 +31,28 @@ import {
3031
PropertiesGERGResult,
3132
type GasMixtureExt,
3233
} from "@sctg/aga8-js";
33-
import React from "react";
3434
import { ScientificNotation } from "@sctg/scientific-notation";
35+
import { useState } from "react";
3536

3637
import { FlowData, GasInlet } from "@/components/GasInlet";
3738
import { title } from "@/components/primitives";
3839
import { SonicNozzleTable } from "@/components/SonicNozzleTable";
3940
import DefaultLayout from "@/layouts/default";
4041

4142
export default function DilutionPage() {
42-
const [selectedGasInlet1, setSelectedGasInlet1] =
43-
React.useState<GasMixtureExt>(availableGasMixtures[0]);
44-
const [selectedGasInlet2, setSelectedGasInlet2] =
45-
React.useState<GasMixtureExt>(availableGasMixtures[0]);
43+
const [selectedGasInlet1, setSelectedGasInlet1] = useState<GasMixtureExt>(
44+
availableGasMixtures[0],
45+
);
46+
const [selectedGasInlet2, setSelectedGasInlet2] = useState<GasMixtureExt>(
47+
availableGasMixtures[0],
48+
);
4649
const [selectedOrificeInlet1, setSelectedOrificeInlet1] =
47-
React.useState<number>(0.02);
50+
useState<number>(0.02);
4851
const [selectedOrificeInlet2, setSelectedOrificeInlet2] =
49-
React.useState<number>(0.02);
50-
const [inlet1Pressure, setInlet1Pressure] = React.useState<number>(400);
51-
const [inlet2Pressure, setInlet2Pressure] = React.useState<number>(400);
52-
const [inlet1FlowData, setInlet1FlowData] = React.useState<FlowData>({
52+
useState<number>(0.02);
53+
const [inlet1Pressure, setInlet1Pressure] = useState<number>(400);
54+
const [inlet2Pressure, setInlet2Pressure] = useState<number>(400);
55+
const [inlet1FlowData, setInlet1FlowData] = useState<FlowData>({
5356
massFlow: 0,
5457
p_crit: 0,
5558
A: 0,
@@ -59,7 +62,7 @@ export default function DilutionPage() {
5962
rho: 0,
6063
rho_out: 0,
6164
});
62-
const [inlet2FlowData, setInlet2FlowData] = React.useState<FlowData>({
65+
const [inlet2FlowData, setInlet2FlowData] = useState<FlowData>({
6366
massFlow: 0,
6467
p_crit: 0,
6568
A: 0,
@@ -69,12 +72,10 @@ export default function DilutionPage() {
6972
rho: 0,
7073
rho_out: 0,
7174
});
72-
const [temperature, setTemperature] = React.useState<number>(293.15);
73-
const [gas1DetailsVisible, setGas1DetailsVisible] =
74-
React.useState<boolean>(false);
75+
const [temperature, setTemperature] = useState<number>(293.15);
76+
const [gas1DetailsVisible, setGas1DetailsVisible] = useState<boolean>(false);
7577

76-
const [gas2DetailsVisible, setGas2DetailsVisible] =
77-
React.useState<boolean>(false);
78+
const [gas2DetailsVisible, setGas2DetailsVisible] = useState<boolean>(false);
7879

7980
return (
8081
<DefaultLayout>

src/types/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { SVGProps } from "react";
1+
import { type SVGProps } from "react";
22

33
export type IconSvgProps = SVGProps<SVGSVGElement> & {
44
size?: number;

vite.config.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,26 @@ export default defineConfig({
99
optimizeDeps: {
1010
exclude: ["@sctg/aga8-js"],
1111
},
12+
build: {
13+
rollupOptions: {
14+
output: {
15+
manualChunks(id) {
16+
if (id.includes("react")) {
17+
return "react";
18+
}
19+
if (id.includes("heroui")) {
20+
return "heroui";
21+
}
22+
if (id.includes("sctg")) {
23+
return "sctg";
24+
}
25+
if (id.includes("tailwind")) {
26+
return "tailwind";
27+
}
28+
29+
return null;
30+
},
31+
},
32+
},
33+
},
1234
});

0 commit comments

Comments
 (0)