Skip to content

Commit 26a1518

Browse files
committed
[chore] Migrate from cra to vite
1 parent bca5022 commit 26a1518

File tree

16 files changed

+3985
-30503
lines changed

16 files changed

+3985
-30503
lines changed

NOTICES

Lines changed: 2049 additions & 17532 deletions
Large diffs are not rendered by default.

streamlit_bokeh/frontend/.env

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
11
# Run the component's dev server on :3001
22
# (The Streamlit dev server already runs on :3000)
3-
PORT=3001
4-
5-
# Don't automatically open the web browser on `npm run start`.
6-
BROWSER=none
3+
VITE_PORT=3001

streamlit_bokeh/frontend/public/index.html renamed to streamlit_bokeh/frontend/index.html

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,14 @@
4343
type="font/woff2"
4444
crossorigin
4545
/>
46-
<link rel="stylesheet" href="index.css" />
47-
<script src="bokeh/bokeh-3.8.0.min.js"></script>
48-
<script src="bokeh/bokeh-widgets-3.8.0.min.js"></script>
49-
<script src="bokeh/bokeh-tables-3.8.0.min.js"></script>
50-
<script src="bokeh/bokeh-api-3.8.0.min.js"></script>
51-
<script src="bokeh/bokeh-gl-3.8.0.min.js"></script>
52-
<script src="bokeh/bokeh-mathjax-3.8.0.min.js"></script>
46+
<link rel="stylesheet" href="/src/v1/index.css" />
47+
<script src="%BASE_URL%bokeh/bokeh-3.8.0.min.js"></script>
48+
<script src="%BASE_URL%bokeh/bokeh-widgets-3.8.0.min.js"></script>
49+
<script src="%BASE_URL%bokeh/bokeh-tables-3.8.0.min.js"></script>
50+
<script src="%BASE_URL%bokeh/bokeh-api-3.8.0.min.js"></script>
51+
<script src="%BASE_URL%bokeh/bokeh-gl-3.8.0.min.js"></script>
52+
<script src="%BASE_URL%bokeh/bokeh-mathjax-3.8.0.min.js"></script>
53+
<script type="module" src="/src/v1/index.ts"></script>
5354
</head>
5455
<body>
5556
<noscript>You need to enable JavaScript to run this app.</noscript>

streamlit_bokeh/frontend/package.json

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -4,39 +4,39 @@
44
"version": "3.8.0",
55
"private": true,
66
"dependencies": {
7+
"@streamlit/component-v2-lib": "^0.1.0",
78
"color2k": "^2.0.3",
8-
"react-scripts": "^5.0.1",
99
"streamlit-component-lib": "^2.0.0"
1010
},
1111
"scripts": {
12-
"start": "react-scripts start",
13-
"format": "prettier --write src/**/*.ts",
14-
"build": "react-scripts build",
15-
"test": "react-scripts test --transformIgnorePatterns='node_modules/(?!streamlit-component-lib)/'",
16-
"eject": "react-scripts eject"
17-
},
18-
"eslintConfig": {
19-
"extends": "react-app"
20-
},
21-
"browserslist": {
22-
"production": [
23-
">0.2%",
24-
"not dead",
25-
"not op_mini all"
26-
],
27-
"development": [
28-
"last 1 chrome version",
29-
"last 1 firefox version",
30-
"last 1 safari version"
31-
]
12+
"build:v1": "yarn clean && yarn typecheck && cross-env NODE_ENV=production vite build --config vite.v1.config.ts && yarn copy:bokeh",
13+
"build:v2": "yarn clean && yarn typecheck && cross-env NODE_ENV=production vite build --config vite.v2.config.ts && yarn copy:bokeh",
14+
"build": "yarn clean && yarn typecheck && cross-env NODE_ENV=production vite build --config vite.v1.config.ts && cross-env NODE_ENV=production vite build --config vite.v2.config.ts && yarn copy:bokeh",
15+
"clean": "rimraf build",
16+
"copy:bokeh": "mkdir -p build && cp -R public/bokeh build/",
17+
"dev:v1": "cross-env DEV=1 NODE_ENV=development vite --config vite.v1.config.ts",
18+
"dev:v2": "yarn copy:bokeh && cross-env DEV=1 NODE_ENV=development vite build --config vite.v2.config.ts --watch",
19+
"format": "prettier --write src/**/*.ts vite.*.config.ts vitest.config.ts tsconfig.json index.html",
20+
"test:dev": "vitest",
21+
"test": "vitest --run",
22+
"typecheck": "tsc --noEmit"
3223
},
24+
"browserslist": [
25+
">0.2%",
26+
"not dead",
27+
"not ie <= 11",
28+
"not op_mini all"
29+
],
3330
"homepage": ".",
3431
"devDependencies": {
35-
"@types/jest": "^24.0.0",
36-
"@types/node": "^12.0.0",
32+
"@types/node": "^24.9.2",
33+
"cross-env": "^10.1.0",
34+
"jsdom": "^26.1.0",
3735
"prettier": "^3.4.2",
38-
"typescript": "^4.2.0",
39-
"util": "^0.12.5"
36+
"rimraf": "^6.1.0",
37+
"typescript": "^5.8.3",
38+
"vite": "^6.2.6",
39+
"vitest": "^3.2.4"
4040
},
4141
"packageManager": "[email protected]"
4242
}

streamlit_bokeh/frontend/src/setupTests.js

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,27 +14,25 @@
1414
* limitations under the License.
1515
*/
1616

17-
import { TextEncoder, TextDecoder } from 'util';
17+
import { vi } from "vitest"
1818

19-
Object.assign(global, { TextDecoder, TextEncoder });
20-
21-
const useTheme = jest.fn()
19+
const useTheme = vi.fn()
2220

2321
window.Bokeh = {
2422
Themes: {
25-
"caliber": null,
26-
"dark_minimal": null,
27-
"light_minimal": null,
28-
"contrast": null,
29-
"night_sky": null,
23+
caliber: null,
24+
dark_minimal: null,
25+
light_minimal: null,
26+
contrast: null,
27+
night_sky: null,
3028
},
31-
require: (name) => {
29+
require: name => {
3230
if (name === "core/properties") {
3331
return {
34-
use_theme: useTheme
32+
use_theme: useTheme,
3533
}
3634
}
3735

3836
return {}
39-
}
37+
},
4038
}

streamlit_bokeh/frontend/public/index.css renamed to streamlit_bokeh/frontend/src/v1/index.css

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,19 @@ body {
2222
font-family: "Source Sans Pro";
2323
font-weight: 400;
2424
font-style: normal;
25-
src: url("./fonts/SourceSansPro-Regular.woff2") format("woff2");
25+
src: url("../fonts/SourceSansPro-Regular.woff2") format("woff2");
2626
}
2727

2828
@font-face {
2929
font-family: "Source Sans Pro";
3030
font-weight: 600;
3131
font-style: normal;
32-
src: url("./fonts/SourceSansPro-SemiBold.woff2") format("woff2");
32+
src: url("../fonts/SourceSansPro-SemiBold.woff2") format("woff2");
3333
}
3434

3535
@font-face {
3636
font-family: "Source Sans Pro";
3737
font-weight: 700;
3838
font-style: normal;
39-
src: url("./fonts/SourceSansPro-Bold.woff2") format("woff2");
39+
src: url("../fonts/SourceSansPro-Bold.woff2") format("woff2");
4040
}

streamlit_bokeh/frontend/src/index.test.ts renamed to streamlit_bokeh/frontend/src/v1/index.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
*/
1616

1717
import { Theme } from "streamlit-component-lib"
18+
import { describe, beforeEach, test, expect } from "vitest"
1819

1920
import {
2021
getChartDataGenerator,
File renamed without changes.

streamlit_bokeh/frontend/src/streamlit-theme.ts renamed to streamlit_bokeh/frontend/src/v1/streamlit-theme.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ type AttrValue = string | number
2424
// Bokeh does not export their Theme Class, so we
2525
// simulate close to the class provided by Bokeh
2626
// The relevant class is located here:
27-
// https://github.com/bokeh/bokeh/blob/3.6.2/bokehjs/src/lib/api/themes.ts#L17
27+
// https://github.com/bokeh/bokeh/blob/3.8.0/bokehjs/src/lib/api/themes.ts#L17
2828
class BokehTheme {
2929
readonly attrs: Record<BokehObjectType, Record<AttrName, AttrValue>>
3030

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/**
2+
* Copyright (c) Snowflake Inc. (2025)
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
export default function () {
18+
// This is a placeholder.
19+
}

0 commit comments

Comments
 (0)