RFC: Changing how we handle Webpack Building

NEW UPDATES: changing direction

We managed to make this RFC works but we feel it adds complexity to the current solution instead simplifying the process.

The new approach we tried includes the new @theforeman/vendor with the following changes:

@theforeman/vendor

  1. @theforeman/vendor will build itself using webpack
    1. It will produce dist/foreman-vendor.bundle.js[.gzip] and dist/foreman-vendor.bundle.css[.gzip]
    2. It will use the window object to share modules with core and plugins (example: window.__FOREMAN_VENDOR_REACT__)
  2. @theforeman/vendor will have its own lifecycle (build, versioning, deploy to npm/rpm with the dist files)

@theforeman/vendor source
@theforeman/vendor in npm (version: 0.1.0-beta.1)

Foreman build

  1. Will use @theforeman/vendor dependency from npm/rpm/source
  2. Will use webpack.config where externals are @theforeman/vendor/webpack.externals
    This will ensure webpack will replace those node_modules with the window object.
  3. Make sure we serve foreman-vendor.bundle.[js,css]

Foreman branch that uses the new vendor
Diff with develop

  • To make it work you will need to build the dist and copy it to the public folder, I am working to fix it.

@ekohl Is currently testing it and working on the packaging side of it and will update soon.

1 Like