Skip to content

Commit 4c63fa2

Browse files
staredclaude
andcommitted
Fix build errors for GitHub Pages deployment
- Added --noEmit flag to vue-tsc in build script - Simplified TypeScript configuration to avoid composite project issues - Removed unused imports and variables to fix TypeScript errors - Removed pnpm-workspace.yaml that was causing deployment failures - Successfully tested build locally 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent c46d4c6 commit 4c63fa2

File tree

8 files changed

+262
-33
lines changed

8 files changed

+262
-33
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"type": "module",
66
"scripts": {
77
"dev": "vite",
8-
"build": "vue-tsc && vite build",
8+
"build": "vue-tsc --noEmit && vite build",
99
"preview": "vite preview",
1010
"lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore",
1111
"format": "prettier --write src/"

simplification_ideas.md

Lines changed: 236 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,236 @@
1+
# Simplification Ideas for webr-ggplot2
2+
3+
This document outlines opportunities to simplify the codebase while maintaining all functionality, making it easier to use as a starting point for others.
4+
5+
## Overview
6+
7+
The goal is to reduce complexity by ~40% while keeping the same user experience. This will make the project more approachable for developers who want to:
8+
- Understand how WebR works
9+
- Build their own R-in-browser applications
10+
- Deploy quickly without configuration overhead
11+
12+
## 1. Dependency Reduction
13+
14+
### Remove Unnecessary Packages
15+
- `@monaco-editor/loader` - Monaco is imported directly, loader not needed
16+
- `@rushstack/eslint-patch` - Only needed for complex monorepo setups
17+
- `@tsconfig/node18` - Can use inline TypeScript configuration
18+
- `@vue/tsconfig` - Provides minimal value over direct configuration
19+
- All ESLint packages - While useful, adds complexity for a demo project
20+
- All Prettier packages - Can be optional for those who want it
21+
- `pnpm-workspace.yaml` - Single package project doesn't need workspace
22+
23+
### Keep Only Essential Dependencies
24+
- `vue` - Core framework
25+
- `vite` - Build tool
26+
- `typescript` - Type safety
27+
- `webr` - R runtime in browser
28+
- `monaco-editor` - Code editor
29+
- `@vitejs/plugin-vue` - Vue support for Vite
30+
31+
### Package Manager
32+
- Switch from pnpm to npm for simpler setup
33+
- Remove pnpm-specific configuration files
34+
35+
## 2. Component Consolidation
36+
37+
### Current Structure (6 components)
38+
```
39+
components/
40+
├── CodeEditor.vue
41+
├── ExampleSelector.vue
42+
├── FileUpload.vue
43+
├── LibrarySelector.vue
44+
├── OutputDisplay.vue
45+
└── WebRStatus.vue
46+
```
47+
48+
### Simplified Structure (4 components)
49+
```
50+
components/
51+
├── CodeEditor.vue # R code editor with examples dropdown
52+
├── OutputPanel.vue # Merged console + plots display
53+
├── StatusBar.vue # Merged WebR status + library info
54+
└── FileUpload.vue # CSV upload (unchanged)
55+
```
56+
57+
### Specific Merges
58+
- **WebRStatus + LibrarySelector → StatusBar**: Single component for all status info
59+
- **Console logic from App.vue → OutputPanel**: Centralize output handling
60+
- **ExampleSelector → CodeEditor**: Examples are part of the editor experience
61+
62+
## 3. Configuration Simplification
63+
64+
### TypeScript Configuration
65+
Replace 3 config files with single `tsconfig.json`:
66+
```json
67+
{
68+
"compilerOptions": {
69+
"target": "ES2020",
70+
"module": "ESNext",
71+
"lib": ["ES2020", "DOM"],
72+
"jsx": "preserve",
73+
"moduleResolution": "node",
74+
"strict": true,
75+
"esModuleInterop": true,
76+
"skipLibCheck": true,
77+
"forceConsistentCasingInFileNames": true
78+
},
79+
"include": ["src/**/*"],
80+
"exclude": ["node_modules"]
81+
}
82+
```
83+
84+
### Build Process
85+
- Remove `vue-tsc` type checking from build (keep for dev if desired)
86+
- Simplify scripts in package.json
87+
- Minimal vite.config.ts focused only on CORS headers for WebR
88+
89+
### Remove Configuration Files
90+
- `.eslintrc.cjs`
91+
- `.prettierrc.json`
92+
- `tsconfig.app.json`
93+
- `tsconfig.node.json`
94+
- `pnpm-workspace.yaml`
95+
96+
## 4. Code Pattern Improvements
97+
98+
### Message Handling
99+
- Simplify message types to just: "output", "error", "plot"
100+
- Remove complex message filtering logic
101+
- Centralize all console handling in OutputPanel
102+
103+
### Type Safety
104+
Replace `any` types with proper interfaces:
105+
- WebR instance typing
106+
- Message payload types
107+
- File upload event types
108+
109+
### Remove Workarounds
110+
- Console.error override hack for WebR warnings
111+
- Complex Monaco worker configuration
112+
- Redundant state management between components
113+
114+
### Library Management
115+
- Remove toggle functionality for libraries
116+
- Auto-install required packages (ggplot2, dplyr, ggrepel) on init
117+
- Simpler status display
118+
119+
## 5. CSS and Styling
120+
121+
### Current Issues
122+
- Duplicate styles across components
123+
- Inconsistent spacing and colors
124+
- Complex nested selectors
125+
126+
### Improvements
127+
- Create CSS variables for consistent theming
128+
- Use utility classes for common patterns
129+
- Consolidate similar styles
130+
- Remove unused CSS
131+
132+
## 6. Project Structure
133+
134+
### Simplified Directory Layout
135+
```
136+
webr-ggplot2/
137+
├── src/
138+
│ ├── components/ # 4 consolidated components
139+
│ ├── composables/ # Single useWebR.ts
140+
│ ├── data/ # examples.ts unchanged
141+
│ ├── types/ # Proper TypeScript interfaces
142+
│ ├── App.vue # Cleaner layout component
143+
│ ├── main.ts # Minimal setup
144+
│ └── style.css # Consolidated styles
145+
├── public/ # Static assets
146+
├── index.html # Entry point
147+
├── package.json # Simplified dependencies
148+
├── tsconfig.json # Single TS config
149+
├── vite.config.ts # Minimal Vite config
150+
└── README.md # Clear setup instructions
151+
```
152+
153+
## 7. Setup and Deployment
154+
155+
### Current Setup
156+
```bash
157+
# Install pnpm
158+
npm install -g pnpm
159+
# Install dependencies
160+
pnpm install
161+
# Run dev server
162+
pnpm dev
163+
# Build
164+
pnpm build
165+
```
166+
167+
### Simplified Setup
168+
```bash
169+
# Install and run
170+
npm install
171+
npm run dev
172+
173+
# Build
174+
npm run build
175+
```
176+
177+
### README Improvements
178+
- Quick start section at the top
179+
- Clear explanation of what WebR is
180+
- Simple deployment instructions
181+
- Links to WebR and ggplot2 documentation
182+
183+
## 8. Code Examples
184+
185+
### Simplified useWebR Composable
186+
- Remove redundant state
187+
- Cleaner initialization
188+
- Better error handling
189+
- Typed WebR instance
190+
191+
### Cleaner App.vue
192+
- Remove console logic (moved to OutputPanel)
193+
- Simpler layout structure
194+
- Better responsive design
195+
- Cleaner event handling
196+
197+
## 9. Benefits of Simplification
198+
199+
### For Users
200+
- Faster setup (npm install && npm run dev)
201+
- Easier to understand codebase
202+
- Better starting point for customization
203+
- Fewer things that can go wrong
204+
205+
### For Maintainers
206+
- Less dependencies to update
207+
- Clearer code structure
208+
- Easier to add features
209+
- Better performance
210+
211+
### For Deployment
212+
- Smaller bundle size
213+
- Faster builds
214+
- Works out of the box
215+
- No configuration needed
216+
217+
## 10. Implementation Priority
218+
219+
1. **High Priority**
220+
- Remove unnecessary dependencies
221+
- Consolidate TypeScript configuration
222+
- Merge WebRStatus and LibrarySelector
223+
224+
2. **Medium Priority**
225+
- Consolidate console handling
226+
- Simplify message types
227+
- Fix TypeScript types
228+
229+
3. **Low Priority**
230+
- CSS improvements
231+
- README updates
232+
- Example refinements
233+
234+
## Conclusion
235+
236+
These simplifications will make webr-ggplot2 a cleaner, more approachable example of running R in the browser. The reduced complexity makes it an ideal starting point for developers wanting to build their own WebR-powered applications.

src/App.vue

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ const {
2424
initializeWebR,
2525
executeCode,
2626
uploadCsvData,
27-
clearMessages,
2827
toggleLibrary,
2928
} = useWebR()
3029

src/components/FileUpload.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<script setup lang="ts">
2-
import { ref, computed, onMounted, onUnmounted } from 'vue'
2+
import { ref, onMounted, onUnmounted } from 'vue'
33
import type { CsvData } from '@/types'
44
55
const emit = defineEmits<{

src/components/OutputDisplay.vue

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,8 @@ interface Props {
1010
1111
const props = defineProps<Props>()
1212
13-
const emit = defineEmits<{
14-
clear: []
15-
}>()
16-
1713
const outputRef = ref<HTMLElement>()
1814
19-
const clearOutput = () => {
20-
emit('clear')
21-
}
22-
2315
const scrollToBottom = () => {
2416
nextTick(() => {
2517
if (outputRef.value) {
@@ -42,9 +34,6 @@ const latestPlot = computed(() => {
4234
return plots.length > 0 ? plots[plots.length - 1] : null
4335
})
4436
45-
const textMessages = computed(() => {
46-
return props.messages.filter(message => message.type !== 'plot')
47-
})
4837
4938
watch(
5039
() => props.messages,

src/components/WebRStatus.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ interface Props {
55
loadingStatus: string
66
}
77
8-
const props = defineProps<Props>()
8+
defineProps<Props>()
99
</script>
1010

1111
<template>

tsconfig.app.json

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,3 @@
11
{
2-
"extends": "@vue/tsconfig/tsconfig.dom.json",
3-
"include": ["env.d.ts", "src/**/*", "src/**/*.vue"],
4-
"exclude": ["src/**/__tests__/*"],
5-
"compilerOptions": {
6-
"composite": true,
7-
"baseUrl": ".",
8-
"paths": {
9-
"@/*": ["./src/*"]
10-
}
11-
}
2+
"extends": "./tsconfig.json"
123
}

tsconfig.json

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,25 @@
11
{
2-
"files": [],
3-
"references": [
4-
{
5-
"path": "./tsconfig.node.json"
6-
},
7-
{
8-
"path": "./tsconfig.app.json"
2+
"compilerOptions": {
3+
"target": "ES2020",
4+
"useDefineForClassFields": true,
5+
"module": "ESNext",
6+
"lib": ["ES2020", "DOM", "DOM.Iterable"],
7+
"skipLibCheck": true,
8+
"moduleResolution": "bundler",
9+
"allowImportingTsExtensions": true,
10+
"resolveJsonModule": true,
11+
"isolatedModules": true,
12+
"noEmit": true,
13+
"jsx": "preserve",
14+
"strict": true,
15+
"noUnusedLocals": true,
16+
"noUnusedParameters": true,
17+
"noFallthroughCasesInSwitch": true,
18+
"baseUrl": ".",
19+
"paths": {
20+
"@/*": ["./src/*"]
921
}
10-
]
22+
},
23+
"include": ["src/**/*.ts", "src/**/*.tsx", "src/**/*.vue"],
24+
"exclude": ["node_modules"]
1125
}

0 commit comments

Comments
 (0)