-
Notifications
You must be signed in to change notification settings - Fork 169
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
question: <How to use it with esbuild> #783
Comments
typedi 0.8.0, typescript 4.7.4 + esbuild works ok for me on a project. There are many breaking changes in 0.9.0 - https://github.com/typestack/typedi/blob/develop/CHANGELOG.md#090---20210110 |
And this is why we've switched most of our project to alternative DI libraries. |
What are those alternatives? I'm looking for a good DI library for JS/TS, but most seem to be unmaintained at this point. |
Well, after being a bit miffed about TypeDI, I ended up making a fork: https://github.com/freshgum-bubbles/typedi. I'd say it's pretty feature complete. The API is still technically in beta stage, but it's just a matter of ironing out the interface and adding more features on top of Typestack's TypeDI. It's feature-complete, of course, and I've written up a documentation site for it too: https://typedi.js.org/ |
esbuild states that it doesn't support Decorator Metadata: https://esbuild.github.io/content-types/#no-type-system so I'm not sure how you're getting it to work with that? do you have a transformation step beforehand? Tried removing it and relying on the new stage 3 decorators, available in TS 5.0: https://devblogs.microsoft.com/typescript/announcing-typescript-5-0/#decorators but I get warnings that I can't use @Inject within a constructor: constructor(
@Inject(APP_CONFIG) private appConfig: AppConfig,
) {} I'm guessing to use stage 3 I'd need to refactor that to look like this? constructor() {
this.appConfig = Container.get(APP_CONFIG);
} When I look at the spec for stage 3 decorators: https://github.com/tc39/proposal-decorators#access-and-metadata-sidechanneling It looks like this sort of thing would be supported but I'm not sure if TypeDI supports that? or if stage 3 are supported at all? export class MyService {
@Inject(APP_CONFIG) private appConfig: AppConfig;
constructor() {...}
} Was hoping to use esbuild to speed up build times but constantly running into new walls and the information is so sparse on the subject of modules, decorators etc. This is the frustrating thing when relying on specs that can change... we're stuck in the transition period where I don't really know what's happening, what's working, what's supported or how. It would be great if typedi could add a notice explaining if it depends on stage 2 |
Hi,
I'm trying to use typedi on my project which is written by typescript and build it by using esbuild.
After build bundle using esbuild, there no source code I used @service to inject.
Is there any options or way to use it?
Here are my config option and version.
esbuild : 0.14.41
typescript : 4.6.4
typedi : 0.10.0
tsconfig.js
esbuild
The problem:
The text was updated successfully, but these errors were encountered: