Skip to content

Upgrade svelte#123

Open
narze wants to merge 226 commits intomainfrom
upgrade-svelte
Open

Upgrade svelte#123
narze wants to merge 226 commits intomainfrom
upgrade-svelte

Conversation

@narze
Copy link
Owner

@narze narze commented Feb 15, 2026

Upgrade Svelte from v3 -> v5 and migrate to SvelteKit

https://thwordle-git-upgrade-svelte-notnarze.vercel.app

BaxBak12 and others added 10 commits December 2, 2025 21:01
- Initialize SvelteKit with Svelte 5.49.2
- Create file-based routing structure:
  - / → Daily mode (from App.svelte)
  - /unlimited → Training mode (from Training.svelte)
  - /s/[id] → Special mode (from Special.svelte)
- Update configuration files (svelte.config.js, vite.config.ts, tsconfig.json)
- Update package.json with SvelteKit dependencies:
  - @sveltejs/kit@^2.50.2
  - @sveltejs/adapter-auto@^7.0.0
  - svelte@^5.49.2
  - svelte-check@^4.3.6
  - vite@^7.3.1
  - prettier@^3.8.1, prettier-plugin-svelte@^3.4.1
- Create src/app.html from index.html with meta tags
- Create src/routes/+layout.svelte for root layout
- Replace svelte-share-buttons-component with native share buttons
- Update src/lib/store.ts for SSR compatibility (browser checks)
- Update routes to use SvelteKit navigation:
  - Replace './lib' imports with '' alias
  - Use /stores for page parameters in special route
- Move document.addEventListener into onMount for SSR compatibility
- Update playwright.config.ts to use 'npm run dev'
- Update vitest.config.ts to use SvelteKit vite config
- Remove old files: index.html, vite.config.js
- All three routes verified loading correctly with Playwright
- Update existing tests to use new URL format:
  - tests/e2e-win.spec.ts:  →
  - tests/e2e-lose.spec.ts:  →

- Add tests/smoke-tests.spec.ts with comprehensive coverage:
  - Daily mode loads (main page elements visible)
  - Unlimited mode loads (code display visible)
  - Special mode loads (input field visible)
  - Navigation between modes works (using goto from SvelteKit)
  - Thai keyboard present (44 keys visible)
  - Unlimited restart button hidden initially
  - Special share button hidden initially
  - Thai keyboard interactive (click doesn't error)

- Update src/lib/Navbar.svelte navigation:
  - Replace window.location.href with goto() from SvelteKit
  - Both desktop and mobile menu navigation updated
  - All routes now use proper SvelteKit navigation

- All 8 smoke tests passing (11.2s)
- Verified all three routes load correctly
- Navigation between modes works properly
- Removed document.addEventListener from module level in +page.svelte
- Moved keydown event listener inside onMount lifecycle hook
- This fixes the 'document is not defined' error during SSR
- All three routes (/, /unlimited, /s/[id]) now work correctly
- Build passes without errors
- Added import '../app.css' to src/routes/+layout.svelte
- This fixes TailwindCSS not being loaded
- All components now render with proper styling
- Thai keyboard, header, and social icons properly sized
@vercel
Copy link

vercel bot commented Feb 15, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
thwordle Ready Ready Preview, Comment Feb 15, 2026 6:12am

Request Review

Resolved conflicts by keeping SvelteKit migration changes:
- Kept .gitignore with .svelte-kit/ and package-lock.json
- Removed index.html (replaced by SvelteKit app.html)
- Kept SvelteKit dependencies in package.json
- Kept SvelteKit configuration in svelte.config.js
- Kept all new SvelteKit-specific files (routes, config, tests)
- Removed old Vite-specific files

All changes from main branch (new words, fixes) were already included in the rewritten history.
- Update vitest.config.ts to use browser conditions when running tests
- Add resolve.conditions: ['browser'] to prevent SSR mode during testing
- This fixes 'mount is not available on the server' errors
- All 56 tests now passing

The key was telling Vitest to use browser entry points instead of SSR entry
points when processing Svelte components during tests.
- SvelteKit uses 'static' directory for static files, not 'public'
- Renamed public/ to static/ to match SvelteKit conventions
- Updated test file references from public/ to static/
- words.json now loads correctly at /words.json endpoint
- Import words.json to calculate today's actual word
- Calculate date index to determine which word is today's solution
- Use today's word in the test to handle variable lengths (4-10 characters)
- Added console.log to show which word is being tested
- Test now adapts to daily word changes automatically
- Added 'yarn svelte-kit sync' before running e2e tests
- This generates the .svelte-kit/tsconfig.json required by tsconfig.json
- Fixes 'Cannot find base config file' warning
- Should resolve 404 errors for static files like words.json
- Fixed closeDialogs helper to properly handle both modals:
  - AnnouncementModal: Click the 'ปิด' (close) button specifically
  - Instructions modal: Click anywhere on the dialog
- Updated all test calls to use the new function signature
- All 9 smoke tests now passing
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.