Skip to content

CONSOLE-3853: Prevent PatternFly styles from being included in plugin compilation#13388

Merged
openshift-merge-bot[bot] merged 1 commit intoopenshift:masterfrom
vojtechszocs:improve-pf-mod-fed
Dec 9, 2023
Merged

CONSOLE-3853: Prevent PatternFly styles from being included in plugin compilation#13388
openshift-merge-bot[bot] merged 1 commit intoopenshift:masterfrom
vojtechszocs:improve-pf-mod-fed

Conversation

@vojtechszocs
Copy link
Contributor

@vojtechszocs vojtechszocs commented Nov 30, 2023

This PR patches ConsoleRemotePlugin to ensure that PatternFly styles are not included when building a dynamic plugin.

This should reduce the risk of having styling related bugs, i.e. some plugin overriding PatternFly styles provided by Console.

Reference:


How to verify changes in this PR

  1. Switch to latest master branch:
git checkout master
git fetch upstream && git rebase upstream/master # upstream => https://github.com/openshift/console.git
  1. Rebuild Console dynamic plugin SDK and Console demo plugin (dev build for more readable output):
(cd frontend ; yarn) # rebuild frontend/packages/console-dynamic-plugin-sdk/dist
(cd dynamic-demo-plugin ; rm -rf node_modules ; yarn ; yarn build-dev) # rebuild dynamic-demo-plugin/dist
  1. Keep the original Console demo plugin output:
(cd dynamic-demo-plugin ; mv dist dist-before)
  1. Apply this PR on top of your local branch and then repeat step 2. above.
  2. Keep the modified Console demo plugin output:
(cd dynamic-demo-plugin ; mv dist dist-after)

You can now use a visual diff tool like Meld to compare before vs. after build output:

  • there will be additional chunks containing ignored (empty) PatternFly CSS modules
  • vendors-node_modules_patternfly_react-core_dist_esm_index_js-chunk.js will refer to these empty CSS modules, for example:
-__webpack_require__(/*! ./alert.css */ "../node_modules/@patternfly/react-styles/css/components/Alert/alert.css");
+__webpack_require__(/*! ./alert.css */ "?9b90");

@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Nov 30, 2023
@openshift-ci-robot
Copy link
Contributor

openshift-ci-robot commented Nov 30, 2023

@vojtechszocs: This pull request references CONSOLE-3853 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "4.15.0" version, but no target version was set.

Details

In response to this:

This PR patches ConsoleRemotePlugin to ensure that PatternFly styles are not included when building a dynamic plugin.

This should reduce the risk of having styling related bugs, i.e. some plugin overriding PatternFly styles provided by Console.

Reference:

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/test-infra repository.

...parseDeps(
rootPackage,
['ajv', 'chalk', 'comment-json', 'find-up', 'read-pkg', 'semver'],
['ajv', 'chalk', 'comment-json', 'find-up', 'glob', 'read-pkg', 'semver'],
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This essentially adds glob to @openshift-console/dynamic-plugin-sdk-webpack package dependencies.

compiler.options.output.publicPath = publicPath;

compiler.options.resolve = compiler.options.resolve ?? {};
compiler.options.resolve.alias = compiler.options.resolve.alias ?? {};
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI, can't use the ??= operator here due to an older Prettier version.

@openshift-ci openshift-ci bot requested review from kyoto and rawagner November 30, 2023 18:06
@openshift-ci openshift-ci bot added component/sdk Related to console-plugin-sdk approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Nov 30, 2023
// Prevent PatternFly styles from being included in the compilation
getPatternFlyStyles().forEach((cssFile) => {
if (Array.isArray(compiler.options.resolve.alias)) {
compiler.options.resolve.alias.push({ name: cssFile, alias: false });
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

options.resolve.alias is typically an object, but webpack also allows for an array representation.

@openshift-ci-robot
Copy link
Contributor

openshift-ci-robot commented Nov 30, 2023

@vojtechszocs: This pull request references CONSOLE-3853 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "4.15.0" version, but no target version was set.

Details

In response to this:

This PR patches ConsoleRemotePlugin to ensure that PatternFly styles are not included when building a dynamic plugin.

This should reduce the risk of having styling related bugs, i.e. some plugin overriding PatternFly styles provided by Console.

Reference:


How to verify changes in this PR:

  1. Switch to latest master branch:
git checkout master
git fetch upstream && git rebase upstream/master # upstream => https://github.com/openshift/console.git
  1. Rebuild Console dynamic plugin SDK and Console demo plugin:
(cd frontend ; yarn) # rebuild frontend/packages/console-dynamic-plugin-sdk/dist
(cd dynamic-demo-plugin ; rm -rf node_modules ; yarn ; yarn build-dev) # rebuild dynamic-demo-plugin/dist
  1. Keep the original Console demo plugin output:
(cd dynamic-demo-plugin ; mv dist dist-before)
  1. Apply this PR on top of your local branch and then repeat step 2. above.
  2. Keep the modified Console demo plugin output:
(cd dynamic-demo-plugin ; mv dist dist-after)

You can now use a visual diff tool like Meld to compare before vs. after build output:

  • there will be additional chunks containing ignored (empty) PatternFly CSS modules
  • vendors-node_modules_patternfly_react-core_dist_esm_index_js-chunk.js will refer to these empty CSS modules, for example:
-__webpack_require__(/*! ./alert.css */ "../node_modules/@patternfly/react-styles/css/components/Alert/alert.css");
+__webpack_require__(/*! ./alert.css */ "?9b90");

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/test-infra repository.

@openshift-ci-robot
Copy link
Contributor

openshift-ci-robot commented Nov 30, 2023

@vojtechszocs: This pull request references CONSOLE-3853 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "4.15.0" version, but no target version was set.

Details

In response to this:

This PR patches ConsoleRemotePlugin to ensure that PatternFly styles are not included when building a dynamic plugin.

This should reduce the risk of having styling related bugs, i.e. some plugin overriding PatternFly styles provided by Console.

Reference:


How to verify changes in this PR:

  1. Switch to latest master branch:
git checkout master
git fetch upstream && git rebase upstream/master # upstream => https://github.com/openshift/console.git
  1. Rebuild Console dynamic plugin SDK and Console demo plugin (dev build for more readable output):
(cd frontend ; yarn) # rebuild frontend/packages/console-dynamic-plugin-sdk/dist
(cd dynamic-demo-plugin ; rm -rf node_modules ; yarn ; yarn build-dev) # rebuild dynamic-demo-plugin/dist
  1. Keep the original Console demo plugin output:
(cd dynamic-demo-plugin ; mv dist dist-before)
  1. Apply this PR on top of your local branch and then repeat step 2. above.
  2. Keep the modified Console demo plugin output:
(cd dynamic-demo-plugin ; mv dist dist-after)

You can now use a visual diff tool like Meld to compare before vs. after build output:

  • there will be additional chunks containing ignored (empty) PatternFly CSS modules
  • vendors-node_modules_patternfly_react-core_dist_esm_index_js-chunk.js will refer to these empty CSS modules, for example:
-__webpack_require__(/*! ./alert.css */ "../node_modules/@patternfly/react-styles/css/components/Alert/alert.css");
+__webpack_require__(/*! ./alert.css */ "?9b90");

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/test-infra repository.

@openshift-ci-robot
Copy link
Contributor

openshift-ci-robot commented Nov 30, 2023

@vojtechszocs: This pull request references CONSOLE-3853 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "4.15.0" version, but no target version was set.

Details

In response to this:

This PR patches ConsoleRemotePlugin to ensure that PatternFly styles are not included when building a dynamic plugin.

This should reduce the risk of having styling related bugs, i.e. some plugin overriding PatternFly styles provided by Console.

Reference:


How to verify changes in this PR

  1. Switch to latest master branch:
git checkout master
git fetch upstream && git rebase upstream/master # upstream => https://github.com/openshift/console.git
  1. Rebuild Console dynamic plugin SDK and Console demo plugin (dev build for more readable output):
(cd frontend ; yarn) # rebuild frontend/packages/console-dynamic-plugin-sdk/dist
(cd dynamic-demo-plugin ; rm -rf node_modules ; yarn ; yarn build-dev) # rebuild dynamic-demo-plugin/dist
  1. Keep the original Console demo plugin output:
(cd dynamic-demo-plugin ; mv dist dist-before)
  1. Apply this PR on top of your local branch and then repeat step 2. above.
  2. Keep the modified Console demo plugin output:
(cd dynamic-demo-plugin ; mv dist dist-after)

You can now use a visual diff tool like Meld to compare before vs. after build output:

  • there will be additional chunks containing ignored (empty) PatternFly CSS modules
  • vendors-node_modules_patternfly_react-core_dist_esm_index_js-chunk.js will refer to these empty CSS modules, for example:
-__webpack_require__(/*! ./alert.css */ "../node_modules/@patternfly/react-styles/css/components/Alert/alert.css");
+__webpack_require__(/*! ./alert.css */ "?9b90");

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/test-infra repository.

@vojtechszocs
Copy link
Contributor Author

/test e2e-gcp-console

@vojtechszocs
Copy link
Contributor Author

Running: knative-ci.feature (1 of 1)

...

<--- JS stacktrace --->

[16777:1201/191957.619205:ERROR:v8_initializer.cc(730)] V8 process OOM (Oilpan: Reserving memory.).

We detected that the Chromium Renderer process just crashed.

/retest

Copy link
Member

@TheRealJon TheRealJon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Dec 7, 2023
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Dec 7, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: TheRealJon, vojtechszocs

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

The pull request process is described here

Details 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

@jhadvig
Copy link
Member

jhadvig commented Dec 8, 2023

QE Approver:
/assign @yanpzhan
Docs Approver:

/assign @opayne1
PX Approver:
/assign @RickJWagner

@opayne1
Copy link
Contributor

opayne1 commented Dec 8, 2023

/label docs-approved

@openshift-ci openshift-ci bot added the docs-approved Signifies that Docs has signed off on this PR label Dec 8, 2023
@yanpzhan
Copy link
Contributor

yanpzhan commented Dec 8, 2023

Checked the code according to @vojtechszocs 's detailed steps, compared files in dist-before and dist-after,
there are additional chunks containing ignored (empty) PatternFly CSS modules:

_a268-_9d82-_21bc-_d0d2-_b014-_9b90-_2347-_271e-_1cde-_eaa9-_6e60-_1574-_ef4e-_fa93-_beef-_a1-113a3b0-chunk.js
_a268-_9d82-_21bc-_d0d2-_b014-_9b90-_2347-_271e-_1cde-_eaa9-_6e60-_1574-_ef4e-_fa93-_beef-_a1-113a3b1-chunk.js

And also could see the difference in vendors-node_modules_patternfly_react-core_dist_esm_index_js-chunk.js :

-__webpack_require__(/*! ./alert.css */ "../node_modules/@patternfly/react-styles/css/components/Alert/alert.css");
+__webpack_require__(/*! ./alert.css */ "?9b90");

/label qe-approved

@openshift-ci openshift-ci bot added the qe-approved Signifies that QE has signed off on this PR label Dec 8, 2023
@openshift-ci-robot
Copy link
Contributor

openshift-ci-robot commented Dec 8, 2023

@vojtechszocs: This pull request references CONSOLE-3853 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "4.16.0" version, but no target version was set.

Details

In response to this:

This PR patches ConsoleRemotePlugin to ensure that PatternFly styles are not included when building a dynamic plugin.

This should reduce the risk of having styling related bugs, i.e. some plugin overriding PatternFly styles provided by Console.

Reference:


How to verify changes in this PR

  1. Switch to latest master branch:
git checkout master
git fetch upstream && git rebase upstream/master # upstream => https://github.com/openshift/console.git
  1. Rebuild Console dynamic plugin SDK and Console demo plugin (dev build for more readable output):
(cd frontend ; yarn) # rebuild frontend/packages/console-dynamic-plugin-sdk/dist
(cd dynamic-demo-plugin ; rm -rf node_modules ; yarn ; yarn build-dev) # rebuild dynamic-demo-plugin/dist
  1. Keep the original Console demo plugin output:
(cd dynamic-demo-plugin ; mv dist dist-before)
  1. Apply this PR on top of your local branch and then repeat step 2. above.
  2. Keep the modified Console demo plugin output:
(cd dynamic-demo-plugin ; mv dist dist-after)

You can now use a visual diff tool like Meld to compare before vs. after build output:

  • there will be additional chunks containing ignored (empty) PatternFly CSS modules
  • vendors-node_modules_patternfly_react-core_dist_esm_index_js-chunk.js will refer to these empty CSS modules, for example:
-__webpack_require__(/*! ./alert.css */ "../node_modules/@patternfly/react-styles/css/components/Alert/alert.css");
+__webpack_require__(/*! ./alert.css */ "?9b90");

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/test-infra repository.

@RickJWagner
Copy link

/label px-approved

@openshift-ci openshift-ci bot added the px-approved Signifies that Product Support has signed off on this PR label Dec 8, 2023
@openshift-ci-robot
Copy link
Contributor

/retest-required

Remaining retests: 0 against base HEAD b6b1302 and 2 for PR HEAD 848987c in total

@openshift-ci-robot
Copy link
Contributor

/retest-required

Remaining retests: 0 against base HEAD 468b9b4 and 1 for PR HEAD 848987c in total

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Dec 9, 2023

@vojtechszocs: all tests passed!

Full PR test history. Your PR dashboard.

Details

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/test-infra repository. I understand the commands that are listed here.

@openshift-merge-bot openshift-merge-bot bot merged commit ad807f6 into openshift:master Dec 9, 2023
@openshift-bot
Copy link
Contributor

[ART PR BUILD NOTIFIER]

This PR has been included in build openshift-enterprise-console-container-v4.16.0-202312091410.p0.gad807f6.assembly.stream for distgit openshift-enterprise-console.
All builds following this will include this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. component/sdk Related to console-plugin-sdk docs-approved Signifies that Docs has signed off on this PR jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. lgtm Indicates that a PR is ready to be merged. px-approved Signifies that Product Support has signed off on this PR qe-approved Signifies that QE has signed off on this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants