vivid-planet / comet

Comet DXP

Home Page:https://comet-dxp.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Naming things is hard

nsams opened this issue · comments

Sorry, but I have to bring this on the table again; now we have:

import { FinalFormInput, FinalFormCheckbox } from "@vivid-planet/react-admin";

I'm not very happy with it. Another (not yet discussed) alternative could be:

import { Input, Checkbox } from "@vivid-planet/react-admin-final-form-fields";

(create an own package just for the sake of shorter exports)

This would have to stay:

import { FinalFormDatePicker } from "@vivid-planet/react-admin-date-picker";

An alternative could also be this, we can support both

import { FinalFormInput, FinalFormCheckbox } from "@vivid-planet/react-admin";
import { Input, Checkbox } from "@vivid-planet/react-admin/final-form";

I think it was a good idea to switch into a single core package

yes, another good option

tough I'm not sure if we should export the same thing with two names

import { Input, Checkbox } from "@vivid-planet/react-admin/final-form";

But like this names are not unique within the package and ide support for autoimport might break:

import { Input, Checkbox } from "@vivid-planet/react-admin/final-form";
import { Input, Checkbox } from "@vivid-planet/react-admin";

(which one should be autoimported)

I think both options are equally ok:

like it is now:
import { FinalFormInput, FinalFormCheckbox } from "@vivid-planet/react-admin";
and like suggested by niko:

import { Input, Checkbox } from "@vivid-planet/react-admin-final-form-fields";

though, aesthetics are better in nikos prosposal

with import { Input, Checkbox } from "@vivid-planet/react-admin-final-form-fields"; autoimport breaks the same way as with import { Input, Checkbox } from "@vivid-planet/react-admin/final-form";

but that is not a real problem i'd say, the IDE will present you multiple possible imports and you have to choose.

I don't like the idea of having two packages when there should be only one as they depend on each other. My vote goes for sticking with the FinalForm prefixes.

I don't like the idea of having two packages when there should be only one as they depend on each other. My vote goes for sticking with the FinalForm prefixes.

I think multiple packages because of naming is not an good idea. Prefix or two different export names would be a good alternativ for that

or this could also be an option export the folder into a ns

index.ts
export * as FinalForm from "./final-form"

example.tsx

import { FinalForm } from "@vivid-planet/react-admin";
<FinalForm.Input ... />
import { Input } from "@vivid-planet/react-admin/final-form";
<Input ... />