Comments (7)
@Require()
is great, works like a charm in node. The problem is that people doesn't understand how webpack/browserify works and what they do with require()
functions. So you shouldn't remove it but place warning about browser environment.
I would even like to go futher and extend the decorator to provide an option to inject by require only part of the module which can imitate import { foo } from "bar"
or const { foo } = require("bar")
statements. It would help with mocking in testing when you only use one function/class of a module, like fs
and readFile
.
from typedi.
Error says for itself.
from typedi.
he has this issue most probably because of experimental @Require()
decorator. I think I'll remove this decorator in a near future and he wont have such problems with webpack anymore
from typedi.
The problem is that people doesn't understand how webpack/browserify works
webpack/browserify automatically reads dynamic "require" and tries to replace them. Since we have such decorator it uses "require" and webpack breaks. Its a bad for user because he dont know whats going on.
The problem with @Requre
that its not javascriptish way. I still think I'll remove this decorator. However typedi extendable system allows anyone to create its custom decorator, and its easy to create such @Require
decorator as an extension.
from typedi.
However typedi extendable system allows anyone to create its custom decorator, and its easy to create such @require decorator as an extension.
Yeah, it would be nice. You could remove it from the codebase but leave the note/sample about typedi extensions and how to implement own @Require
.
The same thing would be with routing-controller - should @JWT
be a part of framework like @Session
? What about other decorators? If users should create it by themselves, what about DRY? Maybe we could have sth like a repository for custom extensions? List in docs with links to npm? What do you think @pleerock? 😉
from typedi.
I left @require for now, but its still experimental, maybe will be removed in the future. Also I added docs on how to create a custom decorator in typedi.
from typedi.
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
from typedi.
Related Issues (20)
- question: How do you test your services with dependency injection? HOT 32
- fix: Constructor Injection fail in vitest/jest HOT 3
- question: adding custom proxy traps in class constructors and instances HOT 2
- fix: non-reconstructable services are erased when imported HOT 1
- question: Stage 3 decorator support (available since TS 5.0)
- question: How to debug circular dependency injections ?
- Question: Service Injection working incorrectly HOT 1
- question: is this project/repo dead? HOT 5
- question: <Implementing repository injection using typedi-typeorm.> HOT 3
- question: <Is it possible to adapt your DI to work with modules (not classes)?> HOT 1
- question: HOT 3
- fix: Error when running in bunjs runtime HOT 2
- question: what is the point of Inject if we can use Container.get
- question: Inject Private Property HOT 2
- Using ContainerInstance in the service constructor causes TypeScript build breaks HOT 1
- question: identifier was not found in the container HOT 2
- question: Using typedi with monorepo HOT 3
- question: Using Typedi with Vite - Returning ContainerInstance2 HOT 3
- question: How to define a third-party dependency HOT 5
- question: Using Token with Generics failed in stongly typying
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from typedi.