1.1.0 • Published 12 months ago

@jahia/webpack-config v1.1.0

Weekly downloads
-
License
MIT
Repository
-
Last release
12 months ago

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))

1.1.0

12 months ago

1.0.0

1 year ago