Skip to content

RFC: Explore new module structure for luma.gl v10 #2634

Description

@ibgreen-openai

Background

We have been good about modularizing vis.gl frameworks into independent composable modules that

  1. separate logical layers
  2. users can assemble to fit their needs.
  3. help with tree-shaking and bundle size control

However vis.gl also now has a situation where users need to list a lot of vis.gl modules (sometimes dozens) in package.json

  • strict peer dependencies
  • need to specify transitive packages
  • Add to this that v10 is currently heading towards adding even more modules.

Possible New Direction

A notable change since the vis.gl multi-module setup was established is that we now have good support for exports in package.json, meaning that we can have a single npm module export multiple independent entry points.

Using package.json exports could allow us to group logical modules into npm packages. Applied to luma.gl with the intention of reducing the module surface this could look like

@luma.gl/core - Would be the core API and its implementation. A separate module because some users like maplibre want to build their own engine and just use the portable webgpu/webgl abstraction. Proposed exports:

  • @luma.gl/core - The pure abstract device API
  • @luma.gl/core/webgpu - The WebGPU implementation of the abstract core API
  • @luma.gl/core/webgl - The WebGL implementation of the abstract core API
  • @luma.gl/core/webgl-constants or `@luma.gl/core/webgl/constants - The WebGL constants enum and types
  • @luma.gl/core/null - The NullDevice implementation of the abstract core API?

@luma.gl/shadertools - Separate because we keep this as a pure shader textual module

  • @luma.gl/shadertools - ShaderModule, ShaderPass, ShaderPlugin etc
  • @luma.gl/shadertools/modules - shader module implementations
  • @luma.gl/shadertools/effect - shader pass implementations

@luma.gl/engine - Separate higher level classes on top of core.

  • @luma.gl/engine - Core model, AnimationLoop etc
  • @luma.gl/engine/tables
  • @luma.gl/engine/gpgu
  • @luma.gl/engine/arrow
  • @luma.gl/engine/text

@luma.gl/test-utils - Test utilities

No longer needed modules

  • @luma.gl/webgpu - Removed or just re-exports @luma.gl/core/webgpu

  • @luma.gl/webgl - Removed or just re-exports @luma.gl/core/webgl

  • @luma.gl/constants - Removed or just re-exports @luma.gl/core/webgl-constants

  • @luma.gl/tables

  • @luma.gl/gpgu

  • @luma.gl/arrow

  • @luma.gl/text

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions