Giter Club home page Giter Club logo

Comments (7)

MichalLytek avatar MichalLytek commented on August 16, 2024 1

@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.

idchlife avatar idchlife commented on August 16, 2024

Error says for itself.

from typedi.

pleerock avatar pleerock commented on August 16, 2024

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.

pleerock avatar pleerock commented on August 16, 2024

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.

MichalLytek avatar MichalLytek commented on August 16, 2024

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.

pleerock avatar pleerock commented on August 16, 2024

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.

github-actions avatar github-actions commented on August 16, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.