diff --git a/packages/grafana-ui/src/components/BigValue/BigValueLayout.tsx b/packages/grafana-ui/src/components/BigValue/BigValueLayout.tsx index eabd079f09f..a5df4c15cd2 100644 --- a/packages/grafana-ui/src/components/BigValue/BigValueLayout.tsx +++ b/packages/grafana-ui/src/components/BigValue/BigValueLayout.tsx @@ -1,7 +1,6 @@ // Libraries -import React, { CSSProperties } from 'react'; +import React, { CSSProperties, Suspense } from 'react'; import tinycolor from 'tinycolor2'; -import { Chart, Geom } from 'bizcharts'; // Utils import { formattedValueToString, DisplayValue, getColorForTheme } from '@grafana/data'; @@ -14,6 +13,16 @@ import { getTextColorForBackground } from '../../utils'; const LINE_HEIGHT = 1.2; const MAX_TITLE_SIZE = 30; +const Chart = React.lazy(async () => { + const { Chart } = await import(/* webpackChunkName: "bizcharts" */ 'bizcharts'); + return { default: Chart }; +}); + +const Geom = React.lazy(async () => { + const { Geom } = await import(/* webpackChunkName: "bizcharts" */ 'bizcharts'); + return { default: Geom }; +}); + export abstract class BigValueLayout { titleFontSize: number; valueFontSize: number; @@ -166,17 +175,19 @@ export abstract class BigValueLayout { } return ( - - {this.renderGeom()} - + Loading chart...}> + + {this.renderGeom()} + + ); } @@ -209,10 +220,10 @@ export abstract class BigValueLayout { lineStyle.stroke = lineColor; return ( - <> + Loading chart...}> - + ); } diff --git a/scripts/webpack/webpack.common.js b/scripts/webpack/webpack.common.js index 23836e2443e..db5df129ecf 100644 --- a/scripts/webpack/webpack.common.js +++ b/scripts/webpack/webpack.common.js @@ -180,6 +180,12 @@ module.exports = { chunks: 'all', minChunks: 1, cacheGroups: { + unicons: { + test: /[\\/]node_modules[\\/]@iconscout[\\/]react-unicons[\\/].*[jt]sx?$/, + chunks: 'initial', + priority: 20, + enforce: true, + }, moment: { test: /[\\/]node_modules[\\/]moment[\\/].*[jt]sx?$/, chunks: 'initial',