npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

dynamic-modules

v0.1.0

Published

A tiny lib that imports Typescript modules (services) dynamically with minimal external dependencies(fs-extra).

Downloads

5

Readme

dynamic-ts-modules

A tiny lib that imports Typescript modules (services) dynamically with minimal external dependencies(fs-extra).

At that moment "DynamicLoader" class dynamic import modules. Examples of usage can see in folder "./examples".

How to use "DynamicLoader" class:

General

loadJson

import {DynamicLoader} from "./src/dynamicLoader";

(async () => {
  const someJson = await DynamicLoader.loadJson('./path/to/some.json');
  // do something with loaded json
})().catch(err => {
  // error handler
})

loadModuleByPath

import {DynamicLoader} from "./src/dynamicLoader";

(async () => {
  const someModule= await DynamicLoader.loadModuleByPath('./path/to/some/module');
  // do something with dynamic imported module
})().catch(err => {
  // error handler
})

Examples of using

1. Example of using DynamicLoader with "Coworkers" lib

In folder "./examples" You can see "coworkersApp.ts" source code. For testing this example You must have working AMQP server or use some services in the internet which support this protocol.

Include Your token for AMQP server in "./examples/token.ts" file and run command:

npm run example:coworkers

After this You can publish a massage for "processorFnQueue", "processorFnMakerQueue" or "processorFnFactoryQueue" in AMQP manager.

Result You will see in console when was running "npm run example:coworkers" command

2. Example of using DynamicLoader with "Node.js Express" framework

In folder "./examples" You can see "expressApp.ts" source code. For testing this example just run command:

npm run example:express

After this You can visit "http://localhost:3000" URL or send GET request to this URL by any HTTP Request manager.

Result You will see in Your browser of HTTP Request manager and console when was running "npm run example:express" command.

3. Example of using DynamicLoader with config file and example of service

Loading service
import {DynamicLoader} from "./src/dynamicLoader"; // importing "DynamicLoader" class
import {ISrvConf, Processor, ProcessorTypes} from "./src/types"; // .json config file interface and processor module interface

(async () => {
  const conf = await DynamicLoader.loadJson('./examples/config/services.json');
  
  let dynamicLoader = new DynamicLoader(conf);
  // './examples/config/' - path to dir with config files, at that moment must have all slashes
  
  let service = await dynamicLoader.loadService('service_name'); // service == {config: ISrvConf; processor: Processor; processorType: ProcessorTypes}
})().catch(err => {
  // error handler
})

4. Example of using DynamicLoader with config file and examples of function service, function maker service and function factory service

In folder "./examples" You can see file "processorTypesDemo.ts", just run command:

npm run examples:procs

After that You can see result of work function service, function maker service and function factory service in console where command was running.

Specialized loaders

loadConfig

Using for load config.json file which implements "IConfig" interface. Used in example #3.

import {DynamicLoader} from "./src/dynamicLoader";

(async () => {
  const conf = await DynamicLoader.loadJson('./examples/config/services.json');
  const loader = new DynamicLoader(conf);
  const processorFnServiceJson = await loader.loadConfig('function.service');
})().catch(err => {
  // error handler
})
loadModules

Using for loading modules. Example of using can see in "expressApp.ts" in dynamic loading "handlerFactory".

loadProcessor

Using for loading service's processor in loadService method which used in example #3.

Testing

You can test "DynamicLoader" class using command:

npm test