pex-renderer
pex-renderer copied to clipboard
Component namespacing
I miss destructuring a bit
const { components: { lights: { directional: directionalLight } } } =
require("pex-renderer")
Any preference?
- (current)
import {
components,
} from "pex-renderer";
const e = {
directionalLight: components.directionalLight()
}
import {
components,
} from "pex-renderer";
const lights = components.lights
const e = {
directionalLight: components.light.directional()
}
import {
directional as directionalLight,
} from "pex-renderer/components/lights/directional.js";
const lights = components.lights
const e = {
directionalLight: directionalLight()
}
I would avoid 3. (deep import in packages currently cause me more headache and might confuse bundlers), keep pex-renderer exporting components and rely on tree-shaking.
Not sure it is necessary to sub-namespace components so I'd stick with 1.
@simonharrisco mentions option 4. - exposing all components on the top level, also not a bad idea
import { directionalLight } from "pex-renderer"
const e = {
directionalLight: directionalLight()
}
- could simplify export in index.js:
export { default as directionalLight } from "./components/directional-light.js";
// or
export * from "./components/index.js";
and also means only systems are namespaced?
and also means only systems are namespaced?
No, if we move components up then systems too.
and also means only systems are namespaced?
No, if we move components up then systems too.
We'd run into conflict for animation (both component and system) unless systems are suffixed (animationSystem).
Well that was the idea for name-spacing in the first place which looks like brings us back to current option 1.