analog: Can't run tests with newest update (1.9.2)

Please provide the environment you discovered this bug in.

We use nx with analog vitest

Which area/package is the issue in?

vitest-angular

Description

Everytime I run the tests I get the error:

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 '/Users/reneachtelik/workspace/fhp-bike/node_modules/.pnpm/@analogjs+vitest-angular@1.9.2_@analogjs+vite-plugin-angular@1.9.2_@angular-devkit+build-angu_tfhrvuljhjniigrh7pmftb3w5m/node_modules/@analogjs/vitest-angular/package.json' contains "type": "module". To treat it as a CommonJS script, rename it to use the '.cjs' file extension.
 ❯ ../../../node_modules/.pnpm/@analogjs+vitest-angular@1.9.2_@analogjs+vite-plugin-angular@1.9.2_@angular-devkit+build-angu_tfhrvuljhjniigrh7pmftb3w5m/node_modules/@analogjs/vitest-angular/setup-zone.js:2:23
      1| "use strict";
      2| Object.defineProperty(exports, "__esModule", { value: true });
       |                       ^
      3| require("zone.js");
      4| require("zone.js/plugins/sync-test");
 ❯ src/test-setup.ts:1:1

project is esm only.

Please provide the exception or error you saw

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 '/Users/reneachtelik/workspace/fhp-bike/node_modules/.pnpm/@analogjs+vitest-angular@1.9.2_@analogjs+vite-plugin-angular@1.9.2_@angular-devkit+build-angu_tfhrvuljhjniigrh7pmftb3w5m/node_modules/@analogjs/vitest-angular/package.json' contains "type": "module". To treat it as a CommonJS script, rename it to use the '.cjs' file extension.
 ❯ ../../../node_modules/.pnpm/@analogjs+vitest-angular@1.9.2_@analogjs+vite-plugin-angular@1.9.2_@angular-devkit+build-angu_tfhrvuljhjniigrh7pmftb3w5m/node_modules/@analogjs/vitest-angular/setup-zone.js:2:23
      1| "use strict";
      2| Object.defineProperty(exports, "__esModule", { value: true });
       |                       ^
      3| require("zone.js");
      4| require("zone.js/plugins/sync-test");
 ❯ src/test-setup.ts:1:1

Other information

Happens only with the newest update

I would be willing to submit a PR to fix this issue

  • Yes
  • No

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 15 (10 by maintainers)

Most upvoted comments

Analog 1.9.3 is released with the fix

Is this Nx 20?

Yes, sorry, thought I’ve included the NX Report, will do this later

Also all my vite configs are named .mts

I also use

https://github.com/jscutlery/devkit/releases/tag/swc-angular-0.16.2

Tried running without it and this threw an error as well. But something about missing snapshotSerializer. I’m in a hurry and will add more details later.

Again, sorry for the half-assed issue