首页 > 解决方案 > GD 7.2.0 to 7.4.0 library upgrade issues

问题描述

We are upgrading our GoodData library to 7.4.0 (from 7.2.0) and the error we are getting in our build is:

 0=./node_modules/react-intl/lib/components/provider.js 59:15
Module parse failed: Unexpected token (59:15)
File was processed with these loaders:
 * ./node_modules/@angular-devkit/build-optimizer/src/build-optimizer/webpack-loader.js
You may need an additional loader to handle the result of these loaders.
|     return Object.assign(Object.assign({}, resolvedConfig), { formatters, formatNumber: formatNumber.bind(null, resolvedConfig, formatters.getNumberFormat), formatNumberToParts: formatNumberToParts.bind(null, resolvedConfig, formatters.getNumberFormat), formatRelativeTime: formatRelativeTime.bind(null, resolvedConfig, formatters.getRelativeTimeFormat), formatDate: formatDate.bind(null, resolvedConfig, formatters.getDateTimeFormat), formatDateToParts: formatDateToParts.bind(null, resolvedConfig, formatters.getDateTimeFormat), formatTime: formatTime.bind(null, resolvedConfig, formatters.getDateTimeFormat), formatTimeToParts: formatTimeToParts.bind(null, resolvedConfig, formatters.getDateTimeFormat), formatPlural: formatPlural.bind(null, resolvedConfig, formatters.getPluralRules), formatMessage: formatMessage.bind(null, resolvedConfig, formatters), formatHTMLMessage: formatHTMLMessage.bind(null, resolvedConfig, formatters), formatList: formatList.bind(null, resolvedConfig, formatters.getListFormat), formatDisplayName: formatDisplayName.bind(null, resolvedConfig, formatters.getDisplayNames) });
| }
> export default const IntlProvider = /*@__PURE__*/ function () {
|     class IntlProvider extends React.PureComponent {
|         constructor() {
 @ ./node_modules/react-intl/lib/index.js 7:0-76 7:0-76 7:0-76
 @ ./node_modules/@gooddata/react-components/dist/helpers/IntlStore.js
 @ ./node_modules/@gooddata/react-`enter code here`components/dist/components/filters/DateFilter/utils/Translations/DateFilterTitle.js
 @ ./node_modules/@gooddata/react-components/dist/components/filters/DateFilter/index.js
 @ ./node_modules/@gooddata/react-components/dist/index.js
 @ ./.skypagestmp/src/app/public/src/modules/gooddata-chart/gooddata-chart.component.js
 @ ./.skypagestmp/src/app/sky-pages.module.ngfactory.js
 @ ./.skypagestmp/src/app/app.module.ngfactory.js
 @ ./.skypagestmp/src/main-internal.aot.ts
 @ multi ./.skypagestmp/src/main-internal.aot.ts

标签: reactjsupgradegooddata

解决方案


从错误消息看来,问题出在react-intl,从2.4.0in升级@gooddata/react-components@7.2.03.6.0in @gooddata/react-components@7.4.0。不幸的是,从 v2 升级到 v3 时,react-intl 在某些情况下需要进行一些迁移。

最有可能的是,您需要将以下配置添加到您的 babel-loader(或 typescript-loader)配置中,如升级指南react-intl中所述,将库包含到您的构建过程中:

include: [
  path.join(__dirname, "node_modules/react-intl"),
  path.join(__dirname, "node_modules/intl-messageformat"),
  path.join(__dirname, "node_modules/intl-messageformat-parser"),
],

推荐阅读