Skip to content

Conversation

@ben-ryder
Copy link
Collaborator

An attempt to migrate to SWC and vitest (with ESM). Current issues:

  • Nest.js dosn't support ESM so might be a dead end in general anyway
  • vitest is much slower (2x) than jest, possibly due to transfomation/processing before tests?
  • test and build commands seem to work ok, but start command fails. Possibly because Nest.js doesn't support ESM, so project is configured as ESM but then compiled code is CJS with base .js extension so fails.

Test speed

vitest (~17 seconds):

 Test Files  24 passed | 1 skipped (25)
      Tests  202 passed | 3 todo (205)
   Start at  17:13:19
   Duration  16.92s (transform 219ms, setup 0ms, collect 9.02s, tests 6.40s, environment 1ms, prepare 43ms)

jest (~8 seconds):

Test Suites: 25 passed, 25 total
Tests:       3 todo, 202 passed, 205 total
Snapshots:   0 total
Time:        7.275 s, estimated 9 s

Start issues with ESM

file:///Users/ben/Development/General/headbase/packages/server/dist/main.js:2
Object.defineProperty(exports, "__esModule", {
                      ^

ReferenceError: exports is not defined in ES module scope
This file is being treated as an ES module because it has a '.js' file extension and '.....headbase/packages/server/package.json' contains "type": "module". To treat it as a CommonJS script, rename it to use the '.cjs' file extension.

@netlify
Copy link

netlify bot commented Nov 20, 2025

Deploy Preview for headbase-app failed.

Name Link
🔨 Latest commit b04b437
🔍 Latest deploy log https://app.netlify.com/projects/headbase-app/deploys/691f4da0d72e070008936a12

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants