diff --git a/app/api/__tests__/safety.spec.ts b/app/api/__tests__/safety.spec.ts index d8880069e..daa8abce6 100644 --- a/app/api/__tests__/safety.spec.ts +++ b/app/api/__tests__/safety.spec.ts @@ -11,6 +11,8 @@ import path from 'path' import { expect, it } from 'vitest' +import viteConfigFn from '../../../vite.config' + it('Generated API client version matches API version specified for deployment', () => { const generatedVersion = fs .readFileSync(path.resolve(__dirname, '../__generated__/OMICRON_VERSION'), 'utf8') @@ -40,6 +42,20 @@ it('API_VERSION file matches apiVersion in generated client', () => { expect(match?.[1]).toEqual(apiVersionFile) }) +// tsc is the only thing preventing use of JS APIs missing from our supported +// browsers: Vite's build neither polyfills nor warns about calls to unsupported +// APIs, it only transpiles syntax. So we want to make sure vite and tsc have +// the same target. +it('vite build target matches tsconfig target', () => { + const tsconfig = JSON.parse( + fs.readFileSync(path.resolve(__dirname, '../../../tsconfig.json'), 'utf8') + ) + const viteConfig = viteConfigFn({ mode: 'production', command: 'build' }) + // guard against an undefined === undefined pass if both are removed + expect(tsconfig.compilerOptions.target).toMatch(/^es\d{4}$/) + expect(viteConfig.build?.target).toEqual(tsconfig.compilerOptions.target) +}) + const grepFiles = (s: string) => execSync(`git grep -l "${s}"`) .toString() diff --git a/package-lock.json b/package-lock.json index 56db9c7ec..2cfab2f5a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -70,7 +70,6 @@ "@vitejs/plugin-basic-ssl": "^2.3.0", "@vitejs/plugin-react": "^6.0.2", "@vitest/browser-playwright": "^4.1.11", - "autoprefixer": "^10.4.20", "eslint-plugin-playwright": "^2.10.4", "eslint-plugin-react-hook-form": "^0.3.1", "husky": "^9.1.7", @@ -6059,44 +6058,6 @@ "node": ">=12" } }, - "node_modules/autoprefixer": { - "version": "10.4.20", - "resolved": "https://registry.npmjs.org/autoprefixer/-/autoprefixer-10.4.20.tgz", - "integrity": "sha512-XY25y5xSv/wEoqzDyXXME4AFfkZI0P23z6Fs3YgymDnKJkCGOnkL0iTxCa85UTqaSgfcqyf3UA6+c7wUvx/16g==", - "dev": true, - "funding": [ - { - "type": "opencollective", - "url": "https://opencollective.com/postcss/" - }, - { - "type": "tidelift", - "url": "https://tidelift.com/funding/github/npm/autoprefixer" - }, - { - "type": "github", - "url": "https://github.com/sponsors/ai" - } - ], - "license": "MIT", - "dependencies": { - "browserslist": "^4.23.3", - "caniuse-lite": "^1.0.30001646", - "fraction.js": "^4.3.7", - "normalize-range": "^0.1.2", - "picocolors": "^1.0.1", - "postcss-value-parser": "^4.2.0" - }, - "bin": { - "autoprefixer": "bin/autoprefixer" - }, - "engines": { - "node": "^10 || ^12 || >=14" - }, - "peerDependencies": { - "postcss": "^8.1.0" - } - }, "node_modules/balanced-match": { "version": "4.0.4", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-4.0.4.tgz", @@ -6208,39 +6169,6 @@ "node": ">=8" } }, - "node_modules/browserslist": { - "version": "4.24.2", - "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.24.2.tgz", - "integrity": "sha512-ZIc+Q62revdMcqC6aChtW4jz3My3klmCO1fEmINZY/8J3EpBg5/A/D0AKmBveUh6pgoeycoMkVMko84tuYS+Gg==", - "dev": true, - "funding": [ - { - "type": "opencollective", - "url": "https://opencollective.com/browserslist" - }, - { - "type": "tidelift", - "url": "https://tidelift.com/funding/github/npm/browserslist" - }, - { - "type": "github", - "url": "https://github.com/sponsors/ai" - } - ], - "license": "MIT", - "dependencies": { - "caniuse-lite": "^1.0.30001669", - "electron-to-chromium": "^1.5.41", - "node-releases": "^2.0.18", - "update-browserslist-db": "^1.1.1" - }, - "bin": { - "browserslist": "cli.js" - }, - "engines": { - "node": "^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7" - } - }, "node_modules/bytes": { "version": "3.1.2", "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz", @@ -6318,27 +6246,6 @@ "dev": true, "license": "MIT" }, - "node_modules/caniuse-lite": { - "version": "1.0.30001769", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001769.tgz", - "integrity": "sha512-BCfFL1sHijQlBGWBMuJyhZUhzo7wer5sVj9hqekB/7xn0Ypy+pER/edCYQm4exbXj4WiySGp40P8UuTh6w1srg==", - "dev": true, - "funding": [ - { - "type": "opencollective", - "url": "https://opencollective.com/browserslist" - }, - { - "type": "tidelift", - "url": "https://tidelift.com/funding/github/npm/caniuse-lite" - }, - { - "type": "github", - "url": "https://github.com/sponsors/ai" - } - ], - "license": "CC-BY-4.0" - }, "node_modules/ccount": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/ccount/-/ccount-2.0.1.tgz", @@ -6829,13 +6736,6 @@ "dev": true, "license": "MIT" }, - "node_modules/electron-to-chromium": { - "version": "1.5.68", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.68.tgz", - "integrity": "sha512-FgMdJlma0OzUYlbrtZ4AeXjKxKPk6KT8WOP8BjcqxWtlg8qyJQjRzPJzUtUn5GBg1oQ26hFs7HOOHJMYiJRnvQ==", - "dev": true, - "license": "ISC" - }, "node_modules/encodeurl": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-2.0.0.tgz", @@ -7383,20 +7283,6 @@ "node": ">= 0.6" } }, - "node_modules/fraction.js": { - "version": "4.3.7", - "resolved": "https://registry.npmjs.org/fraction.js/-/fraction.js-4.3.7.tgz", - "integrity": "sha512-ZsDfxO51wGAXREY55a7la9LScWpwv9RxIrYABrlvOFBlH/ShPnrtsXeuUIfXKKOVicNxQ+o8JTbJvjS4M89yew==", - "dev": true, - "license": "MIT", - "engines": { - "node": "*" - }, - "funding": { - "type": "patreon", - "url": "https://github.com/sponsors/rawify" - } - }, "node_modules/framer-motion": { "version": "11.18.2", "resolved": "https://registry.npmjs.org/framer-motion/-/framer-motion-11.18.2.tgz", @@ -8870,23 +8756,6 @@ "node": ">= 0.6" } }, - "node_modules/node-releases": { - "version": "2.0.18", - "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.18.tgz", - "integrity": "sha512-d9VeXT4SJ7ZeOqGX6R5EM022wpL+eWPooLI+5UpWn2jCT1aosUQEhQP214x33Wkwx3JQMvIm+tIoVOdodFS40g==", - "dev": true, - "license": "MIT" - }, - "node_modules/normalize-range": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/normalize-range/-/normalize-range-0.1.2.tgz", - "integrity": "sha512-bdok/XvKII3nUpklnV6P2hxtMNrCboOjAcyBuQnWEhO665FwrSNRxU+AqpsyvO6LgGYPspN+lu5CLtw4jPRKNA==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/object-inspect": { "version": "1.13.4", "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.4.tgz", @@ -9488,13 +9357,6 @@ "node": "^10 || ^12 || >=14" } }, - "node_modules/postcss-value-parser": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/postcss-value-parser/-/postcss-value-parser-4.2.0.tgz", - "integrity": "sha512-1NNCs6uurfkVbeXG4S8JFT9t19m45ICnif8zWLd5oPSZ50QnwMfK+H3jv408d4jw/7Bttv5axS5IiHoLaVNHeQ==", - "dev": true, - "license": "MIT" - }, "node_modules/prelude-ls": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz", @@ -10933,37 +10795,6 @@ "node": ">=8.11" } }, - "node_modules/update-browserslist-db": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.1.1.tgz", - "integrity": "sha512-R8UzCaa9Az+38REPiJ1tXlImTJXlVfgHZsglwBD/k6nj76ctsH1E3q4doGrukiLQd3sGQYu56r5+lo5r94l29A==", - "dev": true, - "funding": [ - { - "type": "opencollective", - "url": "https://opencollective.com/browserslist" - }, - { - "type": "tidelift", - "url": "https://tidelift.com/funding/github/npm/browserslist" - }, - { - "type": "github", - "url": "https://github.com/sponsors/ai" - } - ], - "license": "MIT", - "dependencies": { - "escalade": "^3.2.0", - "picocolors": "^1.1.0" - }, - "bin": { - "update-browserslist-db": "cli.js" - }, - "peerDependencies": { - "browserslist": ">= 4.21.0" - } - }, "node_modules/uplot": { "version": "1.6.32", "resolved": "https://registry.npmjs.org/uplot/-/uplot-1.6.32.tgz", diff --git a/package.json b/package.json index 6d708e350..5c442324e 100644 --- a/package.json +++ b/package.json @@ -95,7 +95,6 @@ "@vitejs/plugin-basic-ssl": "^2.3.0", "@vitejs/plugin-react": "^6.0.2", "@vitest/browser-playwright": "^4.1.11", - "autoprefixer": "^10.4.20", "eslint-plugin-playwright": "^2.10.4", "eslint-plugin-react-hook-form": "^0.3.1", "husky": "^9.1.7", @@ -113,9 +112,6 @@ "vitest": "^4.1.11", "vitest-browser-react": "^2.2.0" }, - "browserslist": [ - "defaults" - ], "msw": { "workerDirectory": [ "" diff --git a/tsconfig.json b/tsconfig.json index 40d709a73..8ffd767c6 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -15,7 +15,7 @@ "@oxide/api-mocks": ["./mock-api/index.ts"] }, "skipLibCheck": true, - "target": "es2023", + "target": "es2024", "types": ["node", "vite/client", "vitest/importMeta"] }, "exclude": ["tools/deno"] diff --git a/vite.config.ts b/vite.config.ts index 3548a6b92..1e2316841 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -96,6 +96,12 @@ const devHeaders = { // see https://vitejs.dev/config/ export default defineConfig(({ mode }) => ({ build: { + // Must match `target` in tsconfig.json: tsc only checks against lib types + // and nothing polyfills missing APIs, so the browser floor and the type + // ceiling have to move together. Vite maps this to the oldest browsers + // with full ES2024 support. We pin it because the default + // (baseline-widely-available) drifts across Vite versions. + target: 'es2024', outDir: resolve(__dirname, 'dist'), emptyOutDir: true, sourcemap: true,