foreman icon indicating copy to clipboard operation
foreman copied to clipboard

[WIP] Remove foreman vendor

Open MariaAga opened this issue 1 year ago • 6 comments

Depends on https://github.com/theforeman/foreman/pull/10345 https://github.com/theforeman/foreman/pull/10239 "Fixes #37904 - move css from vendor to foreman " Does not bread plugins, but this pr does: Some plugins have "peerDependencies": "@theforeman/vendor" or assume theforeman/vendor will be available from core, this PR removed theforeman/vendor so it will not be available anymore, and their webpack build will fail with:

ERROR in ./components/AnsibleRolesSwitcher/AnsibleRolesSwitcher.scss (../../foreman/node_modules/css-loader/dist/cjs.js!../../foreman/node_modules/sass-loader/dist/cjs.js!./components/AnsibleRolesSwitcher/AnsibleRolesSwitcher.scss)
webpack.1 | Module build failed (from ../../foreman/node_modules/sass-loader/dist/cjs.js):
webpack.1 | Can't find stylesheet to import.
webpack.1 |   ╷
webpack.1 | 1 │ @import '~@theforeman/vendor/scss/variables';
webpack.1 |   │         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

and will have this console error:

Uncaught (in promise) Error: Module build failed (from ../../foreman/node_modules/sass-loader/dist/cjs.js):
Can't find stylesheet to import.
  ╷
1 │ @import '~@theforeman/vendor/scss/variables';
  │         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  ╵
  ../foreman_ansible/webpack/components/AnsibleRolesSwitcher/AnsibleRolesSwitcher.scss 1:9  root stylesheet

MariaAga avatar Oct 08 '24 15:10 MariaAga

In this PR we had to update to npm 8 to get the "overrides" attribute in package.json - "Overrides provide a way to replace a package in your dependency tree with another version, or another package entirely. ". Which we need to pin victory packages that are used in pf4 charts package. before I think because of some vendor magic pf4 used our install victory, and not the one from the pf4 node_modules, but since I'm simplifying things and moving it all to foreman it doesnt work anymore so we need to completely override victory versions, and not just installing an old one.

@theforeman/packaging are we ok to update to NPM 8+?

MariaAga avatar Oct 10 '24 14:10 MariaAga

@theforeman/packaging are we ok to update to NPM 8+?

MariaAga avatar Nov 12 '24 12:11 MariaAga

@theforeman/packaging are we ok to update to NPM 8+?

When we merge https://github.com/theforeman/foreman/pull/10406 it should be something we get for free.

ekohl avatar Dec 19 '24 14:12 ekohl

dnd still not working in host edit with vm ware - need to fix edit: https://projects.theforeman.org/issues/37882

MariaAga avatar Mar 10 '25 11:03 MariaAga

@MariaAga now we can properly rebase this PR

ShimShtein avatar Jun 12 '25 11:06 ShimShtein

rebased but didnt finish testing it

MariaAga avatar Jun 12 '25 12:06 MariaAga

seperate javascript and react app imports is needed to fix the bug where imports are happening in the wrong order, without it, for some files for example

import a from 'a';
console.log(a)

will log undefined even if a is defined

MariaAga avatar Jun 19 '25 16:06 MariaAga

Thanks, squashed, updated the procfile, and removed the npm8 installation

MariaAga avatar Jul 01 '25 08:07 MariaAga

Packaging status:

  • [X] first set of packages https://github.com/theforeman/foreman-packaging/pull/12145
  • [x] second set of packages https://github.com/theforeman/foreman-packaging/pull/12174
  • [x] Reqs https://github.com/theforeman/foreman-packaging/pull/12157

ShimShtein avatar Jul 08 '25 12:07 ShimShtein

@MariaAga seems unrelated, but can you make sure it's OK: https://github.com/theforeman/foreman/actions/runs/16148221131/job/45572685027?pr=10342#step:16:728

ShimShtein avatar Jul 09 '25 16:07 ShimShtein

@ShimShtein it is unrelated (org tests just randomly fail)

MariaAga avatar Jul 09 '25 16:07 MariaAga

/packit build

evgeni avatar Jul 10 '25 09:07 evgeni

ModuleNotFoundError: Module not found: Error: Can't resolve 'react-bootstrap' in '/usr/lib/node_modules/react-ellipsis-with-tooltip/dist'

Mhh, react-bootstrap is a peerDependency of react-ellipsis-with-tooltip, and our packaging doesn't pull those in.

evgeni avatar Jul 10 '25 09:07 evgeni

@evgeni

Mhh, react-bootstrap is a peerDependency of react-ellipsis-with-tooltip, and our packaging doesn't pull those in.

is this a hint for me to add it?

MariaAga avatar Jul 10 '25 09:07 MariaAga

not yet :)

evgeni avatar Jul 10 '25 09:07 evgeni

https://github.com/theforeman/foreman/pull/10601 - let's see if adding react-bootstrap helps.

Edit:

[webpack-cli] ModuleNotFoundError: Module not found: Error: Can't resolve 'react-router' in '/usr/lib/node_modules/connected-react-router/esm'

Well, at least it's a different error now? :crying_cat_face:

evgeni avatar Jul 10 '25 09:07 evgeni

@MariaAga okay, now that #10601 has built on packit: please pull in the react-router and react-bootstrap changes I did into package.json.

I have no idea if it also needs to be added to webpack.js -- seems to work without as long as the peer dependency is satisfied.

Packaging update:

  • [x] https://github.com/theforeman/foreman-packaging/pull/12221

evgeni avatar Jul 10 '25 12:07 evgeni

no runtime error for not adding react-router and react-bootstrap to webpack vendor list

MariaAga avatar Jul 10 '25 13:07 MariaAga

/packit build

evgeni avatar Jul 10 '25 17:07 evgeni

green packit! :green_apple:

evgeni avatar Jul 10 '25 17:07 evgeni

Ubuntu 22.04: TODO (OS repo has NodeJS 12 so we use nodesource; 14 at the moment)

NodeJS 18.20.6 with NPM 10.8.2

evgeni avatar Jul 11 '25 09:07 evgeni