farmOS / farmOS.js

A JavaScript library for working with farmOS data structures and interacting with farmOS servers.
MIT License
15 stars 13 forks source link

Export client, model and other tools from src/index.js #51

Closed jgaehring closed 2 years ago

jgaehring commented 2 years ago

I've talked about making it possible to use the farmOS.js client w/o the model (and vice versa), and that is indeed possible even today, like so:

import client from 'farmos/src/client';

It's a little cumbersome, however, and moreover it's generally considered poor practice to couple the public API surface to the internal directory structure of a library in this way.

Instead, we can export the client and model from src/index.js,

export { default as model } from './model/index.js';
export { default as client } from './client/index.js';

which can be imported by consumers as:

import { client } from 'farmos';

all while the main farmOS function which combines the two remains the default export.

This can all be achieved rather easily, but I think its worth taking a little more time to weigh which functions/modules we want to expose in this way.