Skip to content

Commit 8c25265

Browse files
committed
dev: use turbopack for local development
This PR sets up turbopack for local development for apps using the component library. This should result in much faster development rebuilds.
1 parent becf76c commit 8c25265

File tree

88 files changed

+300
-210
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

88 files changed

+300
-210
lines changed

apps/entropy-explorer/next.config.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,20 @@ const config = {
99
},
1010
},
1111

12+
turbopack: {
13+
rules: {
14+
"*.svg": {
15+
loaders: ["@svgr/webpack"],
16+
as: "*.js",
17+
},
18+
},
19+
},
20+
1221
webpack(config) {
1322
config.module.rules.push({
1423
test: /\.svg$/i,
1524
use: ["@svgr/webpack"],
1625
});
17-
18-
config.resolve.extensionAlias = {
19-
".js": [".js", ".ts", ".tsx"],
20-
};
21-
2226
return config;
2327
},
2428

apps/entropy-explorer/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"fix:lint:eslint": "eslint --fix .",
1313
"fix:lint:stylelint": "stylelint --fix 'src/**/*.scss'",
1414
"pull:env": "[ $CI ] || VERCEL_ORG_ID=team_BKQrg3JJFLxZyTqpuYtIY0rj VERCEL_PROJECT_ID=prj_34F8THr7mZ3eAOQoCLdo8xWj9fdT vercel env pull",
15-
"start:dev": "next dev --port 3006",
15+
"start:dev": "next dev --port 3006 --turbopack",
1616
"start:prod": "next start --port 3006",
1717
"test:format": "prettier --check .",
1818
"test:lint:eslint": "eslint . --max-warnings 0",

apps/insights/next.config.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,21 @@ const config = {
1313
},
1414
},
1515

16+
turbopack: {
17+
rules: {
18+
"*.svg": {
19+
loaders: ["@svgr/webpack"],
20+
as: "*.js",
21+
},
22+
},
23+
},
24+
1625
webpack(config) {
1726
config.module.rules.push({
1827
test: /\.svg$/i,
1928
use: ["@svgr/webpack"],
2029
});
2130

22-
config.resolve.extensionAlias = {
23-
".js": [".js", ".ts", ".tsx"],
24-
};
25-
2631
return config;
2732
},
2833

apps/insights/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"fix:lint:eslint": "eslint --fix .",
1313
"fix:lint:stylelint": "stylelint --fix 'src/**/*.scss'",
1414
"pull:env": "[ $CI ] || VERCEL_ORG_ID=team_BKQrg3JJFLxZyTqpuYtIY0rj VERCEL_PROJECT_ID=prj_TBkf9EyQjQF37gs4Vk0sQKJj97kE vercel env pull",
15-
"start:dev": "next dev --port 3003",
15+
"start:dev": "next dev --port 3003 --turbopack",
1616
"start:prod": "next start --port 3003",
1717
"test:format": "prettier --check .",
1818
"test:lint:eslint": "eslint . --max-warnings 0",

apps/insights/src/components/PriceComponentsCard/index.module.scss

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,3 @@
8787
}
8888
}
8989
}
90-
91-
:export {
92-
// stylelint-disable-next-line property-no-unknown
93-
headerHeight: theme.$header-height;
94-
}

apps/insights/src/components/PriceComponentsCard/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,7 @@ export const PriceComponentsCardContents = <
489489
label={label}
490490
fill
491491
rounded
492-
stickyHeader={styles.headerHeight}
492+
stickyHeader
493493
className={styles.table ?? ""}
494494
columns={[
495495
{
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
@use "@pythnetwork/component-library/theme";
2+
3+
.chart {
4+
--border-light: #{theme.pallette-color("stone", 300)};
5+
--border-dark: #{theme.pallette-color("steel", 600)};
6+
--muted-light: #{theme.pallette-color("stone", 700)};
7+
--muted-dark: #{theme.pallette-color("steel", 300)};
8+
--chart-series-primary-light: #{theme.pallette-color("violet", 500)};
9+
--chart-series-primary-dark: #{theme.pallette-color("violet", 400)};
10+
--chart-series-neutral-light: #{theme.pallette-color("stone", 500)};
11+
--chart-series-neutral-dark: #{theme.pallette-color("steel", 300)};
12+
}

apps/insights/src/components/PriceFeed/chart.tsx

Lines changed: 34 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import type { RefObject } from "react";
99
import { useEffect, useRef, useCallback } from "react";
1010
import { z } from "zod";
1111

12-
import theme from "./theme.module.scss";
12+
import styles from "./chart.module.scss";
1313
import { useLivePriceData } from "../../hooks/use-live-price-data";
1414
import { Cluster } from "../../services/pyth";
1515

@@ -22,14 +22,18 @@ export const Chart = ({ symbol, feedId }: Props) => {
2222
const chartContainerRef = useChart(symbol, feedId);
2323

2424
return (
25-
<div style={{ width: "100%", height: "100%" }} ref={chartContainerRef} />
25+
<div
26+
style={{ width: "100%", height: "100%" }}
27+
className={styles.chart}
28+
ref={chartContainerRef}
29+
/>
2630
);
2731
};
2832

2933
const useChart = (symbol: string, feedId: string) => {
3034
const { chartContainerRef, chartRef } = useChartElem(symbol, feedId);
3135
useChartResize(chartContainerRef, chartRef);
32-
useChartColors(chartRef);
36+
useChartColors(chartContainerRef, chartRef);
3337
return chartContainerRef;
3438
};
3539

@@ -217,17 +221,24 @@ const useChartResize = (
217221
});
218222
};
219223

220-
const useChartColors = (chartRef: RefObject<ChartRefContents | undefined>) => {
224+
const useChartColors = (
225+
chartContainerRef: RefObject<HTMLDivElement | null>,
226+
chartRef: RefObject<ChartRefContents | undefined>,
227+
) => {
221228
const { resolvedTheme } = useTheme();
222229
useEffect(() => {
223-
if (chartRef.current && resolvedTheme) {
224-
applyColors(chartRef.current, resolvedTheme);
230+
if (chartRef.current && chartContainerRef.current && resolvedTheme) {
231+
applyColors(chartRef.current, chartContainerRef.current, resolvedTheme);
225232
}
226-
}, [resolvedTheme, chartRef]);
233+
}, [resolvedTheme, chartRef, chartContainerRef]);
227234
};
228235

229-
const applyColors = ({ chart, ...series }: ChartRefContents, theme: string) => {
230-
const colors = getColors(theme);
236+
const applyColors = (
237+
{ chart, ...series }: ChartRefContents,
238+
container: HTMLDivElement,
239+
theme: string,
240+
) => {
241+
const colors = getColors(container, theme);
231242
chart.applyOptions({
232243
grid: {
233244
horzLines: {
@@ -260,12 +271,20 @@ const applyColors = ({ chart, ...series }: ChartRefContents, theme: string) => {
260271
}
261272
};
262273

263-
const getColors = (resolvedTheme: string) => ({
264-
border: theme[`border-${resolvedTheme}`] ?? "red",
265-
muted: theme[`muted-${resolvedTheme}`] ?? "",
266-
chartNeutral: theme[`chart-series-neutral-${resolvedTheme}`] ?? "",
267-
chartPrimary: theme[`chart-series-primary-${resolvedTheme}`] ?? "",
268-
});
274+
const getColors = (container: HTMLDivElement, resolvedTheme: string) => {
275+
const style = getComputedStyle(container);
276+
277+
return {
278+
border: style.getPropertyValue(`--border-${resolvedTheme}`),
279+
muted: style.getPropertyValue(`--muted-${resolvedTheme}`),
280+
chartNeutral: style.getPropertyValue(
281+
`--chart-series-neutral-${resolvedTheme}`,
282+
),
283+
chartPrimary: style.getPropertyValue(
284+
`--chart-series-primary-${resolvedTheme}`,
285+
),
286+
};
287+
};
269288

270289
const getLocalTimestamp = (date: Date): UTCTimestamp =>
271290
(Date.UTC(

apps/insights/src/components/PriceFeed/theme.module.scss

Lines changed: 0 additions & 15 deletions
This file was deleted.

apps/insights/src/components/PriceFeeds/price-feeds-card.module.scss

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,3 @@
2121
}
2222
}
2323
}
24-
25-
:export {
26-
// stylelint-disable-next-line property-no-unknown
27-
headerHeight: theme.$header-height;
28-
}

0 commit comments

Comments
 (0)