Skip to content

Commit fd07f2c

Browse files
mattgodboltclaude
andauthored
Migrate from webpack to Vite (#133)
## Summary - Migrate the build system from webpack to Vite to align with jsbeeb dependency - Add support for Monaco editor using vite-plugin-monaco-editor - Fix all tests to work properly with JSDOM environment - Update documentation and configuration files ## Details This PR migrates the Owlet Editor from webpack to Vite. The primary motivation is to align with the jsbeeb dependency, which recently moved to Vite, causing integration challenges. ### Key Changes - Replace webpack configuration with Vite equivalent - Update package.json with Vite dependencies and scripts - Configure Monaco editor with vite-plugin-monaco-editor - Set up proper paths for jsbeeb ROM loading - Fix path resolution for assets and imports - Add test setup for proper JSDOM environment - Update documentation in README.md ### Technical Implementation - Use ESM import syntax throughout the codebase - Implement proper static file copying with vite-plugin-static-copy - Configure LESS preprocessing for styles - Set up source maps for better debugging - Implement favicon generation with vite-plugin-favicon - Document known issue with Monaco editor source maps ## Test Plan - All tests pass with vitest - Development server works as expected with `make run` - Production build generates correctly with `npm run build` - Monaco editor functions properly with syntax highlighting - jsbeeb emulator loads correctly with proper ROM paths ## Known Issues - Minor source map warnings from Monaco editor (documented in README) 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 20ee343 commit fd07f2c

24 files changed

Lines changed: 2116 additions & 5263 deletions

CLAUDE.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# CLAUDE.md
2+
3+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4+
5+
## Build, Lint, Test Commands
6+
- Build: `npm run build` or `make build`
7+
- Start dev server: `npm run dev` or `make run`
8+
- Preview production build: `npm run preview`
9+
- Lint: `npm run lint` or `make lint`
10+
- Lint & fix: `npm run lint-fix` or `make lint-fix`
11+
- Run all tests: `npm run test` or `make test`
12+
- Run specific test: `npx vitest run test/file_name_test.js`
13+
- Run all checks: `make check` (tests + lint-fix)
14+
15+
## Code Style
16+
- Use ESLint + Prettier configuration
17+
- 4-space indentation for JS, 2-space for JSON/YAML/LESS
18+
- camelCase variables/functions, PascalCase for classes
19+
- Use `let`/`const` (not `var`)
20+
- Prefer named ES6 imports
21+
- Add appropriate error handling for file operations
22+
- Follow existing patterns in the codebase
23+
24+
Always run linters before committing to fix formatting issues automatically.

Makefile

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,8 @@ roms: $(ROM_DIR)/gxr.rom
2525
$(ROM_DIR)/gxr.rom: $(NPM_UPDATED)
2626
curl -sL https://mdfs.net/System/ROMs/Graphics/GXR120 -o $@
2727

28-
WEBPACK:=./node_modules/webpack-cli/bin/cli.js
29-
.PHONY: webpack
30-
webpack: prereqs ## Runs webpack (useful only for debugging webpack)
28+
.PHONY: build
29+
build: prereqs ## Builds the project
3130
$(NPM) run build
3231

3332
.PHONY: lint
@@ -52,11 +51,10 @@ clean: ## Cleans up everything
5251

5352
.PHONY: run
5453
run: prereqs ## Runs a local version on port 8080
55-
$(NPM) start
54+
$(NPM) run dev
5655

5756
HASH := $(shell git rev-parse HEAD)
5857
.PHONY: dist
5958
dist: export NODE_ENV=production
60-
dist: export WEBPACK_ARGS=-p
61-
dist: prereqs webpack ## Creates a distribution
59+
dist: prereqs build ## Creates a distribution
6260
echo $(HASH) > dist/git_hash

README.md

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,17 @@ Try the beta now at [bbcmic.ro](https://bbcmic.ro) and get coding!
2626
## To develop
2727

2828
```
29-
$ make run
29+
$ make run # Starts the Vite development server
30+
$ npm run build # Build for production
31+
$ npm run preview # Preview the production build locally
3032
```
3133

32-
then visit http://localhost:8080
34+
Then visit http://localhost:8080
35+
36+
## Build System
37+
38+
Owlet Editor uses Vite as its build system. The project was migrated from webpack to Vite to align with the jsbeeb dependency, which also uses Vite.
39+
40+
## Known Issues
41+
42+
- When running tests, you may see warnings about missing source maps for Monaco Editor. This is a [known issue with Monaco Editor 0.52.0+](https://github.com/microsoft/monaco-editor/issues/4712) and doesn't affect functionality.

eslint.config.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export default [
3535
},
3636
},
3737
{
38-
files: ["**/webpack.config.js"],
38+
files: ["**/webpack.config.js", "**/vite.config.js", "**/test/setup.js", "**/vitest.config.mjs"],
3939

4040
languageOptions: {
4141
globals: {

index.html

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
6+
<title>Owlet BBC BASIC Editor</title>
7+
<link rel="icon" href="/assets/images/owlet.png" type="image/png" />
8+
9+
<%- injectAnalytics ? include(analytics.path) : '' %>
10+
</head>
11+
<body>
12+
<script type="module" src="/src/index.js"></script>
13+
</body>
14+
</html>

0 commit comments

Comments
 (0)