Skip to content

Commit 8d163f9

Browse files
feat(express): enable esModuleInterop to align test and runtime
Enable esModuleInterop: true in modules/express/tsconfig.json to fix CommonJS default-import interop at runtime. Context: Unit tests run via Mocha with tsx, which implicitly provides CJS default-import interop. This allowed `import express from 'express'` to work in tests.The Docker image runs the compiled CJS output without that interop, causing TypeError: (0 , express_1. default) is not a function. Enabling esModuleInterop makes the compiler emit CJS-compatible imports for CJS modules like express, so tests and the Docker runtime execute the same semantics. Notes: Keeps behavior consistent across tsx tests and compiled production artifacts. No API changes; build-time only. TICKET: WP-5759
1 parent 7a63c5b commit 8d163f9

File tree

4 files changed

+4
-3
lines changed

4 files changed

+4
-3
lines changed

modules/express/src/enclavedExpressRoutes/enclavedExpressRoutes.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as superagent from 'superagent';
2-
import * as debug from 'debug';
2+
import debug from 'debug';
33
import * as express from 'express';
44
import { retryPromise } from '../retryPromise';
55

modules/express/test/integration/bitgoExpress.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import 'should-http';
77
import { agent as supertest } from 'supertest';
88
import { DefaultConfig } from '../../src/config';
99
import { app as expressApp } from '../../src/expressApp';
10-
import * as nock from 'nock';
10+
import nock from 'nock';
1111
import { Environments } from '@bitgo/sdk-core';
1212

1313
describe('Bitgo Express', function () {

modules/express/test/integration/externalSigner.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import * as sinon from 'sinon';
77

88
import * as request from 'supertest';
99
import { app as expressApp } from '../../src/expressApp';
10-
import * as nock from 'nock';
10+
import nock from 'nock';
1111
import { Coin, Environments } from 'bitgo';
1212

1313
describe('Custom signing function', () => {

tsconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"inlineSources": true,
99
"lib": ["dom", "es2020"],
1010
"module": "commonjs",
11+
"esModuleInterop": true,
1112
"noFallthroughCasesInSwitch": true,
1213
"noImplicitThis": true,
1314
"resolveJsonModule": true,

0 commit comments

Comments
 (0)