implement a Lazy-require to vendetta api

This commit is contained in:
kmmiio99o 2025-12-22 16:21:08 +01:00
parent da0a9bebe4
commit b6de8f1bd3
No known key found for this signature in database
GPG key ID: 13A107AB06ACF9FA

View file

@ -140,10 +140,21 @@ export const initVendettaObject = (): any => {
FluxDispatcher: common.FluxDispatcher,
React: common.React,
ReactNative: common.ReactNative,
moment: require("moment"),
chroma: require("chroma-js"),
lodash: require("lodash"),
util: require("util"),
get moment() {
// Lazy-require heavy libs to avoid pulling them into the startup bundle.
// Consumers access `window.vendetta.common.moment` and this getter will
// require the module on first access.
return require("moment");
},
get chroma() {
return require("chroma-js");
},
get lodash() {
return require("lodash");
},
get util() {
return require("util");
},
},
},
constants: {