Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions app/api/__tests__/safety.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -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()
Expand Down
169 changes: 0 additions & 169 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 0 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -113,9 +112,6 @@
"vitest": "^4.1.11",
"vitest-browser-react": "^2.2.0"
},
"browserslist": [
"defaults"
],
"msw": {
"workerDirectory": [
""
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
6 changes: 6 additions & 0 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Loading