0

I want to add a package whenever it is required in my code than adding an optional dependency. Is there any disadvantage of this approach? Example:

this.install('test-package');

Instead of in package.json

"optionalDependencies": {
    "test-package": "^1.0.0"
  },

1 Answers1

0

I have used live-plugin-manager for one of my project worked well.

import {PluginManager} from "live-plugin-manager";

const manager = new PluginManager();

async function run() {
  await manager.install("moment");

  const moment = manager.require("moment");
  console.log(moment().format());

  await manager.uninstall("moment");
}

run();

There are other tools too, I recommend you checking this link if you find anything useful.

Apoorva Chikara
  • 8,277
  • 3
  • 20
  • 35