Skip to content

Conversation

peterfication
Copy link

Hey @techvlad,

Thanks a lot for your swc/ESBuild setup. I tried it out but couldn't get it to work with the dependency injection of TypeORM. Do you have any ideas whether this could be resolved? I checked out ESBuild and swc but had no luck finding a solution for it :/

Any hints are appreciated :)

This does not work with swc or ESBuild :/
@peterfication peterfication force-pushed the add-module-with-typeorm branch from 635500e to a987fe4 Compare May 14, 2021 12:33
@gozmanyoni
Copy link

@peterfication - I think your module definition(users.module.ts) might be wrong, shouldn't it be?

@Module({ imports: [TypeOrmModule.forFeature([User])], providers: [UsersService], exports: [UsersService], })

@peterfication
Copy link
Author

Yeah, right. But it will still fail on another level: QueryFailedError: SQLITE_ERROR: no such table: user1. (Before it had issues with UserRepository1)

@gozmanyoni
Copy link

@peterfication I think this boils down to configuration issues.

the table wont exist unless you create it or make nest generate it

@peterfication
Copy link
Author

Yes, the table needs to be created, but it shouldn't be called user1 but user. That's the problem here.

@gozmanyoni
Copy link

@peterfication - yep, I haven't worked with typeORM so I don't know what the default behaviour is. doesn't seem right indeed :) you could pass in a table name to the entity attribute to go around that though. so there is a workaround at least.

@gozmanyoni
Copy link

@peterfication - you should be able to retain names and get the table named correctly by modifying the esbuild.transpiler file:

await build({ platform: 'node', target: 'node14', keepNames: true, bundle: false, sourcemap: false, plugins: [await esbuildDecorators({ tsconfig })], entryPoints: [sourceFilePath], outfile: buildFilePath, format: 'cjs', tsconfig, })

See - https://esbuild.github.io/api/#keep-names for more info.

@peterfication
Copy link
Author

Thanks a lot @gozmanyoni, this fixed it for ESBuild.

Also, SWC added an option called keepClassNames which will fix it for SWC.

🎉

@peterfication
Copy link
Author

This resolved it for me 💪

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants