Skip to content

Commit

Permalink
Merge branch 'main' into docs/add-nx-guides
Browse files Browse the repository at this point in the history
  • Loading branch information
ScriptedAlchemy authored Dec 14, 2024
2 parents 4a62171 + 7f2aea6 commit 89c8f81
Show file tree
Hide file tree
Showing 84 changed files with 1,667 additions and 169 deletions.
6 changes: 0 additions & 6 deletions .changeset/real-otters-explode.md

This file was deleted.

5 changes: 5 additions & 0 deletions .changeset/six-yaks-teach.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@module-federation/rspack': patch
---

fix(rspack): import plugin from sub path
5 changes: 5 additions & 0 deletions .changeset/twelve-dingos-ring.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@module-federation/dts-plugin': patch
---

Lazy emit DTS files on hmr rebuilds, do not block compiler pipeline
15 changes: 9 additions & 6 deletions .cursorignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@
./tmp
./scripts
./.git
./packages/storybook-addon
./packages/core
./packages/utilities
./packages/typescript
./packages/native-*
./apps
packages/storybook-addon
packages/core
packages/utilities
packages/typescript
packages/native-*
apps
**/configCases
**/dist
apps/**
*.snap
*.js

21 changes: 17 additions & 4 deletions apps/manifest-demo/3010-rspack-provider/rspack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ module.exports = composePlugins(
transform: {
react: {
runtime: 'automatic',
refresh: true,
},
},
},
Expand All @@ -60,6 +61,18 @@ module.exports = composePlugins(
// publicPath must be specific url
config.output.publicPath = 'http://localhost:3010/';

const rspackPlugin = config.plugins.find((plugin) => {
return plugin.name === 'HtmlRspackPlugin';
});

if (rspackPlugin && rspackPlugin._args && rspackPlugin._args[0]) {
rspackPlugin._args[0].excludeChunks = ['rspack_provider'];
} else {
console.warn(
'HtmlRspackPlugin not found or has unexpected structure. Skipping excludeChunks configuration.',
);
}

config.plugins.push(
new ModuleFederationPlugin({
name: 'rspack_provider',
Expand All @@ -70,10 +83,10 @@ module.exports = composePlugins(
shared: {
lodash: {},
antd: {},
'react/': {
singleton: true,
requiredVersion: '^18.3.1',
},
// 'react/': {
// singleton: true,
// requiredVersion: '^18.3.1',
// },
react: {
singleton: true,
requiredVersion: '^18.3.1',
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.74

### Patch Changes

- @module-federation/enhanced@0.8.3

## 0.1.73

### 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.73",
"version": "0.1.74",
"scripts": {
"reset": "npx rimraf ./**/node_modules",
"dev": "modern dev",
Expand Down
2 changes: 2 additions & 0 deletions apps/react-ts-host/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ module.exports = composePlugins(
withNx(),
withReact(),
async (config, context) => {
config.devServer = config.devServer || {};
config.devServer.host = '127.0.0.1';
// prevent cyclic updates
config.watchOptions = {
ignored: ['**/node_modules/**', '**/@mf-types/**'],
Expand Down
4 changes: 4 additions & 0 deletions apps/react-ts-nested-remote/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ module.exports = composePlugins(
withNx(),
withReact(),
async (config, context) => {
if (!config.devServer) {
config.devServer = {};
}
config.devServer.host = '127.0.0.1';
config.output.publicPath = 'http://localhost:3005/';
// prevent cyclic updates
config.watchOptions = {
Expand Down
1 change: 1 addition & 0 deletions apps/react-ts-remote/rspack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ module.exports = composePlugins(
client: {
overlay: false,
},
host: '127.0.0.1',
port: 3004,
devMiddleware: {
writeToDisk: true,
Expand Down
4 changes: 4 additions & 0 deletions apps/react-ts-remote/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ module.exports = composePlugins(
withNx(),
withReact(),
async (config, context) => {
if (!config.devServer) {
config.devServer = {};
}
config.devServer.host = '127.0.0.1';
const baseConfig = {
name: 'react_ts_remote',
filename: 'remoteEntry.js',
Expand Down
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.16

### Patch Changes

- @module-federation/error-codes@0.8.3

## 1.0.15

### Patch Changes
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
2 changes: 1 addition & 1 deletion apps/website-new/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "website-new",
"version": "1.0.15",
"version": "1.0.16",
"private": true,
"scripts": {
"dev": "rspress dev",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"prepare": "husky install",
"changeset": "changeset",
"build:packages": "npx nx affected -t build --parallel=10 --exclude='*,!tag:type:pkg'",
"changegen": "./changeset-gen.js --path ./packages/enhanced --staged &&./changeset-gen.js --path ./packages/node --staged && ./changeset-gen.js --path ./packages/runtime --staged && ./changeset-gen.js --path ./packages/data-prefetch --staged && ./changeset-gen.js --path ./packages/nextjs-mf --staged",
"changegen": "./changeset-gen.js --path ./packages/enhanced --staged && ./changeset-gen.js --path ./packages/node --staged && ./changeset-gen.js --path ./packages/runtime --staged && ./changeset-gen.js --path ./packages/data-prefetch --staged && ./changeset-gen.js --path ./packages/nextjs-mf --staged && ./changeset-gen.js --path ./packages/dts-plugin --staged",
"commitgen:staged": "./commit-gen.js --path ./packages --staged",
"commitgen:main": "./commit-gen.js --path ./packages",
"changeset:status": "changeset status"
Expand Down
6 changes: 5 additions & 1 deletion packages/assemble-release-plan/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,11 @@
"release": "yarn build && changeset publish"
},
"license": "MIT",
"repository": "https://github.com/changesets/changesets/tree/main/packages/assemble-release-plan",
"repository": {
"type": "git",
"url": "https://github.com/module-federation/core/",
"directory": "packages/assemble-release-plan"
},
"dependencies": {
"@changesets/errors": "^0.2.0",
"@changesets/get-dependents-graph": "^2.1.2",
Expand Down
7 changes: 7 additions & 0 deletions packages/bridge/bridge-react-webpack-plugin/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# @module-federation/bridge-react-webpack-plugin

## 0.8.3

### Patch Changes

- Updated dependencies [8e172c8]
- @module-federation/sdk@0.8.3

## 0.8.2

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/bridge/bridge-react-webpack-plugin/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@module-federation/bridge-react-webpack-plugin",
"version": "0.8.2",
"version": "0.8.3",
"publishConfig": {
"access": "public"
},
Expand Down
8 changes: 8 additions & 0 deletions packages/bridge/bridge-react/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# @module-federation/bridge-react

## 0.8.3

### Patch Changes

- Updated dependencies [8e172c8]
- @module-federation/sdk@0.8.3
- @module-federation/bridge-shared@0.8.3

## 0.8.2

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/bridge/bridge-react/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@module-federation/bridge-react",
"version": "0.8.2",
"version": "0.8.3",
"publishConfig": {
"access": "public"
},
Expand Down
2 changes: 2 additions & 0 deletions packages/bridge/bridge-shared/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# @module-federation/bridge-shared

## 0.8.3

## 0.8.2

## 0.8.1
Expand Down
2 changes: 1 addition & 1 deletion packages/bridge/bridge-shared/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@module-federation/bridge-shared",
"version": "0.8.2",
"version": "0.8.3",
"publishConfig": {
"access": "public"
},
Expand Down
10 changes: 10 additions & 0 deletions packages/bridge/vue3-bridge/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# @module-federation/bridge-vue3

## 0.8.3

### Patch Changes

- Updated dependencies [f817674]
- Updated dependencies [8e172c8]
- @module-federation/runtime@0.8.3
- @module-federation/sdk@0.8.3
- @module-federation/bridge-shared@0.8.3

## 0.8.2

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/bridge/vue3-bridge/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"url": "https://github.com/module-federation/core",
"directory": "packages/vue3-bridge"
},
"version": "0.8.2",
"version": "0.8.3",
"publishConfig": {
"access": "public"
},
Expand Down
7 changes: 7 additions & 0 deletions packages/chrome-devtools/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# @module-federation/devtools

## 0.8.3

### Patch Changes

- Updated dependencies [8e172c8]
- @module-federation/sdk@0.8.3

## 0.8.2

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/chrome-devtools/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@module-federation/devtools",
"version": "0.8.2",
"version": "0.8.3",
"license": "MIT",
"repository": {
"type": "git",
Expand Down
Loading

0 comments on commit 89c8f81

Please sign in to comment.