-
Notifications
You must be signed in to change notification settings - Fork 8
Description
Hello! Thank you a lot for the library. I'm trying to apply it to my project, however I have issues with the file extensions in the generated files.
I'm using node 24, which has type stripping and ES module support enabled by default. For ES imports to work the extensions must be specified verbatim. However, the imports from ts-sql-query use .js extension, and my project is written in typescript, so it uses .ts. To make ts-sql-query imports work I have to specify output.import.extension = '.js'. This kind of sort of works, the generated file has
import { Table } from "ts-sql-query/Table.js";
import type { DBConnection } from "../db/connection-source.js";The second import doesn't break immediately, because it is type-only and ignored by node, and typescript picks it up regardless of the extension. However if I add custom fieldMappings, it breaks
// config
fieldMappings: [
{
columnType: 'real',
generatedField: {
type: {
kind: 'customDouble',
dbType: { name: 'real' },
adapter: {
name: 'testDouble', importPath: './test-double.ts', isDefault: true
},
},
},
},
]// generated file
import { Table } from "ts-sql-query/Table.js";
import type { DBConnection } from "../db/connection-source.js";
import testDouble from "../test-double.ts.js"; // This import failsSo the suggestion would be either to always add a .js extension to the ts-sql-query imports (I think this should work with CJS as well?) or apply output.import.extension only to ts-sql-query imports (for all other imports I'm in direct control of the extension anyway, I can specify it explicitly in connectionSource.path or importPath in fieldMappings). Thank you!