Package conditional import


#1

I want to write a small module/package that is supposed to work with FlowRouter. It can work with either kadira:flow-router or ostrio:flow-router-extra. How can I make it conditional on which package a project has installed?


#2

I believe the recommended way to check for a meteor package is using the Package global which acts as the package registry.

let FlowRouter;
if (Package['ostrio:flow-router-extra']) {
    FlowRouter = Package['ostrio:flow-router-extra'].FlowRouter;
} else if (Package['kadira:flow-router']) {
    FlowRouter = Package['kadira:flow-router'].FlowRouter;
}

It’s very quietly mentioned in the docs for weak dependencies here:


#3

Brilliant. Check out my package jamgold:flow-animate-css


#4

Very nice, I’d been looking for something like this!


#5

Let me know if the sparse README is enough for you to get it working