Skip to content

Commit 040fae2

Browse files
Merge branch 'main' into rsbuild-rslib
2 parents e75f047 + 586e94b commit 040fae2

File tree

53 files changed

+2018
-1051
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+2018
-1051
lines changed

.changeset/beige-meals-wash.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'@module-federation/retry-plugin': minor
3+
'website-new': minor
4+
---
5+
6+
Refactor(retry-plugin): unify retry behavior and improve resilience

.changeset/hungry-countries-sleep.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@module-federation/retry-plugin': patch
3+
---
4+
5+
fix(retry-plugin): prevent query parameter accumulation across retries

.github/workflows/preview.yml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# https://github.com/stackblitz-labs/pkg.pr.new
2+
name: Preview Release
3+
4+
on:
5+
workflow_dispatch:
6+
inputs:
7+
branch:
8+
description: 'Release preview version branch (confirm release branch)'
9+
required: true
10+
default: 'main'
11+
12+
permissions:
13+
contents: read
14+
15+
jobs:
16+
preview:
17+
if: github.repository == 'module-federation/core'
18+
runs-on: ubuntu-latest
19+
20+
steps:
21+
- name: Checkout
22+
uses: actions/checkout@v4
23+
with:
24+
fetch-depth: 25
25+
ref: ${{ github.event.inputs.branch }}
26+
27+
# Use corepack to install pnpm
28+
- name: Setup Pnpm
29+
run: |
30+
npm install -g corepack@latest --force
31+
corepack prepare [email protected] --activate
32+
corepack enable
33+
34+
- name: Setup Node.js
35+
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
36+
with:
37+
node-version: 22
38+
cache: 'pnpm'
39+
40+
# Update npm to the latest version to enable OIDC
41+
- name: Update npm
42+
run: |
43+
npm install -g npm@latest
44+
npm --version
45+
46+
- name: Install deps
47+
run: pnpm install
48+
49+
- name: Build and test Packages
50+
run: |
51+
git fetch origin main
52+
npx nx run-many --targets=build --projects=tag:type:pkg --skip-nx-cache
53+
ls -l packages/*/dist packages/*/package.json
54+
55+
- name: Publish Preview
56+
run: |
57+
pnpx [email protected] publish --compact --pnpm ./packages/*

.github/workflows/release.yml

Lines changed: 28 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -25,23 +25,33 @@ jobs:
2525
name: Release
2626
if: ${{ github.event_name == 'workflow_dispatch' || github.event_name == 'push' }}
2727
runs-on: ubuntu-latest
28+
environment: npm
2829
steps:
2930
- name: Checkout
30-
uses: actions/checkout@v3
31+
uses: actions/checkout@v4
3132
with:
3233
fetch-depth: 25
34+
ref: ${{ github.event.inputs.branch }}
3335

34-
- name: Install Pnpm
36+
# Use corepack to install pnpm
37+
- name: Setup Pnpm
3538
run: |
39+
npm install -g corepack@latest --force
3640
corepack prepare [email protected] --activate
3741
corepack enable
3842
39-
- name: Setup Node.js 18
40-
uses: actions/setup-node@v3
43+
- name: Setup Node.js
44+
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
4145
with:
42-
node-version: '18'
46+
node-version: 22
4347
cache: 'pnpm'
4448

49+
# Update npm to the latest version to enable OIDC
50+
- name: Update npm
51+
run: |
52+
npm install -g npm@latest
53+
npm --version
54+
4555
- name: Install deps
4656
run: pnpm install
4757

@@ -52,15 +62,17 @@ jobs:
5262
npx nx run-many --targets=build --projects=tag:type:metro
5363
ls -l packages/*/dist packages/*/package.json
5464
55-
- name: Release
56-
uses: module-federation/actions@v2
65+
- uses: actions/github-script@v7
66+
id: version_to_release
5767
with:
58-
version: ${{ github.event.inputs.version || 'next' }}
59-
branch: ${{ github.event.inputs.branch }}
60-
type: 'release'
61-
tools: 'changeset'
62-
env:
63-
GITHUB_TOKEN: ${{ secrets.REPO_SCOPED_TOKEN }}
64-
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
65-
REPOSITORY: ${{ github.repository }}
66-
REF: ${{ github.ref }}
68+
result-encoding: string
69+
script: |
70+
const fs = require('fs');
71+
const packageJson = JSON.parse(fs.readFileSync('./packages/runtime/package.json', 'utf8'));
72+
return 'v' + packageJson.version;
73+
74+
- name: Publish to npm
75+
run: |
76+
git tag ${{ steps.version_to_release.outputs.result }}
77+
git push origin ${{ steps.version_to_release.outputs.result }}
78+
pnpm -r publish --tag ${{ github.event.inputs.npm_tag }} --publish-branch ${{ github.event.inputs.branch }}

apps/router-demo/router-host-2000/src/App.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@ import React, {
55
Suspense,
66
} from 'react';
77
import { Route, Routes, useLocation } from 'react-router-dom';
8-
import { init, loadRemote } from '@module-federation/enhanced/runtime';
8+
import {
9+
loadRemote,
10+
createInstance,
11+
} from '@module-federation/enhanced/runtime';
912
import { RetryPlugin } from '@module-federation/retry-plugin';
1013
import { createRemoteAppComponent } from '@module-federation/bridge-react';
1114
import Navigation from './navigation';
@@ -17,7 +20,6 @@ import { ErrorBoundary } from 'react-error-boundary';
1720
import Remote1AppNew from 'remote1/app';
1821
import type { ModuleFederationRuntimePlugin } from '@module-federation/enhanced/runtime';
1922
import { Spin } from 'antd';
20-
import { createInstance } from '@module-federation/enhanced/runtime';
2123

2224
const fallbackPlugin: () => ModuleFederationRuntimePlugin = function () {
2325
return {

apps/router-demo/router-host-2000/src/runtime-plugin/retry.ts

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,32 @@ import { RetryPlugin } from '@module-federation/retry-plugin';
22

33
const retryPlugin = () =>
44
RetryPlugin({
5-
fetch: {
6-
// fallback: () => 'http://localhost:2001/mf-manifest.json',
7-
// getRetryPath: (url) => {
8-
// return 'http://localhost:2001/mf-manifest.json?test=1';
9-
// },
5+
retryTimes: 3,
6+
retryDelay: 1000,
7+
onRetry: (params) => {
8+
console.log('onRetry', params);
109
},
11-
script: {
12-
retryTimes: 3,
13-
retryDelay: 1000,
14-
// moduleName: ['remote1'],
15-
cb: (resolve, error) => {
16-
if (error) {
17-
throw new Error(
18-
'The request failed three times and has now been abandoned',
19-
);
20-
}
21-
return setTimeout(() => {
22-
resolve(error);
23-
}, 1000);
24-
},
25-
getRetryPath: (url) => {
26-
return 'http://localhost:2001/remote1.js?test=2';
27-
},
10+
onSuccess: (params) => {
11+
console.log('onSuccess', params);
12+
},
13+
onError: (params) => {
14+
console.log('onError', params);
15+
},
16+
manifestDomains: [
17+
'https://m1.example.com',
18+
'https://m2.example.com',
19+
'https://m3.example.com',
20+
],
21+
domains: [
22+
'http://localhost:2011',
23+
'http://localhost:2021',
24+
'http://localhost:2031',
25+
],
26+
addQuery: ({ times, originalQuery }) => {
27+
return `${originalQuery}&retry=${times}&retryTimeStamp=${new Date().valueOf()}`;
28+
},
29+
fetchOptions: {
30+
method: 'GET',
2831
},
2932
});
3033
export default retryPlugin;

0 commit comments

Comments
 (0)