Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/codegen-core/tsconfig.base.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"noUnusedLocals": true,
"noUnusedParameters": true,
"strict": true,
"target": "ES2022",
"target": "ES2021",
"useUnknownInCatchVariables": false
}
}
1 change: 1 addition & 0 deletions packages/codegen-core/tsup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,6 @@ export default defineConfig((options) => ({
minify: !options.watch,
shims: false,
sourcemap: true,
target: 'node18',
treeshake: true,
}));
3 changes: 2 additions & 1 deletion packages/openapi-ts/bin/index.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,8 @@ async function start() {
) {
process.exit(0);
}
} catch {
} catch (error) {
console.error(error);
process.exit(1);
}
}
Expand Down
77 changes: 77 additions & 0 deletions packages/openapi-ts/src/config/__tests__/engine.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
import fs from 'node:fs';
import path from 'node:path';

import { describe, expect, it } from 'vitest';

import { checkNodeVersion } from '../engine';

describe('engine config', () => {
describe('checkNodeVersion', () => {
it('should not throw error for Node 18+', () => {
expect(() => checkNodeVersion()).not.toThrow();
});
});

describe('Node 18 compatibility', () => {
it('should have TypeScript target set to ES2021 for Node 18 compatibility', () => {
const tsconfigPath = path.resolve(
__dirname,
'..',
'..',
'..',
'tsconfig.base.json',
);
const tsconfig = JSON.parse(fs.readFileSync(tsconfigPath, 'utf8'));

// ES2021 is required for Node 18 compatibility
// ES2022 includes features like Object.hasOwn that are not available in Node 18
expect(tsconfig.compilerOptions.target).toBe('ES2021');
});

it('should have tsup target set to node18 for Node 18 compatibility', () => {
const tsupConfigPath = path.resolve(
__dirname,
'..',
'..',
'..',
'tsup.config.ts',
);
const tsupConfig = fs.readFileSync(tsupConfigPath, 'utf8');

// tsup/esbuild needs explicit node18 target to ensure compiled output works on Node 18
expect(tsupConfig).toContain("target: 'node18'");
});

it('should have TypeScript target set to ES2021 in codegen-core for Node 18 compatibility', () => {
const tsconfigPath = path.resolve(
__dirname,
'..',
'..',
'..',
'..',
'codegen-core',
'tsconfig.base.json',
);
const tsconfig = JSON.parse(fs.readFileSync(tsconfigPath, 'utf8'));

// ES2021 is required for Node 18 compatibility
expect(tsconfig.compilerOptions.target).toBe('ES2021');
});

it('should have tsup target set to node18 in codegen-core for Node 18 compatibility', () => {
const tsupConfigPath = path.resolve(
__dirname,
'..',
'..',
'..',
'..',
'codegen-core',
'tsup.config.ts',
);
const tsupConfig = fs.readFileSync(tsupConfigPath, 'utf8');

// tsup/esbuild needs explicit node18 target to ensure compiled output works on Node 18
expect(tsupConfig).toContain("target: 'node18'");
});
});
});
2 changes: 1 addition & 1 deletion packages/openapi-ts/tsconfig.base.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"noUnusedLocals": true,
"noUnusedParameters": true,
"strict": true,
"target": "ES2022",
"target": "ES2021",
"useUnknownInCatchVariables": false
}
}
1 change: 1 addition & 0 deletions packages/openapi-ts/tsup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,5 +72,6 @@ export default defineConfig((options) => ({
},
shims: false,
sourcemap: true,
target: 'node18',
treeshake: true,
}));
Loading