使用
yarn
我最近将 @superset-ui/embedded-sdk
库添加到我使用 webpack 构建的 React 项目中。当我们运行生产版本时,一切似乎都很好,但对于我们的开发版本,它无法编译。我不完全理解 webpack,所以我很难弄清楚如何继续前进。我尝试升级一些依赖项,但这似乎没有任何作用。
我设法缩小范围的唯一事情是,如果我将脚本文件中的
BABEL_ENV=development
更改为 BABEL_ENV=production
那么它似乎可以编译并运行良好。为了尝试解决该问题,我接下来可以采取哪些步骤?
这是实际的错误-
./node_modules/@superset-ui/embedded-sdk/lib/index.js 74:45
Module parse failed: Unexpected token (74:45)
File was processed with these loaders:
* ./node_modules/babel-loader/lib/index.js
You may need an additional loader to handle the result of these loaders.
| const iframe = document.createElement('iframe');
| const dashboardConfig = dashboardUiConfig ? `?uiConfig=${calculateConfig()}` : "";
> const filterConfig = dashboardUiConfig?.filters || {};
| const filterConfigKeys = Object.keys(filterConfig);
| const filterConfigUrlParams = filterConfigKeys.length > 0 ? "&" + filterConfigKeys.map(key => _const.DASHBOARD_UI_FILTER_CONFIG_URL_PARAM_KEY[key] + '=' + filterConfig[key]).join('&') : ""; // set up the iframe's sandbox configuration
此处错误:const filterConfig = dashUiConfig?.filters || {}; 解决办法是去 ode_modules@superset-ui mbedded-sdk\lib\index.js 并将此代码编辑为
const filterConfig = dashboardUiConfig && dashboardUiConfig.filters ? dashboardUiConfig.filters : {};