Git Product home page Git Product logo

Comments (3)

aldeed avatar aldeed commented on May 13, 2024 4

I had a thought regarding this. We could make a single @reactioncommerce/meteor-deps package that exports provideDeps and withDeps functions.

In Reaction codebase somewhere:

import { provideDeps } from "@reactioncommerce/meteor-deps";

provideDeps({
  check,
  Tracker,
  // etc.
});

And every NPM package that needs deps would have a peer dependency on @reactioncommerce/meteor-deps and do:

import { withDeps } from "@reactioncommerce/meteor-deps";

withDeps(({
  check,
  Tracker,
  // etc.
}) => {
  // initialize the package
});

The meteor-deps package would just be this:

let deps = {};
let hasDeps = false;
let funcs = [];

export function withDeps(func) {
  if (hasDeps) {
    func(deps);
  } else {
    funcs.push(func);
  }
}

export function provideDeps(userDeps) {
  deps = { ...userDeps };
  funcs.forEach((func) => func(deps));
  funcs = [];
  hasDeps = true;
}

The benefit here is that you'll be able to simply npm install any plugin package and won't need to add any code to make it work. As long as provideDeps is being called with all the deps that all plugins need.

from example-payments-plugin.

zenweasel avatar zenweasel commented on May 13, 2024

@jshimko Great writeup.

This seems like an excellent approach similar to what you and I had talked about. If we get signoff from @spencern should we be able to move forward with building this?

from example-payments-plugin.

spencern avatar spencern commented on May 13, 2024

Good approach @jshimko and I like the suggestion made by @aldeed as well.

This makes sense as a template for migrating plugins to npm, and I think we should probably get on the same page in terms of our priorities for what packages should be migrated first.

from example-payments-plugin.

Related Issues (1)

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.