-
-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Description
Is there an existing issue for this?
- I have searched the existing issues
Current behavior
Summary
Sample 34 (sample/34-using-esm-packages) E2E test fails with superjson 2.2.3
Error Message
expected '{"jsonString":"{"json":{"big":"10"},"meta":{"values":{"big":["bigint"]}}}"}'
got '{"jsonString":"{"json":{"big":"10"},"meta":{"values":{"big":["bigint"]},"v":1}}"}'
superjson 2.2.3 was published to npm on Oct 22, 2025 (06:20 UTC), and CI tests started failing immediately after. The package added a "v": 1 field to the meta object for backward compatibility
Context
- Sample 34 demonstrates how to import and use ESM-only packages in a CommonJS
NestJS project (Node 18.8+) - Uses
superjsonas an example ESM package superjson2.2.3 added a"v": 1field to the meta object (PR A way to create own console commands #311)- Test uses exact JSON string matching, making it fragile to format changes
Minimum reproduction code
https://github.com/nestjs/nest/tree/master/sample/34-using-esm-packages
Steps to reproduce
cd sample/34-using-esm-packagesnpm install(installs superjson 2.2.3 due to"superjson": "2.x")npm run test:e2e- Test fails
Expected behavior
- ESM package is successfully imported
- ESM package functions correctly
- NOT verify superjson's internal serialization format
Better approach example
.expect((res) => {
const result = JSON.parse(res.body.jsonString);
expect(result.json.big).toBe('10');
expect(result.meta.values.big).toEqual(['bigint']);
});NestJS version
11.1.7
Packages versions
{
"@nestjs/common": "11.x",
"@nestjs/core": "11.x",
"@nestjs/platform-express": "11.x",
"superjson": "2.x"
}Node.js version
18.8+
In which operating systems have you tested?
- macOS
- Windows
- Linux
Other
Purpose of Sample 34 is demonstrates importing ESM-only packages in CommonJS NestJS projects using Node 18.8+'s --experimental-vm-modules flag with dynamic imports.
Related
- superjson issue: Input mapping is buggy flightcontrolhq/superjson#310
- superjson PR: fix: input escape mapping flightcontrolhq/superjson#311
Proposed solutions
- Fix test to be format-agnostic (recommended)
- Pin superjson to 2.2.2
- Update expected output to include "v": 1