Skip to content

feat: add webgl-only endpoints - #10504

Merged
Pessimistress merged 2 commits into
masterfrom
x/webgpu-endpoint
Aug 4, 2026
Merged

Pessimistress merged 2 commits into
masterfrom
x/webgpu-endpoint

Conversation

@Pessimistress

Copy link
Copy Markdown
Collaborator

Background

Dual-publish core and layer catalogues to a second /webgpu endpoint. The default endpoint will have WGSL source stripped and only supports WebGL. The new endpoint will support both devices. To opt-in WebGPU, an app may just append /webgpu to the import paths, and it prefer creating a WebGPU device if available.

// Default endpoint - WebGL only
import {Deck} from '@deck.gl/core';
import {GeoJsonLayer} from '@deck.gl/layers';
import {TileLayer} from '@deck.gl/geo-layers';
// Opt-in endpoint - WebGPU first
import {Deck} from '@deck.gl/core/webgpu';
import {GeoJsonLayer} from '@deck.gl/layers/webgpu';
import {TileLayer} from '@deck.gl/geo-layers/webgpu';

Change List

  • New TypeScript transform that strips WebGPU assets
  • Monorepo build harness
  • package.json update to add new endpoint
  • Core webgpu entry point: includes webgpuAdapter in default deviceProps

Next Step

  • Standalone bundles that are webgpu enabled

@Pessimistress

Copy link
Copy Markdown
Collaborator Author

As of today, the WebGPU path adds ~400k to supported layers.

@coveralls

coveralls commented Jul 28, 2026 •

Copy link
Copy Markdown

Coverage Status

coverage: 83.752% (+0.004%) from 83.748% — x/webgpu-endpoint into master

@chrisgervang

Copy link
Copy Markdown
Collaborator

400kb or 400k lines?

@ibgreen

ibgreen commented Jul 28, 2026

Copy link
Copy Markdown
Collaborator

Nice exposition.

  • From an ecosystem / vis.gl point of view, I feel that the default import must support both backends, otherwise working with other libraries such as deck.gl-community and luma on top of and below this would become quite painful due to backend restrictions being made by static import paths all over the code base.
  • For the proposal as is, I think offering an optional, opt-in /webgl2 endpoint for a bundle-sensitive app is as far as I would go.

To go further, one idea would be to use vite/webpack/node conditions - these lets the build system pick export path via config, across many modules, (importantly, apps don't need to hard code their import selection with subpaths).

While there are still complications, it is possible that this could make this code splitting approach tolerable.


Conditions proposal

  • Keep ordinary @deck.gl/* imports dual-capable
  • Publish WebGL-only and WebGPU-only artifacts behind package export conditions—not /webgpu subpaths.
  • Let bundle-sensitive applications select a backend once in bundler configuration.

Conceptually:

{
  "exports": {
    ".": {
      "types": "./dist/index.d.ts",
      "deck-gl:webgpu-only": {
        "import": "./dist-webgpu/index.js",
        "require": "./dist-webgpu/index.cjs"
      },
      "deck-gl:webgl-only": {
        "import": "./dist-webgl/index.js",
        "require": "./dist-webgl/index.cjs"
      },
      "import": "./dist/index.js",
      "require": "./dist/index.cjs"
    }
  }
}

Applications retain normal imports:

import {Deck} from '@deck.gl/core';
import {GeoJsonLayer} from '@deck.gl/layers';
import {TileLayer} from '@deck.gl/geo-layers';

A legacy WebGL-only Vite application would configure:

export default defineConfig({
  resolve: {
    conditions: ['deck-gl:webgl-only']
  }
});
  • Webpack similarly supports custom resolve.conditionNames;
  • Node supports --conditions.

These are established conditional-export mechanisms in Vite, Webpack, and Node.

This has several advantages over the current PR:

  • WebGPU remains part of the canonical API.
  • Users make one backend decision rather than modifying every import.
  • The condition propagates through core, layers, geo-layers, and other dependencies automatically.
  • Third-party layers do not have to learn contagious /webgpu paths.

The stripping transform can largely remain an internal build mechanism.

  • The default can be dual/autodetect during migration, then become WebGPU-only in a future major release.

@ibgreen

ibgreen commented Jul 28, 2026

Copy link
Copy Markdown
Collaborator

Also I am a bit worried about dual build times, it is already a heavy repo to work in, some optimization in that regard would be nice.

@Pessimistress

Copy link
Copy Markdown
Collaborator Author

@chrisgervang My bad, that last number was including the webgpu adapter. It should be ~90KB minified.

@Pessimistress

Copy link
Copy Markdown
Collaborator Author

@ibgreen The only doubled up part of the build process is TypeScript transpilation, which is pretty fast.

@Pessimistress Pessimistress changed the title PoC: add webgpu endpoints PoC: add webgl-only endpoints Jul 28, 2026
@Pessimistress

Copy link
Copy Markdown
Collaborator Author

Switched to condition exports.

@chrisgervang

Copy link
Copy Markdown
Collaborator

First I've heard of conditions, I think that's a nice solution for this. I'm generally in favor of the default experience being the most convenient one to use, rather than the most optimal - and this aligns with that prioritization.

As an aside, I wonder if this would be a good option to add to react-map-gl as well in the next major release, since applications tend to use one map or the other (especially for legacy-mapbox).

@ibgreen ibgreen left a comment •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good:

  • The conditional-export direction is preferable to /webgpu subpaths or dynamic shader imports:
  • the normal entry remains WebGPU-capable,
  • while WebGL-only applications get a static graph without runtime chunks (micro-stutters).

deck.gl feedback notes

  • The PR description is stale—it still documents the deleted /webgpu entry points and reversed default behavior. We should replace it with the conditional-export contract and bundler examples.

Complications:

  • Vite's resolve.conditions is non-inheriting, so an example containing only ['deck-gl:webgl-only'] drops Vite's module, browser, and development|production defaults;
  • Webpack likewise needs ['deck-gl:webgl-only', '...'] to retain its defaults.

Is it possible to add package-level validation for both ESM and CommonJS condition resolution?

  • a WebGL render using the alternate output, an output-size/WGSL scan,
  • and a default-build WebGPU test.

deck.gl-community implications

Given the ongoing WebGPU porting work in deck.gl-community, this PR should really be accompanied by a companion PR in that repo, it could add a compatibility matrix or canary integration covering:

  • default deck.gl + community WebGPU shader/browser tests;
  • WebGL-only condition + a community WebGL bundle/render;
  • explicit behavior when a WebGPU device is supplied to a WebGL-only graph.

Until dependent shader-bearing packages adopt the same condition, this should be described as “deck.gl packages without WebGPU assets,” not necessarily an application-wide WebGL-only bundle.

Comment thread package.json
"bootstrap": "yarn && ocular-bootstrap",
"clean": "ocular-clean",
"build": "npm run clean && ocular-build && lerna run build",
"build": "npm run clean && node scripts/set-webgpu-build.mjs false && ocular-build core,extensions,layers,mesh-layers,aggregation-layers,geo-layers && node scripts/move-webgl-output.mjs && node scripts/set-webgpu-build.mjs true && ocular-build && lerna run build",

@ibgreen ibgreen Jul 29, 2026 •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This sequence mutates the tracked root tsconfig.json to includesWebGPU: false, then restores it only after the first build and move succeed. If either step fails, the checkout remains in WebGL-only mode and a later direct build can silently emit the wrong variant. Could we use a separate WebGL-only tsconfig/build option, or run the toggle through a wrapper with try/finally that always restores the canonical configuration.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought about it, then decided that it's not a big deal because the transform does not affect anything but the build process...

Comment thread modules/core/package.json Outdated
"exports": {
".": {
"types": "./dist/index.d.ts",
"deck-gl:webgl-only": {

@ibgreen ibgreen Jul 29, 2026 •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This condition name and behavior need to be treated as an ecosystem contract, not just a deck.gl implementation detail. deck.gl-community is actively adding native WGSL and currently publishes a single distribution.

Resolver conditions only affect packages that implement the same branch, so selecting this condition would strip some deck.gl WGSL while leaving community WGSL and possibly the WebGPU adapter in the application graph.

Before publishing this API, could we decide whether the shared condition should be ecosystem-scoped (for example visgl:webgl-only) or explicitly document that dependent packages should implement deck-gl:webgl-only, and provide reusable build tooling rather than requiring them to copy this private transformer.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer deck-gl if all WebGPU code paths in deck.gl-community eventually are fed into Deck.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or deckgl:webgl-only?

Comment thread scripts/move-webgl-output.mjs Resolved
@Pessimistress

Copy link
Copy Markdown
Collaborator Author

Upstreamed the ts transform to dev-tools

@Pessimistress
Pessimistress marked this pull request as ready for review August 4, 2026 20:28
@Pessimistress

Pessimistress commented Aug 4, 2026 •

Copy link
Copy Markdown
Collaborator Author

Updated after offline discussion:

  • Default endpoint supports both devices
  • Enable condition visgl:webgl-only to drop WebGPU support for better bundle size
Imports Bundle size Compressed Bundle size (WebGL only) Compressed (WebGL only) Comments
Deck + Layer 504.9 kb 146.8 kb 493.6 kb 144.5 kb Minimal core; baseline
DeckGL (React) 13.6 kb 5.2 kb 13.6 kb 5.2 kb
HexagonLayer 50.9 kb 14.4 kb 40.2 kb 12.5 kb
GeoJsonLayer 167.4 kb 46.9 kb 129.6 kb 39.5 kb Includes the most commonly used primitive layers:
ScatterplotLayer, IconLayer, TextLayer, PathLayer, PolygonLayer
MVTLayer 283.4 kb 82.1 kb 245.6 kb 74.6 kb GeoJsonLayer + TileLayer + MVT loader
Tile3DLayer 355.4 kb 106.1 kb 343.9 kb 103.7 kb ScenegraphLayer + SimpleMeshLayer + GLTF loader + 3D tiles loader

@Pessimistress Pessimistress changed the title PoC: add webgl-only endpoints feat: add webgl-only endpoints Aug 4, 2026
@Pessimistress
Pessimistress merged commit 7bcbbd2 into master Aug 4, 2026
5 checks passed
@Pessimistress
Pessimistress deleted the x/webgpu-endpoint branch August 4, 2026 21:39
@chrisgervang chrisgervang added this to the v9.4 milestone Aug 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants