Skip to content

Commit 0f4ef1d

Browse files
committed
Migrate to nodenext module resolution for TS 6
TS 6 deprecates moduleResolution: "node". Switch to "nodenext" which matches the runtime: this is an ESM Node.js app ("type": "module" with .js extensions on every import). Side-effects of stricter ESM-aware resolution: - ajv/dist/jtd default-import no longer works against the CJS module shape; switch to the named {Ajv} export. - yaml.load returns unknown, which now propagates through loadSwarmAppConfig; pin its return type to SwarmAppConfig (the Ajv validate guard already narrows it on success). - isolatedModules required for ts-jest under nodenext.
1 parent d6c0236 commit 0f4ef1d

3 files changed

Lines changed: 48 additions & 46 deletions

File tree

package-lock.json

Lines changed: 42 additions & 41 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/swarm-app-config.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import fs from "fs";
33
import {AssertionError} from "assert";
44
import nunjucks from "nunjucks";
55
import {JTDSchemaType} from "ajv/dist/types/jtd-schema.js";
6-
import Ajv from "ajv/dist/jtd.js";
6+
import {Ajv} from "ajv/dist/jtd.js";
77
import {assertObjectOrNull} from "./asserts.js";
88

99
export interface SwarmAppNetworkConfig {
@@ -180,7 +180,7 @@ export const swarmAppConfigSchema: JTDSchemaType<SwarmAppConfig> = {
180180
},
181181
};
182182

183-
export async function loadSwarmAppConfig (configFile: string, throwOnUndefined: boolean, injectHostEnv: boolean | null = true, templatingInputFile: string | null) {
183+
export async function loadSwarmAppConfig (configFile: string, throwOnUndefined: boolean, injectHostEnv: boolean | null = true, templatingInputFile: string | null): Promise<SwarmAppConfig> {
184184
const nunjucksEnv = new nunjucks.Environment(null, {throwOnUndefined});
185185
const nunjucksEnvInput = injectHostEnv ? {env: process.env} : {};
186186
const templatingInput = yaml.load(templatingInputFile ? await fs.promises.readFile(templatingInputFile, "utf8") : "---");

tsconfig.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"compilerOptions": {
33
"target": "ESNext",
4-
"moduleResolution": "node",
5-
"module": "ESNext",
4+
"moduleResolution": "nodenext",
5+
"module": "nodenext",
66
"esModuleInterop": true,
77
"forceConsistentCasingInFileNames": true,
88
"inlineSourceMap": true,
@@ -11,6 +11,7 @@
1111
"skipLibCheck": true,
1212
"noUncheckedIndexedAccess": true,
1313
"noImplicitOverride": true,
14-
"exactOptionalPropertyTypes": true
14+
"exactOptionalPropertyTypes": true,
15+
"isolatedModules": true
1516
}
1617
}

0 commit comments

Comments
 (0)