pmndrs / react-three-jolt

⚡ Jolt physics in React
https://react-three-jolt.pmnd.rs/
MIT License
95 stars 5 forks source link

Should imports be unified? #19

Closed DennisSmolek closed 7 months ago

DennisSmolek commented 7 months ago

Because the library came from my original folder structure and changed often I left imports mostly directly from folders/directories to help understand where they were coming from.

However now that this is a standard library for publishing purposes we use barrel exports this could be shortened.

import { useForwardedRef, useJolt } from '../hooks';
import { getThreeObjectForBody } from '../systems/body-system';
import { vec3 } from '../utils';
import { BodyState } from '../systems';

Could be:

import {  BodyState, getThreeObjectForBody, useForwardedRef, useJolt ,vec3, } from 'src';

The benefit is brevity, but part of me feels it looses a bit of clarity in where things are. Although most code tools will direct/highlight where modules exist..

isaac-mason commented 7 months ago

I think we'll run into issues with circular imports if we do this. I had to remove some similar patterns to fix circular imports in this commit: https://github.com/pmndrs/react-three-jolt/commit/672b08f26a0eae2f2bae66f57ceeac9c03d775ea

DennisSmolek commented 7 months ago

I think we'll run into issues with circular imports if we do this. I had to remove some similar patterns to fix circular imports in this commit: 672b08f

Got it, so for now on and when cleaning up I'll use direct imports where possible.