Skip to content

Commit 08c36d0

Browse files
committed
build(workflows): fix ts-node ESM circular dependency errors
Added a specific ts-node override in tsconfig.json to force CommonJS compilation during tests, bypassing Node 20 strict ESM cycle restrictions (ERR_REQUIRE_CYCLE_MODULE). Updated moduleResolution to node16 to resolve TypeScript deprecation warnings and added missing types.
1 parent b4eb6ed commit 08c36d0

5 files changed

Lines changed: 17 additions & 4 deletions

File tree

workflows/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"build": "tsc -p .",
1111
"fix": "gts fix",
1212
"lint": "gts lint",
13-
"test": "c8 mocha -p -j 2 --loader=ts-node/esm --extension ts --timeout 600000 --exit"
13+
"test": "c8 mocha -p -j 2 --require ts-node/register --extension ts --timeout 600000 --exit"
1414
},
1515
"dependencies": {
1616
"@google-cloud/workflows": "^3.0.0"

workflows/quickstart/tsconfig.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,11 @@
66
"esModuleInterop": true,
77
"moduleResolution": "node16",
88
"module": "node16"
9+
},
10+
"ts-node": {
11+
"compilerOptions": {
12+
"module": "CommonJS",
13+
"types": ["node", "mocha"]
14+
}
915
}
1016
}

workflows/test/create-execution.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ const workflow = 'test-workflow-dont-delete';
2525
describe('create-execution', () => {
2626
it('should create an execution', async () => {
2727
const output = execSync(
28-
`node --loader ts-node/esm ./create-execution.ts ${project} ${location} ${workflow}`
28+
`node --require ts-node/register ./create-execution.ts ${project} ${location} ${workflow}`
2929
);
3030
assert(output.match(/name: projects.*executions.*/));
3131
});

workflows/test/list-workflows.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const location = 'us-central1';
2323
describe('list-workflows', () => {
2424
it('should run list-workflows', async () => {
2525
const output = execSync(
26-
`node --loader ts-node/esm ./list-workflows.ts ${project} ${location}`
26+
`node --require ts-node/register ./list-workflows.ts ${project} ${location}`
2727
);
2828
assert(output.match(/name: projects.*/));
2929
});

workflows/tsconfig.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@
44
"strict": true,
55
"noImplicitAny": false,
66
"esModuleInterop": true,
7-
"moduleResolution": "node"
7+
"moduleResolution": "node16",
8+
"module": "node16"
9+
},
10+
"ts-node": {
11+
"compilerOptions": {
12+
"module": "CommonJS",
13+
"types": ["node", "mocha"]
14+
}
815
}
916
}

0 commit comments

Comments
 (0)