PromucFlow_constructor/app/client/src/utils/importUppy.ts
Ivan Akulov 8a1870daa6
perf: reduce the bundle size, vol. 2 (#24969)
Co-authored-by: Tanvi Bhakta <tanvibhakta@gmail.com>
Co-authored-by: Satish Gandham <hello@satishgandham.com>
2023-07-17 00:19:41 +05:30

37 lines
1.2 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// Were setting this flag to true when we know for sure the Uppy module was loaded and initialized.
// When its `true`, the other modules will know that the importUppy function will resolve immediately
// (in the next tick). They can use it to e.g. decide whether to show the loading spinner
export let isUppyLoaded = false;
export async function importUppy() {
const [Uppy, Dashboard, GoogleDrive, OneDrive, Url, Webcam] =
await Promise.all([
import(/* webpackChunkName: "uppy" */ "@uppy/core").then(
(m) => m.default,
),
import(/* webpackChunkName: "uppy" */ "@uppy/dashboard").then(
(m) => m.default,
),
import(/* webpackChunkName: "uppy" */ "@uppy/google-drive").then(
(m) => m.default,
),
import(/* webpackChunkName: "uppy" */ "@uppy/onedrive").then(
(m) => m.default,
),
import(/* webpackChunkName: "uppy" */ "@uppy/url").then((m) => m.default),
import(/* webpackChunkName: "uppy" */ "@uppy/webcam").then(
(m) => m.default,
),
]);
isUppyLoaded = true;
return {
Uppy,
Dashboard,
GoogleDrive,
OneDrive,
Url,
Webcam,
};
}