Bug 2002362 - Dynamic Plugin - ConsoleRemotePlugin for webpack doesn't use commonjs
Summary: Dynamic Plugin - ConsoleRemotePlugin for webpack doesn't use commonjs
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: OpenShift Container Platform
Classification: Red Hat
Component: Management Console
Version: 4.9
Hardware: Unspecified
OS: Unspecified
unspecified
high
Target Milestone: ---
: 4.10.0
Assignee: Vojtech Szocs
QA Contact: Yadan Pei
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2021-09-08 15:56 UTC by Kim Dobestein
Modified: 2022-03-10 16:08 UTC (History)
4 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2022-03-10 16:08:32 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Github openshift console pull 10130 0 None open Bug 2002362: Rework dynamic plugin SDK dist packages 2021-09-23 18:46:14 UTC
Github openshift console pull 10133 0 None open Bug 2002362: Improve dynamic plugin shared modules 2021-09-27 13:32:13 UTC
Github openshift console pull 10242 0 None open Bug 2002362: Use only JSON files for dynamic plugin JSON schemas 2021-10-14 17:31:40 UTC
Red Hat Product Errata RHSA-2022:0056 0 None None None 2022-03-10 16:08:52 UTC

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


Note You need to log in before you can comment on or make changes to this bug.