Skip to content

Commit

Permalink
Merge branch 'main' into consume-share-layers
Browse files Browse the repository at this point in the history
# Conflicts:
#	pnpm-lock.yaml
  • Loading branch information
ScriptedAlchemy committed Dec 31, 2024
2 parents 687365f + de80bb5 commit 4ef6efb
Show file tree
Hide file tree
Showing 139 changed files with 2,276 additions and 940 deletions.
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
5 changes: 0 additions & 5 deletions .changeset/six-yaks-teach.md

This file was deleted.

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: 0 additions & 5 deletions .changeset/twelve-dingos-ring.md

This file was deleted.

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.

43 changes: 0 additions & 43 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,54 +16,11 @@ on:
description: 'Release Branch (confirm release branch)'
required: true
default: 'main'
issue_comment:
types: [created]

permissions:
id-token: write

jobs:
issue_comment:
name: Release with comment
if: github.event.issue.pull_request && contains(github.event.comment.body, '!canary')
runs-on: ubuntu-latest

steps:
- name: Checkout Repo
uses: actions/checkout@v3
with:
fetch-depth: 1
ref: refs/pull/${{ github.event.issue.number }}/head

- name: Install Pnpm
run: corepack enable

- name: Setup Node.js 18
uses: actions/setup-node@v3
with:
node-version: '18'
cache: 'pnpm'

- name: Install deps
run: pnpm install

- name: Build Packages
run: pnpm run build:pkg

- name: Release
uses: module-federation/actions@v2
with:
version: 'next'
type: 'release'
branch: ''
tools: 'changeset'
env:
GITHUB_TOKEN: ${{ secrets.REPO_SCOPED_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
REPOSITORY: ${{ github.repository }}
PULL_REQUEST_NUMBER: ${{ github.event.issue.number }}
COMMENT: ${{ toJson(github.event.comment) }}

release:
name: Release
if: ${{ github.event_name == 'workflow_dispatch' || github.event_name == 'push' }}
Expand Down
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.10",
"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.10",
"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.10",
"next": "14.2.16",
"react": "18.3.1"
},
"devDependencies": {
Expand Down
18 changes: 18 additions & 0 deletions apps/modernjs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,23 @@
# @module-federation/modernjsapp

## 0.1.77

### Patch Changes

- @module-federation/enhanced@0.8.6

## 0.1.76

### Patch Changes

- @module-federation/enhanced@0.8.5

## 0.1.75

### Patch Changes

- @module-federation/enhanced@0.8.4

## 0.1.74

### 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.74",
"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,
},
},
}),
],
});
18 changes: 18 additions & 0 deletions apps/website-new/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,23 @@
# website-new

## 1.0.19

### Patch Changes

- @module-federation/error-codes@0.8.6

## 1.0.18

### Patch Changes

- @module-federation/error-codes@0.8.5

## 1.0.17

### Patch Changes

- @module-federation/error-codes@0.8.4

## 1.0.16

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion apps/website-new/docs/en/configure/shared.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ new ModuleFederationPlugin({

- Type: `boolean`
- Required: No
- Default: `true`
- Default: `false`

Whether to allow only one version of the shared module within the shared scope (singleton mode).

Expand Down
67 changes: 35 additions & 32 deletions apps/website-new/docs/en/guide/basic/runtime.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ type InitOptions = {
shared?: {
[pkgName: string]: ShareArgs | ShareArgs[];
};
// Sharing strategy, which strategy will be used to decide whether to reuse the dependency
shareStrategy?: 'version-first' | 'loaded-first';
};

type ShareArgs =
Expand All @@ -91,7 +93,6 @@ type SharedBaseArgs = {
shareConfig?: SharedConfig;
scope?: string | Array<string>;
deps?: Array<string>;
strategy?: 'version-first' | 'loaded-first';
loaded?: boolean;
};

Expand All @@ -104,41 +105,11 @@ type RemoteInfo = (RemotesWithEntry | RemotesWithVersion) & {
interface RemotesWithVersion {
name: string;
version: string;
}
};

interface RemotesWithEntry {
name: string;
entry: string;
}

type ShareInfos = {
// The name of the dependency, basic information about the dependency, and sharing strategy
[pkgName: string]: Shared[];
};

type Shared = {
// The version of the shared dependency
version: string;
// Which modules are currently consuming this dependency
useIn: Array<string>;
// From which module does the shared dependency come?
from: string;
// Factory function to get the shared dependency instance. When no other existing dependencies, it will load its own shared dependencies.
lib?: () => Module;
// Sharing strategy, which strategy will be used to decide whether to reuse the dependency
shareConfig: SharedConfig;
// The scope where the shared dependency is located, the default value is default
scope: Array<string>;
// Function to retrieve the shared dependency instance.
get: SharedGetter;
// List of dependencies that this shared module depends on
deps: Array<string>;
// Indicates whether the shared dependency has been loaded
loaded?: boolean;
// Represents the loading state of the shared dependency
loading?: null | Promise<any>;
// Determines if the shared dependency should be loaded eagerly
eager?: boolean;
};
```

Expand Down Expand Up @@ -176,6 +147,38 @@ loadRemote('app2/util').then((m) => m.add(1, 2, 3));
- Obtains the `share` dependency. When a "shared" dependency matching the current consumer exists in the global environment, the existing and eligible dependency will be reused first. Otherwise, it loads its own dependency and stores it in the global cache.
- This `API` is usually not called directly by users but is used by the build plugin to convert its own dependencies.

```typescript
type ShareInfos = {
// The name of the dependency, basic information about the dependency, and sharing strategy
[pkgName: string]: Shared[];
};

type Shared = {
// The version of the shared dependency
version: string;
// Which modules are currently consuming this dependency
useIn: Array<string>;
// From which module does the shared dependency come?
from: string;
// Factory function to get the shared dependency instance. When no other existing dependencies, it will load its own shared dependencies.
lib?: () => Module;
// Sharing strategy, which strategy will be used to decide whether to reuse the dependency
shareConfig: SharedConfig;
// The scope where the shared dependency is located, the default value is default
scope: Array<string>;
// Function to retrieve the shared dependency instance.
get: SharedGetter;
// List of dependencies that this shared module depends on
deps: Array<string>;
// Indicates whether the shared dependency has been loaded
loaded?: boolean;
// Represents the loading state of the shared dependency
loading?: null | Promise<any>;
// Determines if the shared dependency should be loaded eagerly
eager?: boolean;
};
```

- Example

```javascript
Expand Down
Loading

0 comments on commit 4ef6efb

Please sign in to comment.