@jahia/webpack-config

1.1.0 • Public • Published

Welcome to @jahia/webpack-config 👋

Version License: SEE LICENSE IN ../../LICENSE.txt FILE Twitter: Jahia

Provide helpers to generates a ModuleFederation plugin config for Jahia extensions

Usage

In your webpack.config.js :

const getModuleFederationConfig = require('@jahia/webpack-config/getModuleFederationConfig');
const packageJson = require('./package.json');
        ...
        plugins: [
            new ModuleFederationPlugin(getModuleFederationConfig(packageJson)),
            ...
        ],
        ...

This will create a default configuration for your module :

  • remote name will be taken from package.json
  • remote will be added to appShell.remotes
  • ./src/javascript/init will be exposed as ./init, in order to be detected and initialized by app-shell
  • shared libraries will be configured based on a global config and your package.json
  • shared libraries are by default not imported (not bundled)

It's possible to pass custom configuration as an optional second argument :

        ...
        plugins: [
            new ModuleFederationPlugin(getModuleFederationConfig(packageJson, {
                name: 'customName',
                exposes: {
                    '.': './src/javascript/shared',
                },
                remotes: {
                    '@jahia/jahia-ui-root': 'appShell.remotes.jahiaUi'
                },
                shared: {
                    'my-additional-shared-lib': '^1.0.0'
                }
            })),
            ...
        ],
        ...

You can also specify the list of shared libraries you want to import, as a third argument :

        ...
        plugins: [
            new ModuleFederationPlugin(getModuleFederationConfig(packageJson, {}, [
                'react', 'react-dom', '@jahia/moonstone'
            ])),
            ...
        ],
        ...

Note : if you want to import all shared libraries you have, you can use getModuleFederationConfig(packageJson, {}, Object.keys(packageJson.dependencies))

Readme

Keywords

none

Package Sidebar

Install

npm i @jahia/webpack-config

Weekly Downloads

65

Version

1.1.0

License

MIT

Unpacked Size

77.7 kB

Total Files

22

Last publish

Collaborators

  • cmailleux
  • shuber
  • gflores-jahia
  • jahiaadmin
  • mdechecchi
  • jahia-ci