Skip to content

Commit 8d429d3

Browse files
fix(connectivity_check): revert to CommonJS for janus-core compatibility
ES modules don't work well with @racker/janus-core subdirectory imports. Reverting to CommonJS which works reliably with the package. JIRA: PLATEXP-11106
1 parent 2ee2282 commit 8d429d3

4 files changed

Lines changed: 6 additions & 15 deletions

File tree

modules/connectivity_check/lambda/index.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { Socket } from 'node:net';
2-
import { lookup } from 'node:dns/promises';
3-
import * as stats from '@racker/janus-core/lib/stats';
4-
import * as log from '@racker/janus-core/lib/log';
1+
const { Socket } = require('net');
2+
const { lookup } = require('dns/promises');
3+
const stats = require('@racker/janus-core/lib/stats');
4+
const log = require('@racker/janus-core/lib/log');
55

66
interface TestTarget {
77
host: string;
@@ -28,7 +28,7 @@ interface LambdaEvent {
2828
targets: TestTarget[];
2929
}
3030

31-
export const handler = async (event: LambdaEvent): Promise<TestResult[]> => {
31+
exports.handler = async (event: LambdaEvent): Promise<TestResult[]> => {
3232
const env = process.env.ENVIRONMENT || 'unknown';
3333

3434
log.initialize('connectivity-check', {

modules/connectivity_check/lambda/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
{
22
"name": "connectivity-check-lambda",
33
"version": "1.0.0",
4-
"type": "module",
54
"engines": {
65
"node": "~22"
76
},

modules/connectivity_check/lambda/tsconfig.json

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
11
{
22
"compilerOptions": {
33
"target": "ES2022",
4-
"module": "ES2022",
4+
"module": "commonjs",
55
"lib": ["ES2022"],
66
"outDir": ".",
77
"rootDir": ".",
88
"strict": false,
9-
"esModuleInterop": true,
109
"skipLibCheck": true,
11-
"forceConsistentCasingInFileNames": true,
12-
"moduleResolution": "bundler",
1310
"resolveJsonModule": true
1411
},
1512
"include": ["index.ts"],

modules/connectivity_check/scripts/build-lambda.sh

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,6 @@ npm install --no-package-lock
3030
echo "Compiling TypeScript..."
3131
npx tsc
3232

33-
# Fix ES module imports - add /index.js to janus-core subpath imports
34-
echo "Fixing ES module imports..."
35-
sed -i "s|from '@racker/janus-core/lib/stats'|from '@racker/janus-core/lib/stats/index.js'|g" index.js
36-
sed -i "s|from '@racker/janus-core/lib/log'|from '@racker/janus-core/lib/log/index.js'|g" index.js
37-
3833
# Remove TypeScript source and dev dependencies
3934
rm -f index.ts tsconfig.json
4035
npm prune --production

0 commit comments

Comments
 (0)