Comments (3)
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.
@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.
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
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from example-payments-plugin.