Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API

From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
I once wrote an ESM Loader for my custom flat file system blob thing. Cool times.
-
@Ranchonyx no matter what I do I always end up needing to load modules dynamically. I've written like 30 and every time I'm like "hurrdurr how do". So now I got something I can drag and drop and not think about it
-
rootshell177313h@BordedDev It's niche use, but I tend to have some module system in my prototypes or just free time projects. So this can dynamically load for example DB Models from sub folders without needing to import each model on the top of the file.
In case you are doing something like DDD and have models per module you can load them all into an DBManager or maybe an route collector.
I always end up re-creating it, I don't want to import an nodejs module for this, it's so simple but I end up spending 4 hours due to how finnecky module loading is in nodeJS imo. This saves me an couple of hour on a new project. Thought it was useful so shared. :) -
BordedDev195110h@rootshell AH that sounds very reasonable, I would have done it differently and generated and equivalent of an index.mjs files
I'm so sick and tired of rewriting an ESM loader I gave in and just yeeted an lib.
No external libs, no bundler, no transpiling just some vibe coded crappy thing. But it does what I need to when prototyping.
https://github.com/1338/...
rant