Sure, instead of creating a webpack vendor file foreman would export all of the libraries in the same manner like patternfly-react expose a react-bootstrap component, lets take the React package as an example:
Today, in foreman package.json, React is a dependency, and in order for plugins to write React code, its also a dependency of the plugin, so you have two places where you depend on a package, and we magically hope that webpack will know to use the same react npm package.
further, it gets even more interesting, where you want to run react based tests, so without the react code, you can’t run tests (which makes sense) so you end up with a plugin node_modules that have another copy of react (regardless of the node_modules for foreman itself).
My suggestion is that instead, foreman will export all of the packages via some namespace lets call it ForemanPackage, and each plugin will depend on the npm package of foreman, in code it would look something like this (not tested):
import React from 'react';
export { default as React } from React;
and then in another place, e.g. a plugin which wants to use React:
Import React from 'ForemanPackage';
...
then you could simply delete your plugin dependency on React as a package, and whenever you run your tests, you know you are getting the version of React that is defined in foreman.
This will also (IMHO - needs to be tested) should eliminate the code duplication that happens today (if you run npm run analyze
you can see that each plugin is copying foreman react code…