Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DO NOT MERGE THIS]: example for migrating webpack in nx to rspack #43

Open
wants to merge 3 commits into
base: lois/nx-webpack-workspace
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ModuleFederationConfig } from '@nx/webpack';
import { ModuleFederationConfig } from '@nx/rspack/module-federation';

const config: ModuleFederationConfig = {
name: 'host',
Expand Down
4 changes: 4 additions & 0 deletions examples/nx-react-webpack-mf-workspace/apps/host/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"name": "host",
"version": "0.0.0"
}
9 changes: 5 additions & 4 deletions examples/nx-react-webpack-mf-workspace/apps/host/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@
"tags": [],
"targets": {
"build": {
"executor": "@nx/webpack:webpack",
"executor": "@nx/rspack:rspack",
"outputs": [
"{options.outputPath}"
],
"defaultConfiguration": "production",
"options": {
"target": "web",
"compiler": "babel",
"outputPath": "dist/apps/host",
"index": "apps/host/src/index.html",
Expand All @@ -26,7 +27,7 @@
"apps/host/src/styles.css"
],
"scripts": [],
"webpackConfig": "apps/host/webpack.config.ts"
"rspackConfig": "apps/host/rspack.config.ts"
},
"configurations": {
"development": {
Expand All @@ -48,12 +49,12 @@
"namedChunks": false,
"extractLicenses": true,
"vendorChunk": false,
"webpackConfig": "apps/host/webpack.config.prod.ts"
"rspackConfig": "apps/host/rspack.config.prod.ts"
}
}
},
"serve": {
"executor": "@nx/react:module-federation-dev-server",
"executor": "@nx/rspack:module-federation-dev-server",
"defaultConfiguration": "development",
"options": {
"buildTarget": "host:build",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { composePlugins, withNx } from '@nx/webpack';
import { withReact } from '@nx/react';
import { withModuleFederation } from '@nx/react/module-federation';
import { ModuleFederationConfig } from '@nx/webpack';

import { composePlugins, withNx, withReact } from '@nx/rspack';
import { withModuleFederation, ModuleFederationConfig } from '@nx/rspack/module-federation';
import { withZephyr } from 'zephyr-webpack-plugin';
import baseConfig from './module-federation.config';

const prodConfig: ModuleFederationConfig = {
Expand Down Expand Up @@ -39,5 +37,6 @@ const prodConfig: ModuleFederationConfig = {
export default composePlugins(
withNx(),
withReact(),
withModuleFederation(prodConfig, { dts: false }),
withModuleFederation(prodConfig, { dts: false } as any),
withZephyr()
);
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { composePlugins, withNx, ModuleFederationConfig } from '@nx/webpack';
import { withReact } from '@nx/react';
import { withModuleFederation } from '@nx/react/module-federation';

import { composePlugins, withNx, withReact } from '@nx/rspack';
import { withModuleFederation, ModuleFederationConfig } from '@nx/rspack/module-federation';
import { withZephyr } from 'zephyr-webpack-plugin';
import baseConfig from './module-federation.config';

const config: ModuleFederationConfig = {
Expand All @@ -18,4 +17,5 @@ export default composePlugins(
withNx(),
withReact(),
withModuleFederation(config, { dts: false }),
withZephyr()
);
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ModuleFederationConfig } from '@nx/webpack';
import { ModuleFederationConfig } from '@nx/rspack/module-federation';

const config: ModuleFederationConfig = {
name: 'remote1',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"name": "remote1",
"version": "0.0.0"
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@
"tags": [],
"targets": {
"build": {
"executor": "@nx/webpack:webpack",
"executor": "@nx/rspack:rspack",
"outputs": [
"{options.outputPath}"
],
"defaultConfiguration": "production",
"options": {
"target": "web",
"compiler": "babel",
"outputPath": "dist/apps/remote1",
"index": "apps/remote1/src/index.html",
Expand All @@ -26,7 +27,7 @@
"apps/remote1/src/styles.css"
],
"scripts": [],
"webpackConfig": "apps/remote1/webpack.config.ts"
"rspackConfig": "apps/remote1/rspack.config.ts"
},
"configurations": {
"development": {
Expand All @@ -48,12 +49,12 @@
"namedChunks": false,
"extractLicenses": true,
"vendorChunk": false,
"webpackConfig": "apps/remote1/webpack.config.prod.ts"
"rspackConfig": "apps/remote1/rspack.config.prod.ts"
}
}
},
"serve": {
"executor": "@nx/react:module-federation-dev-server",
"executor": "@nx/rspack:module-federation-dev-server",
"defaultConfiguration": "development",
"options": {
"buildTarget": "remote1:build",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default require('./rspack.config');
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { composePlugins, withNx } from '@nx/webpack';
import { withReact } from '@nx/react';
import { withModuleFederation } from '@nx/react/module-federation';

import { composePlugins, withNx, withReact } from '@nx/rspack';
import { withModuleFederation } from '@nx/rspack/module-federation';
import { withZephyr } from 'zephyr-webpack-plugin';
import baseConfig from './module-federation.config';

const config = {
Expand All @@ -18,4 +17,5 @@ export default composePlugins(
withNx(),
withReact(),
withModuleFederation(config, { dts: false }),
withZephyr()
);

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ModuleFederationConfig } from '@nx/webpack';
import { ModuleFederationConfig } from '@nx/rspack/module-federation';

const config: ModuleFederationConfig = {
name: 'remote2',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"name": "remote2",
"version": "0.0.0"
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@
"tags": [],
"targets": {
"build": {
"executor": "@nx/webpack:webpack",
"executor": "@nx/rspack:rspack",
"outputs": [
"{options.outputPath}"
],
"defaultConfiguration": "production",
"options": {
"target": "web",
"compiler": "babel",
"outputPath": "dist/apps/remote2",
"index": "apps/remote2/src/index.html",
Expand All @@ -26,7 +27,7 @@
"apps/remote2/src/styles.css"
],
"scripts": [],
"webpackConfig": "apps/remote2/webpack.config.ts"
"rspackConfig": "apps/remote2/rspack.config.ts"
},
"configurations": {
"development": {
Expand All @@ -48,12 +49,12 @@
"namedChunks": false,
"extractLicenses": true,
"vendorChunk": false,
"webpackConfig": "apps/remote2/webpack.config.prod.ts"
"rspackConfig": "apps/remote2/rspack.config.prod.ts"
}
}
},
"serve": {
"executor": "@nx/react:module-federation-dev-server",
"executor": "@nx/rspack:module-federation-dev-server",
"defaultConfiguration": "development",
"options": {
"buildTarget": "remote2:build",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default require('./rspack.config');
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { composePlugins, withNx } from '@nx/webpack';
import { withReact } from '@nx/react';
import { withModuleFederation } from '@nx/react/module-federation';
import { composePlugins, withNx, withReact } from '@nx/rspack';
import { withModuleFederation } from '@nx/rspack/module-federation';
import { withZephyr } from "zephyr-webpack-plugin"

import baseConfig from './module-federation.config';

Expand All @@ -18,4 +18,5 @@ export default composePlugins(
withNx(),
withReact(),
withModuleFederation(config, { dts: false }),
withZephyr()
);

This file was deleted.

Loading