From c05e3b77a5e6af4ae2477de057a3c35f7f886bf6 Mon Sep 17 00:00:00 2001 From: Shane Jaroch Date: Sat, 10 Jan 2026 16:29:10 -0500 Subject: [PATCH] fix: applying fixes needed for legacy builder plugin --- README.md | 53 +++++++++++++++++++++++++++++--------------------- package.json | 29 +++++++++++++++++---------- vite.config.js | 8 +++++++- 3 files changed, 57 insertions(+), 33 deletions(-) diff --git a/README.md b/README.md index 75842c4..beb186b 100644 --- a/README.md +++ b/README.md @@ -1,38 +1,47 @@ -# sv +# SvelteKit Legacy Template -Everything you need to build a Svelte project, powered by [`sv`](https://github.com/sveltejs/cli). +This project is a SvelteKit template configured for legacy browser support (IE11) using `@vitejs/plugin-legacy`. -## Creating a project +## Setup -If you're seeing this, you've probably already done this step. Congrats! - -```sh -# create a new project in the current directory -npx sv create - -# create a new project in my-app -npx sv create my-app -``` +1. Install dependencies: + ```bash + npm install + # or + pnpm install + ``` ## Developing -Once you've created a project and installed dependencies with `npm install` (or `pnpm install` or `yarn`), start a development server: +Start the development server: -```sh +```bash npm run dev - -# or start the server and open the app in a new browser tab -npm run dev -- --open ``` -## Building +*Note: The development server uses Vite's modern ESM serving and does NOT emulate legacy browsers. To test legacy support, you must build and preview.* + +## Building (Legacy Support) -To create a production version of your app: +To generate the production build, which includes both modern chunks and legacy chunks (transpiled for IE11): -```sh +```bash npm run build ``` -You can preview the production build with `npm run preview`. +This command will: +1. Build the server-side code. +2. Build the client-side code (Modern). +3. Generate potential legacy chunks and polyfills via `@vitejs/plugin-legacy`. + +You will see output indicating `legacy` chunks are being generated. + +## Serving / Previewing + +To serve the built application (production mode) and verify legacy loading: + +```bash +npm run preview +``` -> To deploy your app, you may need to install an [adapter](https://svelte.dev/docs/kit/adapters) for your target environment. +Open the exposed URL (e.g., `http://localhost:4173`) in your legacy browser (e.g., IE11 virtual machine) to verify it loads correctly. diff --git a/package.json b/package.json index dfe4e2c..20f858f 100644 --- a/package.json +++ b/package.json @@ -1,8 +1,9 @@ { - "name": "website-template-svkit-v2-legacy", - "private": true, + "name": "@tg-svelte/website-template-svkit-v2-legacy", "version": "0.0.1", "type": "module", + "description": "SvelteKit v2 website sample/template with IE11 legacy support configuration.", + "private": true, "author": "Shane Jaroch ", "contributors": [ "Tal Hadad " @@ -11,17 +12,25 @@ "dev": "vite dev", "build": "vite build", "preview": "vite preview", - "prepare": "svelte-kit sync || echo ''", "check": "svelte-kit sync && svelte-check --tsconfig ./jsconfig.json", "check:watch": "svelte-kit sync && svelte-check --tsconfig ./jsconfig.json --watch" }, "devDependencies": { - "@sveltejs/adapter-auto": "^7.0.0", - "@sveltejs/kit": "^2.49.1", - "@sveltejs/vite-plugin-svelte": "^6.2.1", - "svelte": "^5.45.6", - "svelte-check": "^4.3.4", - "typescript": "^5.9.3", - "vite": "^7.2.6" + "@sveltejs/adapter-auto": "^3.0.0", + "@sveltejs/kit": "npm:@tg-svelte/kit@^2.49.4", + "@sveltejs/vite-plugin-svelte": "^3.0.0", + "@vitejs/plugin-legacy": "^5.0.0", + "svelte": "^5.0.0-next.1", + "svelte-check": "^3.6.0", + "terser": "^5.0.0", + "vite": "^5.0.0" + }, + "overrides": { + "@sveltejs/kit": "file:../../packages/kit" + }, + "pnpm": { + "overrides": { + "@sveltejs/kit": "file:../../packages/kit" + } } } diff --git a/vite.config.js b/vite.config.js index bbf8c7d..0bab3e1 100644 --- a/vite.config.js +++ b/vite.config.js @@ -1,6 +1,12 @@ import { sveltekit } from '@sveltejs/kit/vite'; import { defineConfig } from 'vite'; +import legacy from '@vitejs/plugin-legacy'; export default defineConfig({ - plugins: [sveltekit()] + plugins: [ + legacy({ + targets: ['ie 11'] + }), + sveltekit() + ] }); -- 2.52.0