From d9324401554d051b9ef9695e13ec70a87f80017e Mon Sep 17 00:00:00 2001 From: Michael Cousins Date: Thu, 6 Feb 2025 12:10:01 -0500 Subject: [PATCH] ci: fix node 16 builds again --- package.json | 4 ++-- scripts/install-dependencies | 18 ++++++++++++------ vite.config.js | 7 +++++++ 3 files changed, 21 insertions(+), 8 deletions(-) diff --git a/package.json b/package.json index 008ee04..77bba08 100644 --- a/package.json +++ b/package.json @@ -103,7 +103,7 @@ "@testing-library/user-event": "^14.5.2", "@typescript-eslint/eslint-plugin": "^8.0.0", "@typescript-eslint/parser": "^8.0.0", - "@vitest/coverage-v8": "^1.0.0 || ^2.0.2", + "@vitest/coverage-v8": "0.x.x || ^1.0.0 || ^2.0.2", "all-contributors-cli": "^6.26.1", "doctoc": "^2.2.1", "esbuild": "*", @@ -128,6 +128,6 @@ "svelte-jester": "^5.0.0", "typescript": "^5.5.3", "vite": "^4.0.0 || ^5.3.3", - "vitest": "^1.0.0 || ^2.0.2" + "vitest": "0.x.x || ^1.0.0 || ^2.0.2" } } diff --git a/scripts/install-dependencies b/scripts/install-dependencies index 029bfdf..8f403a0 100755 --- a/scripts/install-dependencies +++ b/scripts/install-dependencies @@ -1,22 +1,28 @@ #!/usr/bin/env bash # Install dependencies for a given version of Svelte -set -euo pipefail +set -euxo pipefail svelte_version=${1} +node_version=$(node --version) rm -rf node_modules npm install --no-package-lock -if [[ "${svelte_version}" == "4" ]]; then +if [[ "${svelte_version}" == "3" ]]; then + npm uninstall --no-save vite vitest @vitest/coverage-v8 @sveltejs/vite-plugin-svelte svelte-check svelte + npm install --no-save vite@4 vitest@0.x.x @vitest/coverage-v8@0.x.x @sveltejs/vite-plugin-svelte@2 svelte-check@3 svelte@3 +elif [[ "${svelte_version}" == "4" ]]; then npm uninstall --no-save @sveltejs/vite-plugin-svelte svelte npm install --no-save @sveltejs/vite-plugin-svelte@3 svelte@4 -elif [[ "${svelte_version}" == "3" ]]; then - npm uninstall --no-save vite vitest @vitest/coverage-v8 @sveltejs/vite-plugin-svelte svelte-check svelte - npm install --no-save vite@4 vitest@1 @vitest/coverage-v8@1 @sveltejs/vite-plugin-svelte@2 svelte-check@3 svelte@3 +fi + +if [[ "${node_version}" =~ "v16" ]]; then + npm uninstall --no-save vite vitest @vitest/coverage-v8 @sveltejs/vite-plugin-svelte + npm install --no-save vite@4 vitest@0.x.x @vitest/coverage-v8@0.x.x @sveltejs/vite-plugin-svelte@2 fi npm dedupe -installed_version=$(npm ls --depth=0 --parseable svelte@${svelte_version}) +installed_version=$(npm ls --depth=0 --parseable svelte@${svelte_version}) if [[ -z "${installed_version}" ]]; then echo "Error: expected svelte@${svelte_version}" diff --git a/vite.config.js b/vite.config.js index 1ddeea5..2db8a40 100644 --- a/vite.config.js +++ b/vite.config.js @@ -1,8 +1,12 @@ +import { createRequire } from 'node:module' + import { svelte } from '@sveltejs/vite-plugin-svelte' import { defineConfig } from 'vite' import { svelteTesting } from './src/vite.js' +const require = createRequire(import.meta.url) + // https://vitejs.dev/config/ export default defineConfig({ plugins: [svelte(), svelteTesting()], @@ -17,5 +21,8 @@ export default defineConfig({ include: ['src/**/*'], exclude: ['**/__tests__/**', 'src/vite.js', 'src/vitest.js'], }, + alias: { + '@testing-library/svelte': require.resolve('.'), + }, }, })