-
Notifications
You must be signed in to change notification settings - Fork 168
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: Using Typedi with Vite - Returning ContainerInstance2 #966
Comments
I have no experience with vite but the container instance is injected as the last parameter always, so it seems like your service is not recognized for some reason. Could you please setup a repo where we could test? |
I ran into a similar problem, it is because esbuild (it is used under the hood in vite) intentionally does not support emitDecoratorMetadata (evanw/esbuild#257), this causes decorators to not work. I was helped by the solution https://github.com/anatine/esbuildnx/tree/main/packages/esbuild-decorators |
This works for me. import { esbuildDecorators } from '@anatine/esbuild-decorators';
export default defineConfig(() => {
return {
...
optimizeDeps: {
esbuildOptions: {
plugins: [
esbuildDecorators({
tsconfig: 'tsconfig.app.json',
})
],
}
}
};
});
|
I was trying to...
We are using an Nx monorepo for our projects. As Nx included Vite in its most recent release, we wanted to try it out in one of our react projects. The brain of our applications is a library that injects services via typedi, which worked without any problems.
The problem:
Since we changed to Vite, typedi is not injecting the services anymore. One thing i noticed was that instead of returning the Service as expected it returned an Instance of ContainerInstance2. I could not find any explanation why this suddenly occurs?
The text was updated successfully, but these errors were encountered: