console icon indicating copy to clipboard operation
console copied to clipboard

Utilize dynamic-modules.json provided by PatternFly packages

Open vojtechszocs opened this issue 1 year ago • 2 comments

This is a follow-up to #13832 and patternfly/patternfly-react/pull/10046

This PR updates ConsoleRemotePlugin code to utilize dynamic-modules.json files provided by relevant PatternFly packages when processing webpack federated shared modules.

The current default list of packages eligible for dynamic module processing by ConsoleRemotePlugin is following:

  • @patternfly/react-core
  • @patternfly/react-icons
  • @patternfly/react-table

When the relevant dynamic-modules.json file is missing, ConsoleRemotePlugin emits an info message to inform developers that it's falling back to Console dynamic module parser (logically equivalent to PatternFly dynamic module parser).


How to compare Console dynamic module parser vs. dynamic-modules.json files from PatternFly packages

  1. Open packages/console-dynamic-plugin-sdk/src/webpack/ConsoleRemotePlugin.ts and put the following code inside sharedDynamicModuleMaps reducer callback:
if (!dynamicModulesFileFound) {
  const moduleMap = acc[pkgName];
  const moduleMapSorted = Object.keys(moduleMap).sort().reduce((acc, key) => ({ ...acc, [key]: moduleMap[key] }), {});

  fs.writeFileSync(
    path.resolve(this.baseDir, `generated-dynamic-modules_${pkgName.replace(/^@.+\//, '')}.json`),
    JSON.stringify(moduleMapSorted, null, 2),
  );
}
  1. Rebuild Console plugin SDK and then your plugin, refer to these instructions for details.

  2. This should produce the following files in your plugin directory:

generated-dynamic-modules_react-core.json
generated-dynamic-modules_react-icons.json
generated-dynamic-modules_react-table.json
  1. Download latest versions of above PatternFly packages, for example:
$ npm info @patternfly/react-core dist.tarball
https://registry.npmjs.org/@patternfly/react-core/-/react-core-5.3.3.tgz
  1. Compare the contents of JSON files, for example:
$ meld generated-dynamic-modules_react-core.json /path/to/react-core-5.3.3/package/dist/dynamic-modules.json

vojtechszocs avatar May 17 '24 17:05 vojtechszocs

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: vojtechszocs

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment Approvers can cancel approval by writing /approve cancel in a comment

openshift-ci[bot] avatar May 17 '24 17:05 openshift-ci[bot]

@vojtechszocs: all tests passed!

Full PR test history. Your PR dashboard.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

openshift-ci[bot] avatar May 17 '24 22:05 openshift-ci[bot]

Issues go stale after 90d of inactivity.

Mark the issue as fresh by commenting /remove-lifecycle stale. Stale issues rot after an additional 30d of inactivity and eventually close. Exclude this issue from closing by commenting /lifecycle frozen.

If this issue is safe to close now please do so with /close.

/lifecycle stale

openshift-bot avatar Aug 16 '24 01:08 openshift-bot

PR needs rebase.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

openshift-merge-robot avatar Aug 16 '24 01:08 openshift-merge-robot

Stale issues rot after 30d of inactivity.

Mark the issue as fresh by commenting /remove-lifecycle rotten. Rotten issues close after an additional 30d of inactivity. Exclude this issue from closing by commenting /lifecycle frozen.

If this issue is safe to close now please do so with /close.

/lifecycle rotten /remove-lifecycle stale

openshift-bot avatar Sep 15 '24 08:09 openshift-bot

@vojtechszocs this one needs rebase

jhadvig avatar Sep 23 '24 19:09 jhadvig

Rotten issues close after 30d of inactivity.

Reopen the issue by commenting /reopen. Mark the issue as fresh by commenting /remove-lifecycle rotten. Exclude this issue from closing again by commenting /lifecycle frozen.

/close

openshift-bot avatar Oct 24 '24 00:10 openshift-bot

@openshift-bot: Closed this PR.

In response to this:

Rotten issues close after 30d of inactivity.

Reopen the issue by commenting /reopen. Mark the issue as fresh by commenting /remove-lifecycle rotten. Exclude this issue from closing again by commenting /lifecycle frozen.

/close

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

openshift-ci[bot] avatar Oct 24 '24 00:10 openshift-ci[bot]