fix(server): import bcryptjs via default export for ESM dev runner (#1104)

- bcryptjs is a CommonJS package whose index.js re-exports via
  `module.exports = require("./dist/bcrypt.js")`
- Node's cjs-module-lexer cannot detect named exports through that
  require() indirection, so `import { compare, hash } from 'bcryptjs'`
  threw "Named export 'compare' not found" under the tsx dev runner
  (make dev), even though vitest and the esbuild bundle handled it fine
- switch to the default import and destructure, which works across tsx,
  vitest and the bundled binary
This commit is contained in:
Haozhe 2026-06-25 19:21:17 +08:00 committed by GitHub
parent f059649ce8
commit 77412b89fa
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1,4 +1,6 @@
import { compare, hash } from 'bcryptjs';
import bcrypt from 'bcryptjs';
const { compare, hash } = bcrypt;
const BCRYPT_COST = 12;