hawtio/hawtio-online

Upgrade to hawtio 1.0.4 + causes compile / runtime errors

Closed this issue ยท 5 comments

WARNING in ../../node_modules/@hawtio/react/node_modules/@patternfly/react-charts/dist/esm/components/ChartCursorTooltip/ChartCursorFlyout.js 87:62-88
export 'CommonProps' (imported as 'CommonProps') was not found in 'victory-core' (possible exports: Arc, Axis, Background, Border, Box, Circle, ClipPath, Collection, Data, DefaultTransitions, Domain, Events, Helpers, Hooks, Immutable, LabelHelpers, Line, LineHelpers, LineSegment, Log, Path, Point, PointPathHelpers, Portal, PortalContext, Rect, Scale, Selection, Style, TSpan, Text, TextSize, Timer, TimerContext, Transitions, UserProps, VictoryAccessibleGroup, VictoryAnimation, VictoryClipContainer, VictoryContainer, VictoryLabel, VictoryPortal, VictoryTheme, VictoryTransition, Whisker, Wrapper, addEvents)
 @ ../../node_modules/@hawtio/react/node_modules/@patternfly/react-charts/dist/esm/components/ChartCursorTooltip/index.js 1:0-36 1:0-36
 @ ../../node_modules/@hawtio/react/node_modules/@patternfly/react-charts/dist/esm/components/index.js 9:0-37 9:0-37
 @ ../../node_modules/@hawtio/react/node_modules/@patternfly/react-charts/dist/esm/index.js 1:0-29 1:0-29
 @ ../../node_modules/@hawtio/react/dist/index.js 3624:26-61 15760:27-62 16742:27-62
 @ consume shared module (default) @hawtio/react@^1.0.4 (singleton) (fallback: ../../node_modules/@hawtio/react/dist/index.js)
 @ ./src/bootstrap.tsx 2:0-62 9:0-15 9:16-28 10:32-47 13:4-32 18:0-16
 @ ./src/index.ts 3:0-21

WARNING in ../../node_modules/@hawtio/react/node_modules/@module-federation/utilities/dist/index.cjs.js 862:122-132
Critical dependency: the request of a dependency is an expression
 @ ../../node_modules/@hawtio/react/dist/index.js 607:23-62
 @ consume shared module (default) @hawtio/react@^1.0.4 (singleton) (fallback: ../../node_modules/@hawtio/react/dist/index.js)
 @ ./src/bootstrap.tsx 2:0-62 9:0-15 9:16-28 10:32-47 13:4-32 18:0-16
 @ ./src/index.ts 3:0-21

1 warning has detailed information that is not shown.
Use 'stats.errorDetails: true' resp. '--stats-error-details' to show it.

webpack 5.90.3 compiled with 2 warnings in 25943 ms

After upgrade to 1.0.4 (or 1.0.5 or 1.0.6), these errors are presented when starting the dev-server.

@tadayosi
Would appreciate your thoughts on this...

Initially, thought it must be the dependency upgrades I merged in, yesterday, but taking out a branch and going back to prior to the upgrades, these errors pop up the moment that I upgrade @hawtio/react to version 1.0.4.

I have some kind of fix / workaround for the react-charts error:

  • It appears that @hawtio/react 1.0.4+ uses 2 different versions of the victory-... dependencies, eg. victory-core.
    • Imports 36.9.1 to node-modules
    • Imports 36.8.6 to `node-modules/@patternfly/react-charts/node-modules/victory-core
  • However, the build version of @hawtio/react 1.0.4+ only requires 36.9.1 so when consuming react-charts as a 3rd-party dependency in hawtio-online, it tries to consume 36.9.1 and the API has obviously changed between the two versions, generating the first error.
  • Was able to workaround the compile error by including the following in package.json (obviously not an ideal solution):
    "@patternfly/react-charts": "6.94.21",
    "victory-area": "36.8.6",
    "victory-axis": "36.8.6",
    "victory-bar": "36.8.6",
    "victory-chart": "36.8.6",
    "victory-core": "36.8.6",
    "victory-create-container": "36.8.6",
    "victory-cursor-container": "36.8.6",
    "victory-group": "36.8.6",
    "victory-legend": "36.8.6",
    "victory-line": "36.8.6",
    "victory-pie": "36.8.6",
    "victory-scatter": "36.8.6",
    "victory-stack": "36.8.6",
    "victory-tooltip": "36.8.6",
    "victory-voronoi-container": "36.8.6",
    "victory-zoom-container": "36.8.6",

The second error is more of a problem and frankly I am stumped. It appears that the upgrade of @module-federation/utilties from 3.0.0 (or possibly 3.0.2 as it is mentioned in yarn.lock) to 3.0.5 has introduced a dynamic loading at line (node_modules/@hawtio/react/node_modules/@module-federation/utilities/dist/index.cjs.js 862:122-132) which webpack just does not like:

(function (t) { return Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require(t)); }); })(/        * webpackIgnore: true */ url)

Have tried a couple of things like defining the mf/utilities version in hawtio-online and trying to ignore the library in the webpack config but nothing has worked. So am just not sure how to proceed with this so please any suggestions would appreciated.

Yeah they are all known issues.

For react-charts, it's the issue with react-charts where it only specifies ^36.6.7 as the victory-core version, so the semver by yarn tries to upgrade it to the latest one 36.9.x which has some breaking changes. So the solution is easy, you can just set resolution of victory-core to 36.8.6 by running the yarn command:

yarn set resolution victory-core@npm:^36.6.7 npm:36.8.6

Note only victory-core needs to be fixed. The other victory libs are fine to upgrade to latest.

Next, for the MF utilities, it's actually just a warning, so you can ignore it when running locally.

WARNING in ../../node_modules/@hawtio/react/node_modules/@module-federation/utilities/dist/index.cjs.js 862:122-132
Critical dependency: the request of a dependency is an expression

However, with CI=true a warning causes the CI to stop. So, to fix it, you can simply force ignoring it. You can check how hawtio/hawtio handles the exact issue:
hawtio/hawtio@aa29d5e

Note the latest @hawtio/react is 1.0.6, and I'll soon release 1.0.7 which contains fixes requested from the Artemis team. So please upgrade it to the latest.

PR for 1.0.7 -> #347