-
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
Usage without Reflect #180
Comments
+1 We have the exact same need. A warning log could be sufficient instead of throwing an error, since it's not true that tsyringe require a reflect polyfill. |
I've had success switching from // main.ts
-import "reflect-metadata";
+import "@abraham/reflection";
// Your code here... |
@shrink the only plus here is that |
I had the same problem when converting a project from a Rollup-based solution to SvelteKit, which uses Vite, which uses ESBuild. I needed to provide the import although it's not needed when using the explicit |
I have found a way to make it work in vite 4+. https://stackblitz.com/edit/vitejs-vite-hzkjj3?file=vite.config.ts |
Here's a system for using TSyringe without decorators at all, by simply making the same calls to It's a work in progress and being used only internally, not packaged in any way. Some inspiration was taken from the source code of VS Code. It also allows for nice autocomplete for dependencies which were registered by name and a shorthand for doing injectWithTransform, injectAll, injectAllWithTransform, e.g. registerClass(MyClass, [
"dep1", // Inject dep1 by id.
["dep2"], // ...array of dep2 by id.
["dep3", getYesNo, ...yesNoArgs], // ...dep3 transformed to bool.
[Dep4, [getId, ...getIdArgs]], // ...dep4 array transformed to string.
YadaProvider, // ...exact type.
]); |
Hey everyone, I have been working on a library called |
Is your feature request related to a problem? Please describe.
I need to install
reflect-metadata
even when ifemitDecoratorMetadata
not used.Description
In some cases
emitDecoratorMetadata
can't work. For example, when usingesbuild
as typescript compiler (which is used in popularVite
).Tsyringe can work in such environment, it just will not interfere injection token (one need to provide token to
@inject
manually), but I still need to install and importreflect-metadata
because oftsyringe requires a reflect polyfill. Please add 'import "reflect-metadata"' to the top of your entry point.
Alternate solutions
I understand why this check is needed in most cases, but maybe you can add a way to tell tsyringe that I don't need a Reflect?
The text was updated successfully, but these errors were encountered: