npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@ausuliv/frontend-components-config-utilities

v3.0.5

Published

Utilities for shared config used in RedHat Cloud Services project.

Downloads

5

Readme

RedHat Cloud Services frontend components - webpack config utilities

npm version

Chrome render loader

When using chrome 2 and user refreshes a page on your application you may end up with 2 instances of your application in virtual DOM. This loader prevents it by wrapping your app in condition to check if chrome 2 config is enabled.

The appName should be same as is insights.appname in your package.json.

{
  module: {
    rules: [{
      test: new RegExp(appEntry),
      loader: path.resolve(__dirname, './chrome-render-loader.js'),
      options: {
        appName: 'name-of-your-app',
      }
    }]
}
}

Disable chrome 2

When migrating application to chrome 2 you may want to disable this for some time, otherwise you'll have to sync pushes to all branches with CSC.

{
  module: {
    rules: [{
      test: new RegExp(appEntry),
      loader: '@ausuliv/frontend-components-config-utilities/chrome-render-loader',
      options: {
        appName: 'name-of-your-app',
        skipChrome2: true
      }
    }]
  }
}

Chunk mapper

To properly load files in chrome 2 you have to generate mapper to each exported chunk. This webpack plugin will do that for you.

const ChunkMapper = require('@ausuliv/frontend-components-config-utilities/chunk-mapper');

{
  plugins: [
    new ChunkMapper({
      // prefix: '/some-path/', // optional - defaults to output.publicPath
      modules: [], //required
    })
  ]
}
  • prefix - if you have your federated modules files located under some different path than output.publicPath
  • modules - either string or an array of strings to indicate which generated files should be picked up (generally your insights.appname - if you have dashes in your name replace them with cammel case)

Federated modules

If you don't want to dig trough webpack's module-federation/ and write custom generator you can use this wrapper.

plugins.push(
    require('@redhat-cloud-services/frontend-components-config/federated-modules')({
        root: resolve(__dirname, '../'),
        // exposes: { './RootApp': './src/AppEntry.js' },
        // shared: [{ react: { singleton: true, requiredVersion: 17.0.0 } }],
        // debug: true,
        // moduleName: 'someAppName',
        // useFileHash: false,
        // exclude: ['react']
    })
);

We've aimed for easy plug and play, but feel free to override any fed mods partials with these arguments:

  • root - root of you application (to find out package.json)
  • exposes - which files and modules should be exposed
  • shared - federated modules allow for sharing of dependencies, we've added some general dependencies, but feel free to expand them via this prop
  • debug - to see full output what is going to be used
  • moduleName - used to generate the file under this name (generally your insights.appname - if you have dashes in your name replace them with cammel case)
  • useFileHash - in order to prevent caching we are using file hashes, you might want to turn this off in your dev env
  • exclude - if you want to exclude any shared module you can do it trough here (even for general dependencies added by us)
  • eager - if set to true, turns eager fetch for shared modules on

Override container ports

The default ports for the RBAC server(4012) and/or the Keycloak server(4001) can be overridden using a corresponding variable in the environment.

Bash examples:

  export KEYCLOAK_PORT=4020
  export RBAC_PORT=5000

List of shared deps

This packages exposes these federated shared dependencies

  • lodash - version taken from your package.json
  • axios - version taken from your package.json
  • redux - version taken from your package.json
  • react - version taken from your package.json, treated as singleton
  • react-dom - version taken from your package.json, treated as singleton
  • react-router-dom - version taken from your package.json
  • react-redux - version taken from your package.json
  • redux-promise-middleware - version taken from your package.json
  • @patternfly/react-table - version taken from your package.json
  • @patternfly/react-core - version taken from your package.json
  • @patternfly/react-icons - version taken from your package.json
  • @patternfly/react-tokens - version taken from your package.json
  • @redhat-cloud-services/frontend-components - version taken from your package.json
  • @ausuliv/frontend-components-utilities - version taken from your package.json
  • @redhat-cloud-services/frontend-components-notifications - version taken from your package.json

Extensions plugin

In order to share some code into extension points or to add new extension point we can use ExtensionsPlugin

Simply import it in your webpack config and add it to your plugins

const { resolve } = require('path');
const config = require('@redhat-cloud-services/frontend-components-config');
const ExtensionsPlugin = require('@redhat-cloud-services/frontend-components-config/extensions-plugin');

const { config: webpackConfig, plugins } = config({
  rootFolder: resolve(__dirname, '../'),
  ...(process.env.BETA && { deployment: 'beta/apps' }),
});

plugins.push(
  require('@redhat-cloud-services/frontend-components-config/federated-modules')({
    root: resolve(__dirname, '../'),
  }),
  new ExtensionsPlugin({})
);

module.exports = {
  ...webpackConfig,
  plugins
}

Arguments

There are three arguments ExtensionsPlugin constructor accepts:

  • pluginConfig
  • fedModuleConfig
  • options

pluginConfig

This config contains information about extensions, plugin requirements, its name and description. Most of it (name, description and version) is calculated from your root package.json. But you can override these values:

  • name - plugin name (pulled from package.json)
  • version - version of the plugin
  • displayName - display name of the plugin
  • description - description of the plugin (pulled from package.json)
  • dependencies - object of dependencies which will be passed down to module federation (no need to list general react dependencies)
  • disableStaticPlugins - list of static plugins this plugin disables on load
  • extensions - list of extension objects.

extension object

Each extension object requires a type and properties. The type can be either custom extension or one of predefined:

  • console.navigation/section - a section in navigation (identifies secondary nav)
    • properties
      • id - id of the section
      • name - name of the section, this will be shown in the UI
  • console.page/route - route passed to react-router
    • properties - in theory any react-router path prop can be used here
      • path - (string, or array) path on which the component will be rendered
      • component
        • $codeRef - federated module used to render on the route
  • console.navigation/href - navigation href, used to render leafs of navigation
    • properties
      • id - id of the href
      • section - (optional) used to group nav items under section (omit for flat nav)
      • name - name of the href, thiw will be shown in the UI
      • href - used to mutate the URL