Skip to content

Commit d270f5e

Browse files
Move to optional dependencies.
1 parent dfe3e45 commit d270f5e

File tree

3 files changed

+26
-8
lines changed

3 files changed

+26
-8
lines changed

packages/x-charts-pro/package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@
4444
"@mui/x-charts-vendor": "workspace:*",
4545
"@mui/x-internals": "workspace:*",
4646
"@mui/x-license": "workspace:*",
47-
"rasterizehtml": "^1.3.1",
4847
"clsx": "^2.1.1",
4948
"prop-types": "^15.8.1"
5049
},
@@ -64,11 +63,15 @@
6463
"optional": true
6564
}
6665
},
66+
"optionalDependencies": {
67+
"rasterizehtml": "^1.3.1"
68+
},
6769
"devDependencies": {
6870
"@mui/material": "^7.0.2",
6971
"@mui/system": "^7.0.2",
7072
"@types/prop-types": "^15.7.14",
7173
"csstype": "^3.1.3",
74+
"rasterizehtml": "^1.3.1",
7275
"react": "^19.0.0",
7376
"react-dom": "^19.0.0",
7477
"rimraf": "^6.0.1"

packages/x-charts-pro/src/internals/plugins/useChartProExport/exportImage.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,15 @@ import { createExportIframe, loadStyleSheets } from './common';
33
import { ChartImageExportOptions } from './useChartProExport.types';
44

55
export const getDrawDocument = async () => {
6-
const module = await import('rasterizehtml');
6+
let module;
7+
try {
8+
module = await import('rasterizehtml');
9+
} catch (error) {
10+
throw new Error(
11+
`MUI X: Failed to import 'rasterizehtml' module. This dependency is mandatory when exporting a chart as an image. Make sure you have it installed as a dependency.`,
12+
{ cause: error },
13+
);
14+
}
715

816
return module.drawDocument;
917
};

pnpm-lock.yaml

Lines changed: 13 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)