Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/module-federation/core into…
Browse files Browse the repository at this point in the history
… upgrade-package-deps-to-allow-to-use-new-api

# Conflicts:
#	packages/storybook-addon/package.json
  • Loading branch information
fyodorovandrei committed Dec 30, 2024
2 parents c1129b5 + b4a8548 commit 0c7481d
Show file tree
Hide file tree
Showing 116 changed files with 1,114 additions and 502 deletions.
6 changes: 0 additions & 6 deletions .changeset/brave-boxes-remain.md

This file was deleted.

5 changes: 5 additions & 0 deletions .changeset/lucky-shirts-listen.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@module-federation/sdk': patch
---

chore: bump logger
7 changes: 7 additions & 0 deletions .changeset/shaggy-flowers-cry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@module-federation/error-codes': patch
'@module-federation/enhanced': patch
'@module-federation/sdk': patch
---

fix(enhanced): abort process if not find expose modules
7 changes: 7 additions & 0 deletions .changeset/smart-crabs-burn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@module-federation/error-codes': patch
'@module-federation/runtime': patch
'@module-federation/sdk': patch
---

fix: throw RUNTIME-008 Error when script resources load failed
5 changes: 5 additions & 0 deletions .changeset/sour-carpets-walk.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@module-federation/modern-js': patch
---

chore(modern-js-plugin): add ssr option
5 changes: 5 additions & 0 deletions .changeset/twelve-pumpkins-film.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@module-federation/bridge-react': patch
---

feat: support basename passed by remote module props
11 changes: 0 additions & 11 deletions .github/dependabot.yml

This file was deleted.

2 changes: 1 addition & 1 deletion apps/3000-home/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"@ant-design/cssinjs": "^1.21.0",
"antd": "5.19.1",
"lodash": "4.17.21",
"next": "14.2.15",
"next": "14.2.16",
"react": "18.3.1"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion apps/3001-shop/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"@ant-design/cssinjs": "^1.21.0",
"antd": "5.19.1",
"lodash": "4.17.21",
"next": "14.2.15",
"next": "14.2.16",
"react": "18.3.1"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion apps/3002-checkout/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"@ant-design/cssinjs": "^1.21.0",
"antd": "5.19.1",
"lodash": "4.17.21",
"next": "14.2.15",
"next": "14.2.16",
"react": "18.3.1"
},
"devDependencies": {
Expand Down
6 changes: 6 additions & 0 deletions apps/modernjs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @module-federation/modernjsapp

## 0.1.77

### Patch Changes

- @module-federation/enhanced@0.8.6

## 0.1.76

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion apps/modernjs/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@module-federation/modernjsapp",
"private": true,
"version": "0.1.76",
"version": "0.1.77",
"scripts": {
"reset": "npx rimraf ./**/node_modules",
"dev": "modern dev",
Expand Down
4 changes: 3 additions & 1 deletion apps/router-demo/router-host-2000/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,9 @@ const App = () => {
<Route path="/detail/*" Component={Detail} />
<Route
path="/remote1/*"
Component={() => <Remote1App name={'Ming'} age={12} ref={ref} />}
Component={() => (
<Remote1App name={'Ming'} age={12} ref={ref} basename="/remote1" />
)}
/>
<Route
path="/remote2/*"
Expand Down
2 changes: 1 addition & 1 deletion apps/rslib-module/.storybook/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const config: StorybookConfig = {
options: {
remotes: {
'rslib-module':
'rslib-module@http://localhost:3001/mf/mf-manifest.json',
'rslib_provider@http://localhost:3001/mf-manifest.json',
},
},
},
Expand Down
5 changes: 3 additions & 2 deletions apps/rslib-module/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
"types": "./dist/cjs/index.d.ts",
"scripts": {
"build": "rslib build",
"dev": "rslib mf dev",
"dev": "rslib mf-dev",
"build:watch": "rslib build --watch",
"serve": "pnpm build && http-server -p 3001 ./dist/ --cors",
"storybook": "storybook dev -p 6006"
},
Expand All @@ -22,7 +23,7 @@
"@module-federation/rsbuild-plugin": "workspace:*",
"@module-federation/storybook-addon": "workspace:*",
"@rsbuild/plugin-react": "^1.0.6",
"@rslib/core": "^0.0.18",
"@rslib/core": "0.2.0",
"@types/react": "^18.3.11",
"http-server": "^14.1.1",
"react": "^18.3.1",
Expand Down
40 changes: 17 additions & 23 deletions apps/rslib-module/rslib.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,33 +35,27 @@ export default defineConfig({
distPath: {
root: './dist/mf',
},
assetPrefix: 'http://localhost:3000/mf',
minify: true,
},
dev: {
assetPrefix: 'http://localhost:3001/mf',
},
// just for dev
server: {
port: 3001,
},
plugins: [
pluginModuleFederation({
name: 'rslib_provider',
exposes: {
'.': './src/index.tsx',
},
shared: {
react: {
singleton: true,
},
'react-dom': {
singleton: true,
},
},
}),
],
},
],
plugins: [pluginReact()],
plugins: [
pluginReact(),
pluginModuleFederation({
name: 'rslib_provider',
exposes: {
'.': './src/index.tsx',
},
shared: {
react: {
singleton: true,
},
'react-dom': {
singleton: true,
},
},
}),
],
});
6 changes: 6 additions & 0 deletions apps/website-new/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# website-new

## 1.0.19

### Patch Changes

- @module-federation/error-codes@0.8.6

## 1.0.18

### Patch Changes
Expand Down
36 changes: 36 additions & 0 deletions apps/website-new/docs/en/guide/framework/modernjs.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -169,3 +169,39 @@ Set module loading status.
A fault-tolerant component that is rendered when the component fails to **load** or **render**.

Note: This component only renders this fault-tolerant component on the client side when **rendering** fails.

## Configuration

### ssr

- Type: `false`
- Is it required: No
- Default value: `undefined`

`@module-federation/modern-js` will automatically add SSR related build presets based on `server.ssr` in modern.js config.

If the current project only needs to load MF in the CSR, you can set `ssr: false` to help progressive migration.

```title='modern.config.ts'
import { appTools, defineConfig } from '@modern-js/app-tools';
import { moduleFederationPlugin } from '@module-federation/modern-js';
// https://modernjs.dev/en/configure/app/usage
export default defineConfig({
dev: {
port: 3050,
},
runtime: {
router: true,
},
server: {
ssr: {
mode: 'stream',
},
},
plugins: [
appTools(),
moduleFederationPlugin({ ssr: false })
],
});
```
6 changes: 6 additions & 0 deletions apps/website-new/docs/en/guide/troubleshooting/_meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@
"label": "Runtime",
"collapsed":true
},
{
"type": "dir",
"name": "build",
"label": "Build",
"collapsed":true
},
{
"type": "dir",
"name": "type",
Expand Down
18 changes: 18 additions & 0 deletions apps/website-new/docs/en/guide/troubleshooting/build/BUILD-001.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import ErrorCodeTitle from '@components/ErrorCodeTitle';

<ErrorCodeTitle code='BUILD-001'/>

## Reason

The Expose module resource could not be found properly.

There are two reasons for this problem:
1. The exposeModules file path set by `exposes` is incorrect and points to a non-existent address.
2. When using `Next.js` or other frameworks with built-in webpack, the webpack address used by MF is incorrect.

## Solutions

There are corresponding solutions for the reasons:

1. Check whether the module file path corresponding to exposes is correct. Pay attention to the case here.
2. Check whether FEDERATION_WEBPACK_PATH is consistent with the webpack address used by the framework. If not, you can check whether the dependency is installed normally, or set process.env.FEDERATION_WEBPACK_PATH to point to the actual webpack address used.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import ErrorCodeTitle from '@components/ErrorCodeTitle';

<ErrorCodeTitle code='RUNTIME-008'/>

## Reasons

Failed to load resource during the runtime process, which may be caused by network instability leading to resource loading timeout failure, or resource address error leading to resource loading failure.


## Solutions

check whether the resource address is correct. If the resource address is correct, check whether the network is stable. If the network is unstable, you can add the retry mechanism, refer to [Runtime Retry Mechanism](en/plugin/plugins/retry-plugin.html).
48 changes: 48 additions & 0 deletions apps/website-new/docs/public/words-map.json
Original file line number Diff line number Diff line change
Expand Up @@ -156,5 +156,53 @@
}
}
}
},
"exposeModules":{
"id":"exposeModules",
"lang":{
"zh":{
"description":"Module Federation 中 expose 所对应的模块。",
"related_meta":{
"docs":[],
"links":[
{
"id":"webpack-modules-link",
"title":"Webpack modules",
"url":"https://webpack.docschina.org/concepts/modules/"
}]
}
},
"en":{
"description":"The module corresponding to expose in Module Federation.",
"related_meta":{
"docs":[],
"links":[
{
"id":"webpack-modules-link",
"title":"Webpack modules",
"url":"https://webpack.js.org/concepts/modules/#root"
}]
}
}
}
},
"FEDERATION_WEBPACK_PATH":{
"id":"FEDERATION_WEBPACK_PATH",
"lang":{
"zh":{
"description":"Module Federation 实际使用的 webpack 地址。",
"related_meta":{
"docs":[],
"links":[]
}
},
"en":{
"description":"The webpack address actually used by Module Federation.",
"related_meta":{
"docs":[],
"links":[]
}
}
}
}
}
36 changes: 36 additions & 0 deletions apps/website-new/docs/zh/guide/framework/modernjs.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -180,3 +180,39 @@ export default Product;
当组件**加载****渲染**失败时,所渲染的容错组件。

注意:当**渲染**失败的时候,该组件仅在客户端渲染此 容错组件。

## 配置

### ssr

- 类型:`false`
- 是否必填:否
- 默认值:`undefined`

`@module-federation/modern-js` 会根据 modern.js config 中的 `server.ssr` 来自动添加 SSR 相关的构建预设。

如果当前项目仅需要在 CSR 加载 MF ,那么可以设置 `ssr: false` 来帮助渐进式迁移。

```title='modern.config.ts'
import { appTools, defineConfig } from '@modern-js/app-tools';
import { moduleFederationPlugin } from '@module-federation/modern-js';
// https://modernjs.dev/en/configure/app/usage
export default defineConfig({
dev: {
port: 3050,
},
runtime: {
router: true,
},
server: {
ssr: {
mode: 'stream',
},
},
plugins: [
appTools(),
moduleFederationPlugin({ ssr: false })
],
});
```
6 changes: 6 additions & 0 deletions apps/website-new/docs/zh/guide/troubleshooting/_meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@
"label": "运行时",
"collapsed":true
},
{
"type": "dir",
"name": "build",
"label": "构建",
"collapsed":true
},
{
"type": "dir",
"name": "type",
Expand Down
Loading

0 comments on commit 0c7481d

Please sign in to comment.