diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f9274313a..5a7c2d813 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -78,9 +78,15 @@ jobs: - name: Build packages run: pnpm exec turbo build --filter='...[origin/${{ github.base_ref }}]' --filter='!gt-next-middleware-e2e' --filter='!./examples/*' + - name: Run typecheck + run: pnpm exec turbo typecheck --filter='...[origin/${{ github.base_ref }}]' --filter='!gt-next-middleware-e2e' --filter='!./examples/*' + - name: Run tests run: pnpm exec turbo test --filter='...[origin/${{ github.base_ref }}]' --filter='!gt-next-middleware-e2e' --filter='!./examples/*' + - name: Run smoke tests + run: pnpm exec turbo smoke --filter='...[origin/${{ github.base_ref }}]' --filter='!gt-next-middleware-e2e' --filter='!./examples/*' + test-builds: strategy: matrix: diff --git a/packages/next/package.json b/packages/next/package.json index c63f7be5f..c3c4aaf53 100644 --- a/packages/next/package.json +++ b/packages/next/package.json @@ -49,7 +49,8 @@ "test:watch": "vitest", "bench": "vitest bench --run --config vitest.config.bench.ts", "bench:unit:json": "vitest bench --run --config vitest.config.bench.ts --outputJson benchmarks/results/unit-latest.json", - "typecheck": "tsc --noEmit" + "typecheck": "tsc --noEmit", + "smoke": "node scripts/smoke.mjs" }, "repository": { "type": "git", diff --git a/packages/next/scripts/smoke.mjs b/packages/next/scripts/smoke.mjs new file mode 100644 index 000000000..e1fed47c0 --- /dev/null +++ b/packages/next/scripts/smoke.mjs @@ -0,0 +1,37 @@ +#!/usr/bin/env node +// Import the built `gt-next/config` entry the way a real next.config does: +// plain Node, no bundler. Catches module-evaluation-time regressions the +// bundled test apps can't (e.g. bare `require`/`__dirname` in the ESM build, +// exports-map paths pointing at files that don't exist). +import { createRequire } from 'node:module'; + +const failures = []; + +try { + const esm = await import('gt-next/config'); + if (typeof esm.withGTConfig !== 'function') { + failures.push('ESM: withGTConfig is not a function'); + } +} catch (error) { + failures.push(`ESM: import('gt-next/config') threw: ${error}`); +} + +try { + const require = createRequire(import.meta.url); + const cjs = require('gt-next/config'); + if (typeof cjs.withGTConfig !== 'function') { + failures.push('CJS: withGTConfig is not a function'); + } +} catch (error) { + failures.push(`CJS: require('gt-next/config') threw: ${error}`); +} + +if (failures.length > 0) { + console.error('gt-next smoke test failed:'); + for (const failure of failures) { + console.error(` - ${failure}`); + } + process.exit(1); +} + +console.warn('gt-next smoke test passed (ESM + CJS config entry)'); diff --git a/turbo.json b/turbo.json index 9eded66da..8b0996434 100644 --- a/turbo.json +++ b/turbo.json @@ -27,6 +27,10 @@ "cache": false, "env": ["VITE_CI_TEST_GT_PROJECT_ID", "VITE_CI_TEST_GT_API_KEY"] }, + "smoke": { + "dependsOn": ["build", "^build"], + "cache": false + }, "test:watch": { "cache": false, "persistent": true