Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"build-libs": "yarn workspaces foreach -A --include 'packages/lib-*' run build",
"build-samples": "yarn workspaces foreach -A --include 'packages/sample-*' run build",
"build-samples-prod": "yarn workspaces foreach -A --include 'packages/sample-*' run build-prod",
"build-samples-rspack": "yarn workspaces foreach -A --include 'packages/sample-*' run build-rspack",
"run-samples": "yarn workspaces foreach -Api --include 'packages/sample-*' run http-server",
"lint": "yarn eslint packages",
"test": "yarn jest",
Expand Down
6 changes: 6 additions & 0 deletions packages/lib-webpack/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog for `@openshift/dynamic-plugin-sdk-webpack`

## 5.2.0 - 2026-06-11

- Add rspack compatibility: `DynamicRemotePlugin` now works with both webpack and rspack bundlers. Both
`@rspack/core` and `webpack` are now optional peer dependencies. ([#285])

## 5.1.1 - 2026-04-16

- Fix bug in `PatchEntryCallbackPlugin` where compilation fails when using webpack-dev-server ([#314])
Expand Down Expand Up @@ -77,6 +82,7 @@
[#256]: https://github.com/openshift/dynamic-plugin-sdk/pull/256
[#259]: https://github.com/openshift/dynamic-plugin-sdk/pull/259
[#280]: https://github.com/openshift/dynamic-plugin-sdk/pull/280
[#285]: https://github.com/openshift/dynamic-plugin-sdk/pull/285
[#289]: https://github.com/openshift/dynamic-plugin-sdk/pull/289
[#296]: https://github.com/openshift/dynamic-plugin-sdk/pull/296
[#314]: https://github.com/openshift/dynamic-plugin-sdk/pull/314
11 changes: 10 additions & 1 deletion packages/lib-webpack/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@openshift/dynamic-plugin-sdk-webpack",
"version": "5.1.1",
"version": "5.2.0",
"description": "Allows building dynamic plugin assets with webpack",
"license": "Apache-2.0",
"repository": {
Expand All @@ -26,8 +26,17 @@
"api-extractor-local": "yarn run api-extractor --local"
},
"peerDependencies": {
"@rspack/core": "^2.0.8",
"webpack": "^5.100.0"
},
"peerDependenciesMeta": {
"@rspack/core": {
"optional": true
},
"webpack": {
"optional": true
}
},
"dependencies": {
"lodash": "^4.17.23",
"semver": "^7.7.3",
Expand Down
8 changes: 7 additions & 1 deletion packages/lib-webpack/src/webpack/DynamicRemotePlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,14 @@ export class DynamicRemotePlugin implements WebpackPluginInstance {
const moduleFederationLibraryType = moduleFederationSettings.libraryType ?? 'jsonp';
const moduleFederationSharedScope = moduleFederationSettings.sharedScopeName ?? 'default';

// Rspack's renamed ModuleFederationPlugin to ModuleFederationPluginV1.
// Their ModuleFederationPlugin implements module federation 1.5+
const isRspack = 'rspack' in compiler;

const {
ModuleFederationPlugin = compiler.webpack.container.ModuleFederationPlugin,
ModuleFederationPlugin = isRspack
? (compiler as any).rspack.container.ModuleFederationPluginV1

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unsafe cast to any - no guard if rspack structure changes. Use optional chaining or check existence.

const {
    ModuleFederationPlugin = isRspack
      ? compiler.rspack?.container?.ModuleFederationPluginV1
      : compiler.webpack.container.ModuleFederationPlugin,
    ContainerPlugin = compiler.webpack.container.ContainerPlugin,
  } = moduleFederationSettings.pluginOverride ?? {};

  if (!ModuleFederationPlugin) {
    throw new Error(
      `${isRspack ? 'rspack' : 'webpack'}.container.ModuleFederationPlugin${isRspack ? 'V1' : ''} not found`
    );
  }

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The guard is const isRspack = 'rspack' in compiler;. We can be pretty certain that api will be stable: https://rspack.rs/plugins/webpack/module-federation-plugin-v1

Any cast is pragmatic - rspack and webpack types are structurally similar but incompatible.

: compiler.webpack.container.ModuleFederationPlugin,
ContainerPlugin = compiler.webpack.container.ContainerPlugin,
} = moduleFederationSettings.pluginOverride ?? {};

Expand Down
7 changes: 6 additions & 1 deletion packages/sample-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@
"clean": "rm -rf dist",
"build": "yarn clean && yarn webpack",
"build-prod": "yarn clean && NODE_ENV=production yarn webpack",
"build-rspack": "yarn clean && NODE_ENV=production yarn rspack",
"analyze": "yarn clean && NODE_ENV=production ANALYZE_BUNDLES=true yarn webpack",
"lint": "yarn run -T eslint $INIT_CWD",
"webpack": "node -r ts-node/register ./node_modules/.bin/webpack",
"webpack": "WEBPACK=1 node -r ts-node/register ./node_modules/.bin/webpack",
"rspack": "RSPACK=1 node -r ts-node/register ./node_modules/.bin/rspack -c webpack.config.ts",
"http-server": "http-server dist -p 9000 -c-1",
"test-e2e": "yarn run -T playwright test --headed",
"test-e2e-headless": "yarn run -T playwright test"
Expand All @@ -22,6 +24,9 @@
"@patternfly/react-styles": "^6.4.0",
"@patternfly/react-table": "^6.4.0",
"@patternfly/react-tokens": "^6.4.0",
"@rspack/cli": "^2.0.8",
"@rspack/core": "^2.0.8",
"@types/webpack-bundle-analyzer": "~4.7.0",
"copy-webpack-plugin": "^13.0.1",
"css-loader": "^7.1.2",
"css-minimizer-webpack-plugin": "7.0.2",
Expand Down
Loading