From ca96f3b4f5079aa7bddd5173096c7c092af8ea04 Mon Sep 17 00:00:00 2001 From: Marcel Gerber Date: Tue, 16 Jul 2024 18:16:34 +0200 Subject: [PATCH] chore(deps): update vite to 5.3 (#3791) --- devTools/tsconfigs/tsconfig.base.json | 1 + package.json | 9 +- .../@ourworldindata/grapher/tsconfig.json | 1 + site/viteUtils.tsx | 16 +- vite.config-common.mts | 5 +- yarn.lock | 875 +++++++++++------- 6 files changed, 538 insertions(+), 369 deletions(-) diff --git a/devTools/tsconfigs/tsconfig.base.json b/devTools/tsconfigs/tsconfig.base.json index fdb79cd62f5..f775dca2c20 100644 --- a/devTools/tsconfigs/tsconfig.base.json +++ b/devTools/tsconfigs/tsconfig.base.json @@ -27,6 +27,7 @@ "jsx": "react", "experimentalDecorators": true, + "useDefineForClassFields": false, "emitDecoratorMetadata": false, "isolatedModules": true diff --git a/package.json b/package.json index 9004c16a7e2..5c9a77f6474 100644 --- a/package.json +++ b/package.json @@ -211,7 +211,7 @@ "@types/workerpool": "^6.1.0", "@typescript-eslint/eslint-plugin": "^7.2.0", "@typescript-eslint/parser": "^7.2.0", - "@vitejs/plugin-react": "^4.1.0", + "@vitejs/plugin-react": "^4.3.1", "@yarnpkg/types": "^4.0.0", "bundlewatch": "^0.3.3", "cypress": "9.3.1", @@ -231,10 +231,9 @@ "sass": "^1.69.5", "tmex": "^1.0.8", "topojson-server": "^3.0.1", - "tsx": "^4.10.2", - "vite": "^4.4.10", - "vite-plugin-checker": "^0.6.4", - "vite-plugin-warmup": "^0.1.0", + "tsx": "^4.16.2", + "vite": "^5.3.4", + "vite-plugin-checker": "^0.7.2", "wrangler": "^3.61.0" }, "prettier": { diff --git a/packages/@ourworldindata/grapher/tsconfig.json b/packages/@ourworldindata/grapher/tsconfig.json index dc50164fc3b..be5326d65b7 100644 --- a/packages/@ourworldindata/grapher/tsconfig.json +++ b/packages/@ourworldindata/grapher/tsconfig.json @@ -1,4 +1,5 @@ { + "extends": "../../../devTools/tsconfigs/tsconfig.base.json", "references": [ { "path": "./tsconfig.src.json" }, { "path": "./tsconfig.test.json" } diff --git a/site/viteUtils.tsx b/site/viteUtils.tsx index 95c113c689a..d447cc87aba 100644 --- a/site/viteUtils.tsx +++ b/site/viteUtils.tsx @@ -7,7 +7,7 @@ import { VITE_PREVIEW, } from "../settings/serverSettings.js" import { POLYFILL_URL } from "./SiteConstants.js" -import type { Manifest } from "vite" +import type { Manifest, ManifestChunk } from "vite" import { sortBy } from "@ourworldindata/utils" import urljoin from "url-join" @@ -97,13 +97,13 @@ export const createTagsForManifestEntry = ( const createTags = (entry: string): React.ReactElement[] => { const manifestEntry = Object.values(manifest).find((e) => e.file === entry) ?? - manifest[entry] + (manifest[entry] as ManifestChunk | undefined) let assets = [] as React.ReactElement[] - if (!manifestEntry) + if (!manifestEntry && !entry.endsWith(".css")) throw new Error(`Could not find manifest entry for ${entry}`) - const assetUrl = urljoin(assetBaseUrl, manifestEntry.file) + const assetUrl = urljoin(assetBaseUrl, manifestEntry?.file ?? entry) if (entry.endsWith(".css")) { assets = [ @@ -118,7 +118,7 @@ export const createTagsForManifestEntry = ( ] } else if (entry.match(/\.[cm]?(js|jsx|ts|tsx)$/)) { // explicitly reference the entry; preload it and its dependencies - if (manifestEntry.isEntry) { + if (manifestEntry?.isEntry) { assets = [ ...assets,