axefrog / cycle-router5

A router driver for Cycle.js, wrapping the router5 library
29 stars 4 forks source link

Use default export #2

Closed ivan-kleshnin closed 9 years ago

ivan-kleshnin commented 9 years ago

Minor issue but just as easy to fix.

Currently, your lib exports single function:

export function makeRouterDriver(routes, options) {...}

Which allows two types of imports:

import * as CycleRouter5 from "cycle-router5";
// or
import {makeRouterDriver} from "cycle-router5";

It would be better if the export style was:

function makeRouterDriver(routes, options) {...}

export default {
  makeRouterDriver
};

Which would allow better namespaced import:

import CycleRouter5 from "cycle-router5";

// compare to ugly
// import * as CycleRouter5 from "cycle-router5";

// keeps the same
import {makeRouterDriver} from "cycle-router5";

There is a rule of thumb that every library should always declare a default export to make client code easier. In ES6 we can even combine "default" and "shared" exports in the same module.

axefrog commented 9 years ago

@ivan-kleshnin done, thanks I wasn't overly savvy on the nuances of ES6 module syntax.