playcanvas / engine

JavaScript game engine built on WebGL, WebGPU, WebXR and glTF

Home Page:https://playcanvas.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Examples] `npm run develop` slower/bigger than it has to be

kungfooman opened this issue · comments

// Don't include all of 'playcanvas' for these defines, it just
// causes bigger bundles and prolongs the build time by ~3s.
import {
DEVICETYPE_WEBGL2,
DEVICETYPE_WEBGPU,
DEVICETYPE_NULL
} from 'playcanvas';

Previously we had:

// Don't include all of 'playcanvas' for these defines, it just
// causes bigger bundles and prolongs the build time by ~3s.
import {
    DEVICETYPE_WEBGL1, DEVICETYPE_WEBGL2, DEVICETYPE_WEBGPU, DEVICETYPE_NULL
} from 'playcanvas/src/platform/graphics/constants.js';

(hence the comment)

For some reason it was refactored and the comment was neither read nor removed.

The Examples UI doesn't really require PlayCanvas, it's like a fancy UI to pick content for an <iframe>, as the only function is to render the UI. It depends on exactly three constants for the DeviceSelector. These three constants add like 2-3 seconds build time and append an unused extra of ~1.7MB to generate examples/dist/index.js on every Ctrl+S now.

So possible actions are:

  1. Keep it slow and oversized
  2. Reimplement how it was
  3. Just write them out without messing around with the imports, for example:
const DEVICETYPE_NULL = 'null';
const DEVICETYPE_WEBGL2 = 'webgl2';
const DEVICETYPE_WEBGPU = 'webgpu';
  1. Any better ideas?
commented

It shouldn't include the entire of playcanvas on the latest version cos of treeshaking during rollup? I will take a look