From 1b1b9bd98d919b97759244e542af58b3f42a7424 Mon Sep 17 00:00:00 2001 From: Eric Radman Date: Sun, 7 Jan 2024 15:19:58 -0500 Subject: [PATCH] Import all Plotly visualizations (#6673) - Accessible using the Custom chart type - Disable 'fs' and 'path' modules which are available in node, but not on the frontend. Co-authored-by: github-actions Co-authored-by: Guido Petri <18634426+guidopetri@users.noreply.github.com> --- package.json | 4 ++++ viz-lib/package.json | 4 ++++ viz-lib/src/visualizations/chart/plotly/index.ts | 14 +------------- viz-lib/webpack.config.js | 4 ++++ webpack.config.js | 4 ++++ 5 files changed, 17 insertions(+), 13 deletions(-) diff --git a/package.json b/package.json index e4053f5c17..199e7d4668 100644 --- a/package.json +++ b/package.json @@ -178,6 +178,10 @@ "viz-lib/**" ] }, + "browser": { + "fs": false, + "path": false + }, "//": "browserslist set to 'Async functions' compatibility", "browserslist": [ "Edge >= 15", diff --git a/viz-lib/package.json b/viz-lib/package.json index c583df82d9..f926a6906c 100644 --- a/viz-lib/package.json +++ b/viz-lib/package.json @@ -111,5 +111,9 @@ "^@/(.*)": "/$1", "\\.(css|less)$": "identity-obj-proxy" } + }, + "browser": { + "fs": false, + "path": false } } diff --git a/viz-lib/src/visualizations/chart/plotly/index.ts b/viz-lib/src/visualizations/chart/plotly/index.ts index 8680f5f6d7..2300aa8b06 100644 --- a/viz-lib/src/visualizations/chart/plotly/index.ts +++ b/viz-lib/src/visualizations/chart/plotly/index.ts @@ -1,14 +1,4 @@ -import Plotly from "plotly.js/lib/core"; -// @ts-expect-error ts-migrate(7016) FIXME: Could not find a declaration file for module 'plot... Remove this comment to see the full error message -import bar from "plotly.js/lib/bar"; -// @ts-expect-error ts-migrate(7016) FIXME: Could not find a declaration file for module 'plot... Remove this comment to see the full error message -import pie from "plotly.js/lib/pie"; -// @ts-expect-error ts-migrate(7016) FIXME: Could not find a declaration file for module 'plot... Remove this comment to see the full error message -import histogram from "plotly.js/lib/histogram"; -// @ts-expect-error ts-migrate(7016) FIXME: Could not find a declaration file for module 'plot... Remove this comment to see the full error message -import box from "plotly.js/lib/box"; -// @ts-expect-error ts-migrate(7016) FIXME: Could not find a declaration file for module 'plot... Remove this comment to see the full error message -import heatmap from "plotly.js/lib/heatmap"; +import * as Plotly from "plotly.js"; import prepareData from "./prepareData"; import prepareLayout from "./prepareLayout"; @@ -17,8 +7,6 @@ import updateAxes from "./updateAxes"; import updateChartSize from "./updateChartSize"; import { prepareCustomChartData, createCustomChartRenderer } from "./customChartUtils"; -// @ts-expect-error ts-migrate(2339) FIXME: Property 'register' does not exist on type 'typeof... Remove this comment to see the full error message -Plotly.register([bar, pie, histogram, box, heatmap]); // @ts-expect-error ts-migrate(2339) FIXME: Property 'setPlotConfig' does not exist on type 't... Remove this comment to see the full error message Plotly.setPlotConfig({ modeBarButtonsToRemove: ["sendDataToCloud"], diff --git a/viz-lib/webpack.config.js b/viz-lib/webpack.config.js index d716ecd153..9cb95fe46f 100644 --- a/viz-lib/webpack.config.js +++ b/viz-lib/webpack.config.js @@ -15,6 +15,10 @@ module.exports = { resolve: { symlinks: false, extensions: [".js", ".jsx", ".ts", ".tsx"], + fallback: { + fs: false, + path: false + } }, module: { rules: [ diff --git a/webpack.config.js b/webpack.config.js index e256019fb6..1ae282c767 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -75,6 +75,10 @@ const config = { filename: isProduction ? "[name].[chunkhash].js" : "[name].js", publicPath: staticPath }, + node: { + fs: "empty", + path: "empty" + }, resolve: { symlinks: false, extensions: [".js", ".jsx", ".ts", ".tsx"],