[Examples] `npm run develop` slower/bigger than it has to be
kungfooman opened this issue · comments
engine/examples/src/app/components/DeviceSelector.mjs
Lines 1 to 7 in 4075e5b
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:
- Keep it slow and oversized
- Reimplement how it was
- Just write them out without messing around with the imports, for example:
const DEVICETYPE_NULL = 'null';
const DEVICETYPE_WEBGL2 = 'webgl2';
const DEVICETYPE_WEBGPU = 'webgpu';
- Any better ideas?
It shouldn't include the entire of playcanvas on the latest version cos of treeshaking during rollup? I will take a look