gltf-pipeline
gltf-pipeline copied to clipboard
Reduce size of final NPM package
If I create a blank folder and type npm install gltf-pipeline
, I end up with about 96 MB downloaded to the folder. Of that, roughly 91 MB sits in node_modules/cesium
. There's a full source tree, plus there are minified and un-minified copies of built Cesium in there, each with its own copy of Natural Earth, Maki, the star map, all the widgets, etc. Almost none of this is used by gltf-pipeline.
I went through gltf-pipeline/lib
and tried to gather up the actual dependency on Cesium. This is what I came up with:
const arrayFill = Cesium.arrayFill;
const Check = Cesium.Check;
const clone = Cesium.clone;
const ComponentDatatype = Cesium.ComponentDatatype;
const defaultValue = Cesium.defaultValue;
const defined = Cesium.defined;
const getMagic = Cesium.getMagic; // for GLB support
const getStringFromTypedArray = Cesium.getStringFromTypedArray;
const isArray = Cesium.isArray;
const isDataUri = Cesium.isDataUri;
const RuntimeError = Cesium.RuntimeError;
const WebGLConstants = Cesium.WebGLConstants;
// Imported by splitPrimitives, but a copy already exists natively in gltf-pipeline.
const numberOfComponentsForType = Cesium.numberOfComponentsForType;
// Vector math is needed for updateVersion.js.
// Also, removeDefault.js needs to test for an identity Matrix4.
const Cartesian3 = Cesium.Cartesian3;
const Cartesian4 = Cesium.Cartesian4;
const Matrix4 = Cesium.Matrix4;
const Quaternion = Cesium.Quaternion;
Size-wise, this is a very small percentage of Cesium, and shouldn't rely on any of Cesium's assets. Is it possible to modify this project to only pull in the parts of Cesium that are actually needed?
I'd love to include gltf-pipeline in the VSCode plugin, but, there are strict size limits for such plugins, and I don't have room for spare copies of Natural Earth and such hanging out in there.
I have a similar problem, except that I'm running this in the browser and the whole cesium package has to be bundled along with gltf-pipeline. So the bundle is too big.
I have a question for the maintainers: How difficult would it be to remove cesium as a dependency? Would a PR be welcome?
+1
This is a great utility, but the size of the cesium
dependency is becoming an issue when trying to keep the bundled output under control (e.g., for a vscode extension).