A platform for community discussion. Free, open, simple.
DEV: Bundle chart.js into a single async chunk (#40796)
David Taylor039e62e5e8e3
diff --git a/frontend/discourse/app/lib/load-chart-js.js b/frontend/discourse/app/lib/load-chart-js.jsindex 3523cddf8f8..f5af8182931 100644--- a/frontend/discourse/app/lib/load-chart-js.js+++ b/frontend/discourse/app/lib/load-chart-js.js@@ -1,8 +1,8 @@import { waitForPromise } from "@ember/test-waiters";export default async function loadChartJS() {- await waitForPromise(import("chartjs-adapter-moment"));- return (await waitForPromise(import("chart.js/auto"))).default;+ return (await waitForPromise(import("discourse/static/chart-js-bundle")))+ .Chart;}/**@@ -10,5 +10,6 @@ export default async function loadChartJS() {* @returns {import("chart.js").Plugin}*/export async function loadChartJSDatalabels() {- return (await waitForPromise(import("chartjs-plugin-datalabels"))).default;+ return (await waitForPromise(import("discourse/static/chart-js-bundle")))+ .ChartDataLabels;}diff --git a/frontend/discourse/app/static/chart-js-bundle.js b/frontend/discourse/app/static/chart-js-bundle.jsnew file mode 100644index 00000000000..c4bdeed2753--- /dev/null+++ b/frontend/discourse/app/static/chart-js-bundle.js@@ -0,0 +1,4 @@+import "chartjs-adapter-moment";++export { default as Chart } from "chart.js/auto";+export { default as ChartDataLabels } from "chartjs-plugin-datalabels";