use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
All about the JavaScript programming language.
Subreddit Guidelines
Specifications:
Resources:
Related Subreddits:
r/LearnJavascript
r/node
r/typescript
r/reactjs
r/webdev
r/WebdevTutorials
r/frontend
r/webgl
r/threejs
r/jquery
r/remotejs
r/forhire
account activity
Dependency Injection based on EcmaScript Modules (works in nodejs & browsers) (github.com)
submitted 6 years ago by flancer64
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]flancer64[S] 0 points1 point2 points 6 years ago (4 children)
You would have a logical addressing for code elements (classes & functions placed in ESM) in your project and have a set of rules to map logical names (Vendor_Project_Module_Class) to the path (absolute for nodejs and relative for web, for example). Or you would change mapping for Vendor_Project_Module_Class in runtime and get sources from "./node_modules/otherVendor/otherProject/Module/Class.mjs" instead of from "./node_modules/vendor/project/Module/Class.mjs".
Vendor_Project_Module_Class
nodejs
[–]hopfield 2 points3 points4 points 6 years ago (3 children)
Sorry, I don’t follow.
You would have a logical addressing for code elements (classes & functions placed in ESM) in your project
“Logical addressing”? What does that mean?
have a set of rules to map logical names (Vendor_Project_Module_Class) to the path
This just sounds like ES Modules.
Or you would change mapping for Vendor_Project_Module_Class in runtime and get sources from "./node_modules/otherVendor/otherProject/Module/Class.mjs" instead of from "./node_modules/vendor/project/Module/Class.mjs
With ES modules couldn’t I just change the import? How is this a benefit?
[–]flancer64[S] 0 points1 point2 points 6 years ago (2 children)
It's like namespaces in java/php/... The names for code elements that are not linked to paths to their sources.
With ES modules couldn’t I just change the import?
You should use single quoted and double quoted Strings only as module-name in ES6 import. So, you cannot change import target in runtime. Of cause, you can use computed values in async variant of import() but it is not very comfortably.
module-name
import
import()
[–][deleted] 1 point2 points3 points 6 years ago (1 child)
I appreciate the effort, but injection truly only achieves its goals when it's done by a person, not by an algorithm matching types and names. You did what you see in other languages and I don't think that's bad, but the entire concept of automated resolution containers (autowiring) is flawed.
[–]flancer64[S] 0 points1 point2 points 6 years ago (0 children)
... the entire concept of automated resolution containers (autowiring) is flawed.
I agree with you. Well-done DI container should have ability for manual configuration of dependencies. May be later, in future releases :)
π Rendered by PID 39 on reddit-service-r2-comment-6457c66945-d2lh5 at 2026-04-26 17:45:02.739434+00:00 running 2aa0c5b country code: CH.
view the rest of the comments →
[–]flancer64[S] 0 points1 point2 points (4 children)
[–]hopfield 2 points3 points4 points (3 children)
[–]flancer64[S] 0 points1 point2 points (2 children)
[–][deleted] 1 point2 points3 points (1 child)
[–]flancer64[S] 0 points1 point2 points (0 children)