Giter Site home page Giter Site logo

pluginus's People

Contributors

andreidmt avatar semantic-release-bot avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

pluginus's Issues

Don't create plugin every time it's required as a dependency

Describe

Plugins initialized each time it gets loaded as a dependency.

Reproduce

// plugin 1
module.exports = {
  depend: [],
  create: () => {
    // will log two times
    console.log("Init plugin 1")
  },
}

// plugin 2
module.exports = {
  depend: ["Plugin1"],
  create: Plugin2 => {},
}

// plugin 3
module.exports = {
  depend: ["Plugin1"],
  create: Plugin1 => {},
}

Expected

Plugins should act like singletons, load once and reuse next time it's required by another plugin.

Error: Pluginus: plugin "X" not found as dependency for "Y"

Hi!

I am experiencing an issue that seems to be related to the loading order of dependencies.

The situation is:

PluginA {
  depend: ["PluginB"],
}

PluginB {
  depend: ["PluginA"],
}

That causes the error mentioned in the title. Having a quick look at the code, I see that this piece of code could be the issue:

sort((a, b) => {
  const aHasB = has(b.name, a.depend)
  const bHasA = has(a.name, b.depend)
  if (!aHasB && !bHasA) {
    return a.depend.length > b.depend.length ? 1 : -1
  }
  return bHasA ? -1 : 1
}),

While it can be argued that the code should be decoupled or architectured in a different way, I wanted to raise the issue in case this is a known limitation, there is a workaround, or this is something that need addressing at this level.

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.