Skip to content

Commit

Permalink
feat: support rspack modern ssr (#2775)
Browse files Browse the repository at this point in the history
Co-authored-by: Zhou xiao <codingzx@gmail.com>
  • Loading branch information
2heal1 and zhoushaw authored Jul 26, 2024
1 parent 0de1c83 commit 85ae159
Show file tree
Hide file tree
Showing 31 changed files with 467 additions and 428 deletions.
7 changes: 7 additions & 0 deletions .changeset/nervous-otters-type.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@module-federation/dts-plugin': patch
'@module-federation/enhanced': patch
'@module-federation/modern-js': patch
---

feat: support rspack ssr
2 changes: 2 additions & 0 deletions apps/modernjs-ssr/dynamic-nested-remote/modern.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import { moduleFederationPlugin } from '@module-federation/modern-js';
export default defineConfig({
dev: {
port: 3054,
// FIXME: it should be removed , related issue: https://github.com/web-infra-dev/modern.js/issues/5999
host: '0.0.0.0',
},
runtime: {
router: true,
Expand Down
12 changes: 6 additions & 6 deletions apps/modernjs-ssr/dynamic-nested-remote/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "modernjs-ssr-dynamic-nested-remote",
"private": true,
"version": "0.1.13",
"version": "0.1.11",
"scripts": {
"reset": "npx rimraf ./**/node_modules",
"dev": "modern dev",
Expand All @@ -25,18 +25,18 @@
"dist/"
],
"dependencies": {
"@modern-js/runtime": "2.56.1",
"@modern-js/runtime": "2.56.2",
"react": "~18.2.0",
"react-dom": "~18.2.0",
"@module-federation/modern-js": "workspace:*",
"@babel/runtime": "7.24.4",
"antd": "4.24.15"
},
"devDependencies": {
"@modern-js/app-tools": "2.56.1",
"@modern-js/eslint-config": "2.56.1",
"@modern-js/tsconfig": "2.56.1",
"@modern-js-app/eslint-config": "2.56.1",
"@modern-js/app-tools": "2.56.2",
"@modern-js/eslint-config": "2.56.2",
"@modern-js/tsconfig": "2.56.2",
"@modern-js-app/eslint-config": "2.56.2",
"typescript": "~5.0.4",
"@types/jest": "~29.5.0",
"@types/node": "~16.11.7",
Expand Down
2 changes: 2 additions & 0 deletions apps/modernjs-ssr/dynamic-remote-new-version/modern.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import { moduleFederationPlugin } from '@module-federation/modern-js';
export default defineConfig({
dev: {
port: 3056,
// FIXME: it should be removed , related issue: https://github.com/web-infra-dev/modern.js/issues/5999
host: '0.0.0.0',
},
runtime: {
router: true,
Expand Down
12 changes: 6 additions & 6 deletions apps/modernjs-ssr/dynamic-remote-new-version/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "modernjs-ssr-dynamic-remote-new-version",
"private": true,
"version": "0.1.13",
"version": "0.1.11",
"scripts": {
"reset": "npx rimraf ./**/node_modules",
"dev": "modern dev",
Expand All @@ -25,18 +25,18 @@
"dist/"
],
"dependencies": {
"@modern-js/runtime": "2.56.1",
"@modern-js/runtime": "2.56.2",
"react": "~18.2.0",
"react-dom": "~18.2.0",
"@module-federation/modern-js": "workspace:*",
"@babel/runtime": "7.24.4",
"antd": "4.24.15"
},
"devDependencies": {
"@modern-js/app-tools": "2.56.1",
"@modern-js/eslint-config": "2.56.1",
"@modern-js/tsconfig": "2.56.1",
"@modern-js-app/eslint-config": "2.56.1",
"@modern-js/app-tools": "2.56.2",
"@modern-js/eslint-config": "2.56.2",
"@modern-js/tsconfig": "2.56.2",
"@modern-js-app/eslint-config": "2.56.2",
"typescript": "~5.0.4",
"@types/jest": "~29.5.0",
"@types/node": "~16.11.7",
Expand Down
2 changes: 2 additions & 0 deletions apps/modernjs-ssr/dynamic-remote/modern.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import { moduleFederationPlugin } from '@module-federation/modern-js';
export default defineConfig({
dev: {
port: 3053,
// FIXME: it should be removed , related issue: https://github.com/web-infra-dev/modern.js/issues/5999
host: '0.0.0.0',
},
runtime: {
router: true,
Expand Down
12 changes: 6 additions & 6 deletions apps/modernjs-ssr/dynamic-remote/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "modernjs-ssr-dynamic-remote",
"private": true,
"version": "0.1.13",
"version": "0.1.11",
"scripts": {
"reset": "npx rimraf ./**/node_modules",
"dev": "modern dev",
Expand All @@ -25,18 +25,18 @@
"dist/"
],
"dependencies": {
"@modern-js/runtime": "2.56.1",
"@modern-js/runtime": "2.56.2",
"react": "~18.2.0",
"react-dom": "~18.2.0",
"@module-federation/modern-js": "workspace:*",
"@babel/runtime": "7.24.4",
"antd": "4.24.15"
},
"devDependencies": {
"@modern-js/app-tools": "2.56.1",
"@modern-js/eslint-config": "2.56.1",
"@modern-js/tsconfig": "2.56.1",
"@modern-js-app/eslint-config": "2.56.1",
"@modern-js/app-tools": "2.56.2",
"@modern-js/eslint-config": "2.56.2",
"@modern-js/tsconfig": "2.56.2",
"@modern-js-app/eslint-config": "2.56.2",
"typescript": "~5.0.4",
"@types/jest": "~29.5.0",
"@types/node": "~16.11.7",
Expand Down
2 changes: 2 additions & 0 deletions apps/modernjs-ssr/host/modern.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import { moduleFederationPlugin } from '@module-federation/modern-js';
export default defineConfig({
dev: {
port: 3050,
// FIXME: it should be removed , related issue: https://github.com/web-infra-dev/modern.js/issues/5999
host: '0.0.0.0',
},
runtime: {
router: true,
Expand Down
12 changes: 6 additions & 6 deletions apps/modernjs-ssr/host/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "modernjs-ssr-host",
"private": true,
"version": "0.1.13",
"version": "0.1.11",
"scripts": {
"reset": "npx rimraf ./**/node_modules",
"dev": "modern dev",
Expand All @@ -25,18 +25,18 @@
"dist/"
],
"dependencies": {
"@modern-js/runtime": "2.56.1",
"@modern-js/runtime": "2.56.2",
"react": "~18.2.0",
"react-dom": "~18.2.0",
"@module-federation/modern-js": "workspace:*",
"@babel/runtime": "7.24.4",
"antd": "4.24.15"
},
"devDependencies": {
"@modern-js/app-tools": "2.56.1",
"@modern-js/eslint-config": "2.56.1",
"@modern-js/tsconfig": "2.56.1",
"@modern-js-app/eslint-config": "2.56.1",
"@modern-js/app-tools": "2.56.2",
"@modern-js/eslint-config": "2.56.2",
"@modern-js/tsconfig": "2.56.2",
"@modern-js-app/eslint-config": "2.56.2",
"typescript": "~5.0.4",
"@types/jest": "~29.5.0",
"@types/node": "~16.11.7",
Expand Down
10 changes: 8 additions & 2 deletions apps/modernjs-ssr/nested-remote/modern.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,22 @@ import { moduleFederationPlugin } from '@module-federation/modern-js';
export default defineConfig({
dev: {
port: 3052,
// FIXME: it should be removed , related issue: https://github.com/web-infra-dev/modern.js/issues/5999
host: '0.0.0.0',
},
runtime: {
router: true,
},

server: {
ssr: {
mode: 'stream',
},
port: 3052,
},
plugins: [appTools(), moduleFederationPlugin()],
plugins: [
appTools({
bundler: 'experimental-rspack',
}),
moduleFederationPlugin(),
],
});
12 changes: 6 additions & 6 deletions apps/modernjs-ssr/nested-remote/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "modernjs-ssr-nested-remote",
"private": true,
"version": "0.1.13",
"version": "0.1.11",
"scripts": {
"reset": "npx rimraf ./**/node_modules",
"dev": "modern dev",
Expand All @@ -25,18 +25,18 @@
"dist/"
],
"dependencies": {
"@modern-js/runtime": "2.56.1",
"@modern-js/runtime": "2.56.2",
"react": "~18.2.0",
"react-dom": "~18.2.0",
"@module-federation/modern-js": "workspace:*",
"@babel/runtime": "7.24.4",
"antd": "4.24.15"
},
"devDependencies": {
"@modern-js/app-tools": "2.56.1",
"@modern-js/eslint-config": "2.56.1",
"@modern-js/tsconfig": "2.56.1",
"@modern-js-app/eslint-config": "2.56.1",
"@modern-js/app-tools": "2.56.2",
"@modern-js/eslint-config": "2.56.2",
"@modern-js/tsconfig": "2.56.2",
"@modern-js-app/eslint-config": "2.56.2",
"typescript": "~5.0.4",
"@types/jest": "~29.5.0",
"@types/node": "~16.11.7",
Expand Down
17 changes: 17 additions & 0 deletions apps/modernjs-ssr/nested-remote/serverroutebootstrap.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
export const routes = [
{
path: '/',
children: [
{
_component: '@_modern_js_src/routes/page',
index: true,
id: 'page',
type: 'nested',
},
],
isRoot: true,
_component: '@_modern_js_src/routes/layout',
id: 'layout',
type: 'nested',
},
];
2 changes: 2 additions & 0 deletions apps/modernjs-ssr/nested-remote/test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
const serverRender = require('/Users/bytedance/outter/universe/apps/modernjs-ssr/nested-remote/dist/bundles/main.js');
console.log(33, serverRender);
2 changes: 2 additions & 0 deletions apps/modernjs-ssr/remote-new-version/modern.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import { moduleFederationPlugin } from '@module-federation/modern-js';
export default defineConfig({
dev: {
port: 3055,
// FIXME: it should be removed , related issue: https://github.com/web-infra-dev/modern.js/issues/5999
host: '0.0.0.0',
},
runtime: {
router: true,
Expand Down
10 changes: 5 additions & 5 deletions apps/modernjs-ssr/remote-new-version/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,18 @@
"dist/"
],
"dependencies": {
"@modern-js/runtime": "2.56.1",
"@modern-js/runtime": "2.56.2",
"react": "~18.2.0",
"react-dom": "~18.2.0",
"@module-federation/modern-js": "workspace:*",
"@babel/runtime": "7.24.4",
"antd": "4.24.15"
},
"devDependencies": {
"@modern-js/app-tools": "2.56.1",
"@modern-js/eslint-config": "2.56.1",
"@modern-js/tsconfig": "2.56.1",
"@modern-js-app/eslint-config": "2.56.1",
"@modern-js/app-tools": "2.56.2",
"@modern-js/eslint-config": "2.56.2",
"@modern-js/tsconfig": "2.56.2",
"@modern-js-app/eslint-config": "2.56.2",
"typescript": "~5.0.4",
"@types/jest": "~29.5.0",
"@types/node": "~16.11.7",
Expand Down
9 changes: 8 additions & 1 deletion apps/modernjs-ssr/remote/modern.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,19 @@ import { moduleFederationPlugin } from '@module-federation/modern-js';
export default defineConfig({
dev: {
port: 3051,
// FIXME: it should be removed , related issue: https://github.com/web-infra-dev/modern.js/issues/5999
host: '0.0.0.0',
},
runtime: {
router: true,
},

plugins: [appTools(), moduleFederationPlugin()],
plugins: [
appTools({
bundler: 'experimental-rspack',
}),
moduleFederationPlugin(),
],
server: {
ssr: {
mode: 'stream',
Expand Down
10 changes: 5 additions & 5 deletions apps/modernjs-ssr/remote/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,18 @@
"dist/"
],
"dependencies": {
"@modern-js/runtime": "2.56.1",
"@modern-js/runtime": "2.56.2",
"react": "~18.2.0",
"react-dom": "~18.2.0",
"@module-federation/modern-js": "workspace:*",
"@babel/runtime": "7.24.4",
"antd": "4.24.15"
},
"devDependencies": {
"@modern-js/app-tools": "2.56.1",
"@modern-js/eslint-config": "2.56.1",
"@modern-js/tsconfig": "2.56.1",
"@modern-js-app/eslint-config": "2.56.1",
"@modern-js/app-tools": "2.56.2",
"@modern-js/eslint-config": "2.56.2",
"@modern-js/tsconfig": "2.56.2",
"@modern-js-app/eslint-config": "2.56.2",
"typescript": "~5.0.4",
"@types/jest": "~29.5.0",
"@types/node": "~16.11.7",
Expand Down
Loading

0 comments on commit 85ae159

Please sign in to comment.