AppView in a box as a Vite plugin thing hatk.dev
2
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix: resolve $hatk alias in tests via Node.js module hooks

scanServerDir uses raw import() which bypasses Vite's resolve.alias.
Register a Node.js module resolve hook in createTestContext so $hatk
resolves to hatk.generated.ts in all contexts.

Also adds resolve.alias in the vite plugin for dev/build consistency.

Bumps to 0.0.1-alpha.27.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

+16 -69
+1 -68
package-lock.json
··· 9 9 "packages/*", 10 10 "docs/site" 11 11 ], 12 - "dependencies": { 13 - "better-sqlite3": "^12.8.0" 14 - }, 15 12 "devDependencies": { 16 13 "@types/node": "^25.3.0", 17 14 "oxfmt": "^0.35.0", ··· 2147 2144 "os": [ 2148 2145 "win32" 2149 2146 ] 2150 - }, 2151 - "node_modules/@playwright/test": { 2152 - "version": "1.58.2", 2153 - "resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.58.2.tgz", 2154 - "integrity": "sha512-akea+6bHYBBfA9uQqSYmlJXn61cTa+jbO87xVLCWbTqbWadRVmhxlXATaOjOgcBaWU4ePo0wB41KMFv3o35IXA==", 2155 - "dev": true, 2156 - "license": "Apache-2.0", 2157 - "dependencies": { 2158 - "playwright": "1.58.2" 2159 - }, 2160 - "bin": { 2161 - "playwright": "cli.js" 2162 - }, 2163 - "engines": { 2164 - "node": ">=18" 2165 - } 2166 2147 }, 2167 2148 "node_modules/@resvg/resvg-js": { 2168 2149 "version": "2.6.2", ··· 7212 7193 "url": "https://github.com/sponsors/jonschlinkert" 7213 7194 } 7214 7195 }, 7215 - "node_modules/playwright": { 7216 - "version": "1.58.2", 7217 - "resolved": "https://registry.npmjs.org/playwright/-/playwright-1.58.2.tgz", 7218 - "integrity": "sha512-vA30H8Nvkq/cPBnNw4Q8TWz1EJyqgpuinBcHET0YVJVFldr8JDNiU9LaWAE1KqSkRYazuaBhTpB5ZzShOezQ6A==", 7219 - "dev": true, 7220 - "license": "Apache-2.0", 7221 - "dependencies": { 7222 - "playwright-core": "1.58.2" 7223 - }, 7224 - "bin": { 7225 - "playwright": "cli.js" 7226 - }, 7227 - "engines": { 7228 - "node": ">=18" 7229 - }, 7230 - "optionalDependencies": { 7231 - "fsevents": "2.3.2" 7232 - } 7233 - }, 7234 - "node_modules/playwright-core": { 7235 - "version": "1.58.2", 7236 - "resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.58.2.tgz", 7237 - "integrity": "sha512-yZkEtftgwS8CsfYo7nm0KE8jsvm6i/PTgVtB8DL726wNf6H2IMsDuxCpJj59KDaxCtSnrWan2AeDqM7JBaultg==", 7238 - "dev": true, 7239 - "license": "Apache-2.0", 7240 - "bin": { 7241 - "playwright-core": "cli.js" 7242 - }, 7243 - "engines": { 7244 - "node": ">=18" 7245 - } 7246 - }, 7247 - "node_modules/playwright/node_modules/fsevents": { 7248 - "version": "2.3.2", 7249 - "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz", 7250 - "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==", 7251 - "dev": true, 7252 - "hasInstallScript": true, 7253 - "license": "MIT", 7254 - "optional": true, 7255 - "os": [ 7256 - "darwin" 7257 - ], 7258 - "engines": { 7259 - "node": "^8.16.0 || ^10.6.0 || >=11.0.0" 7260 - } 7261 - }, 7262 7196 "node_modules/postcss": { 7263 7197 "version": "8.5.8", 7264 7198 "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.8.tgz", ··· 9620 9554 }, 9621 9555 "packages/hatk": { 9622 9556 "name": "@hatk/hatk", 9623 - "version": "0.0.1-alpha.24", 9557 + "version": "0.0.1-alpha.25", 9624 9558 "license": "MIT", 9625 9559 "dependencies": { 9626 9560 "@bigmoves/lexicon": "^0.2.1", ··· 9636 9570 "hatk": "dist/cli.js" 9637 9571 }, 9638 9572 "devDependencies": { 9639 - "@playwright/test": "^1.58.2", 9640 9573 "@types/better-sqlite3": "^7.6.13", 9641 9574 "@types/react": "^19.2.14", 9642 9575 "vite": "^8.0.0"
+1 -1
packages/hatk/package.json
··· 1 1 { 2 2 "name": "@hatk/hatk", 3 - "version": "0.0.1-alpha.26", 3 + "version": "0.0.1-alpha.27", 4 4 "license": "MIT", 5 5 "bin": { 6 6 "hatk": "dist/cli.js"
+14
packages/hatk/src/test.ts
··· 1 1 import { resolve, dirname } from 'node:path' 2 + import { pathToFileURL } from 'node:url' 3 + import { registerHooks } from 'node:module' 2 4 import { readdirSync, readFileSync } from 'node:fs' 3 5 import YAML from 'yaml' 4 6 import { loadConfig, type HatkConfig } from './config.ts' ··· 70 72 * but it will NOT work with --pool=threads (multiple tests sharing a process). 71 73 */ 72 74 export async function createTestContext(): Promise<TestContext> { 75 + // Register Node.js module resolve hook so raw import() of server files 76 + // can resolve the $hatk alias to the generated entry points. 77 + const hatkUrl = pathToFileURL(resolve('hatk.generated.ts')).href 78 + const hatkClientUrl = pathToFileURL(resolve('hatk.generated.client.ts')).href 79 + registerHooks({ 80 + resolve(specifier, context, nextResolve) { 81 + if (specifier === '$hatk/client') return { url: hatkClientUrl, shortCircuit: true } 82 + if (specifier === '$hatk') return { url: hatkUrl, shortCircuit: true } 83 + return nextResolve(specifier, context) 84 + }, 85 + }) 86 + 73 87 const configPath = findConfigPath() 74 88 const config = await loadConfig(configPath) 75 89 const configDir = dirname(resolve(configPath))