Skip to content

Commit

Permalink
Merge pull request #13 from narthur/codegen
Browse files Browse the repository at this point in the history
use .js in imports
  • Loading branch information
narthur committed Apr 11, 2024
2 parents b3f4d6f + 9a39547 commit faa2688
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions src/codegen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ export default async function main(): Promise<void> {
})
.parse(raw);

console.log("Hello from codegen.ts");
console.dir(config);

const outDir = path.join(path.dirname(config.config), config.outDir);
Expand Down Expand Up @@ -55,12 +54,12 @@ export default async function main(): Promise<void> {
//TODO: this may not be correct for all generated files
const typeDef = `export type ${tableName}RowType = ${makeType(fields)}
import { Row } from "${__dirname}/row.ts";
import { Repository } from "./Repository.ts";
import { BaserowSdk } from "${__dirname}/index.ts";
import { Row } from "${__dirname}/row.js";
import { Repository } from "./Repository.js";
import { BaserowSdk } from "${__dirname}/index.js";
${foreignTables
.map((t) => {
return `import { ${t?.name}Row } from "./${t?.name}.ts";`;
return `import { ${t?.name}Row } from "./${t?.name}.js";`;
})
.join("\n")}
Expand All @@ -82,12 +81,12 @@ export class ${tableName}Row extends Row<${tableName}RowType> {
fs.writeFileSync(`${outDir}/${tableName}.ts`, typeDef);
});

const factoryCode = `import { Factory } from '${__dirname}/factory.ts'
import { ListRowsOptions, GetRowOptions } from '${__dirname}/index.ts'
const factoryCode = `import { Factory } from '${__dirname}/factory.js'
import { ListRowsOptions, GetRowOptions } from '${__dirname}/index.js'
${Object.keys(config.tables)
.map(
(tableName) =>
`import { ${tableName}Row, ${tableName}RowType } from './${tableName}.ts';`,
`import { ${tableName}Row, ${tableName}RowType } from './${tableName}.js';`,
)
.join("\n")}
export class Repository extends Factory {
Expand Down

0 comments on commit faa2688

Please sign in to comment.