Bug 2002362

Summary: Dynamic Plugin - ConsoleRemotePlugin for webpack doesn't use commonjs
Product: OpenShift Container Platform Reporter: Kim Dobestein <kdoberst>
Component: Management ConsoleAssignee: Vojtech Szocs <vszocs>
Status: CLOSED ERRATA QA Contact: Yadan Pei <yapei>
Severity: high Docs Contact:
Priority: unspecified    
Version: 4.9CC: aos-bugs, spadgett, vszocs, yapei
Target Milestone: ---   
Target Release: 4.10.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2022-03-10 16:08:32 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Kim Dobestein 2021-09-08 15:56:47 UTC
Came out of Hybrid Console Scrum on 09/08/2021

Description of problem:
ACM is having issues loading the ConsoleRemotePlugin for Webpack since the dynamic plug does not use commonjs.


Additional info:
The Console team hasn't seen this since they use ts-node, but ts-node should not be required.

Comment 5 Yadan Pei 2021-10-09 07:33:48 UTC
Hi Kim,

From the bug description it seems only ACM team is having some issues, is this something I can verify from QE side?

Comment 6 Kim Dobestein 2021-10-14 13:19:38 UTC
I would double check with Vojtech, but since this is part of the build process, there may not be much to check.

Comment 7 Vojtech Szocs 2021-10-14 17:30:19 UTC
Moving to POST since there is one more PR related to this bug: https://github.com/openshift/console/pull/10242

Comment 8 Vojtech Szocs 2021-10-14 17:41:43 UTC
Hi @yapei, to verify this bug, you can inspect the generated content of SDK dist package

  @openshift-console/dynamic-plugin-sdk-webpack

Comment 9 Vojtech Szocs 2021-10-14 17:54:17 UTC
Hi Yadan, to verify this bug, you can inspect the generated content of SDK dist package

  @openshift-console/dynamic-plugin-sdk-webpack

$ git clone https://github.com/openshift/console
$ cd console/frontend ; yarn # this also builds all SDK dist packages
$ cd packages/console-dynamic-plugin-sdk/dist/webpack

In this directory, we can check that all .js files *do not* use ESM style imports and exports:

$ grep -r 'import ' --include='*.js' # empty
$ grep -r 'export ' --include='*.js' # no static export statements => OK

You can also inspect some .js files and check that they use CommonJS style imports and exports:

$ cat lib/webpack/ConsoleRemotePlugin.js
..
const webpack = require("webpack"); => this is CommonJS style import
..
exports.ConsoleRemotePlugin = ConsoleRemotePlugin; => this is CommonJS style export
..

Comment 12 Yadan Pei 2021-10-29 06:27:39 UTC
yapei-mac:dist yapei$ git clone xxxx
yapei-mac:dist yapei$ cd console/frontend
yapei-mac:frontend yapei$ yarn
yarn install v1.22.15
[1/5] 🔍  Validating package.json...
[2/5] 🔍  Resolving packages...
warning Resolution field "minimist.5" is incompatible with requested version "minimist.8"
warning Resolution field "minimist.5" is incompatible with requested version "minimist@~0.0.1"
success Already up-to-date.
$ yarn generate
yarn run v1.22.15
$ yarn generate-graphql && yarn build-plugin-sdk
$ graphql-codegen --config graphql-codegen.yml
  ✔ Parse configuration
  ✔ Generate outputs
$ yarn --cwd packages/console-dynamic-plugin-sdk build
$ yarn clean && yarn validate && yarn compile && yarn generate
$ rm -rf dist generated
$ yarn ts-node scripts/validate-extensions.ts
$ ts-node -O '{"module":"commonjs"}' scripts/validate-extensions.ts
Validating Console extension types
Warnings (42)
    Extension type 'PVCCreateProp' has no JSDoc com
........
Generating assets for package @openshift-console/dynamic-plugin-sdk-webpack
dist/webpack/package.json
dist/webpack/LICENSE
dist/webpack/README.md
dist/webpack/schema
✨  Done in 51.19s.
✨  Done in 53.71s.
yapei-mac:dist yapei$ cd packages/console-dynamic-plugin-sdk/dist/webpack
yapei-mac:webpack yapei$ find ./ -name *.js | xargs grep 'export '
.//lib/coderefs/coderef-resolver.js:        console.error(`Missing module export '${moduleName}.${exportName}' of plugin ${pluginID}`);
.//lib/validation/ExtensionValidator.js:                    this.result.addError(`Invalid module export '${exportName}' ${errorTrace}`);
yapei-mac:webpack yapei$ find ./ -name *.js | xargs grep 'import '


All *.js files are using commonJS import and export

Comment 16 errata-xmlrpc 2022-03-10 16:08:32 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (Moderate: OpenShift Container Platform 4.10.3 security update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHSA-2022:0056