Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions .github/workflows/test-frontend.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ on:
- "src/**"
- "package.json"
- "tsconfig.json"
- "vite.config.ts"
- "package-lock.json"

jobs:
test:
Expand Down Expand Up @@ -55,3 +57,20 @@ jobs:
cache: npm
- run: npm ci
- run: npm run build
# Vite's esbuild pre-bundling can inject __publicField helper calls
# into maplibre-gl, breaking its Web Worker blob creation at runtime.
# Setting build.target and optimizeDeps.esbuildOptions.target to es2022+
# in vite.config.ts prevents this by using native class fields instead.
# This step catches regressions from config changes, Vite/esbuild upgrades,
# or new dependencies that might reintroduce the problem.
# This check can be removed once maplibre-gl no longer creates Web Workers
# from inline blobs, or once Vite drops esbuild pre-bundling entirely.
# See https://github.com/tmshv/sphere/issues/102
- name: Check for __publicField regression
run: |
if grep -r '__publicField' dist/assets/*.js; then
echo "ERROR: __publicField found in build output."
echo "Ensure build.target and optimizeDeps.esbuildOptions.target"
echo "are set to es2022 or higher in vite.config.ts."
exit 1
fi
4 changes: 4 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,10 @@ Available Tauri commands (invoked from frontend via `invoke()`):
| `mbtiles_get_metadata` | Get MBTiles metadata/TileJSON |
| `show_in_finder` | Open file location in system explorer |

## Important Build Constraints

**esbuild target must be es2022+**: Both `build.target` and `optimizeDeps.esbuildOptions.target` in `vite.config.ts` must remain `es2022` or higher. Lower targets cause esbuild to inject `__publicField` helper calls into `maplibre-gl`, breaking its Web Worker blob creation at runtime. `tsconfig.json` `useDefineForClassFields` must stay `false` to match. CI checks the build output for this regression. Future versions of maplibre-gl may fix the inline blob worker approach, making this constraint unnecessary — check when upgrading. See [#102](https://github.com/tmshv/sphere/issues/102).

## Known Issues / Technical Debt

1. **Error handling** - Error types discard context (e.g., `From<io::Error>` returns generic variant without details)
Expand Down
8 changes: 4 additions & 4 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
"compilerOptions": {
"baseUrl": "./",
"paths": {
"@/*": ["src/*"]
"@/*": ["src/*"],
},
"target": "ESNext",
"useDefineForClassFields": true,
"target": "ES2022",
"lib": ["DOM", "DOM.Iterable", "ESNext"],
"allowJs": false,
"skipLibCheck": true,
Expand All @@ -19,7 +19,7 @@
"isolatedModules": true,
"noEmit": true,
"types": ["vitest/globals"],
"jsx": "react-jsx"
"jsx": "react-jsx",
},
"include": ["src"]
"include": ["src"],
}
7 changes: 6 additions & 1 deletion vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,14 @@ export default defineConfig({
// to make use of `TAURI_DEBUG` and other env variables
// https://tauri.studio/v1/api/config#buildconfig.beforedevcommand
envPrefix: ["VITE_", "TAURI_"],
optimizeDeps: {
esbuildOptions: {
target: "es2022",
},
},
build: {
// Tauri supports es2021
target: ["es2021", "chrome100", "safari13"],
target: ["es2022", "safari15"],
// don't minify for debug builds
minify: !process.env.TAURI_DEBUG ? "esbuild" : false,
// produce sourcemaps for debug builds
Expand Down
Loading