-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: migrate to module federation 2.0 (#168)
* chore: Update the packages and samples to MF enhanced * More stuff * Fixed all tests * Added tests for sharedDependenciesResolutionPlugin * Clean up * More stuff * More docs * More docs * More stuff * More stuff * More doc fixes * Rename @squide/firefly-configs to @squide/firefly-webpack-configs * docs about shared dependencies * Added a changeset file * Updated CI script
- Loading branch information
1 parent
e4620f1
commit 89ace29
Showing
160 changed files
with
5,665 additions
and
4,865 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
--- | ||
"@squide/firefly-webpack-configs": major | ||
"@squide/module-federation": major | ||
"@squide/webpack-configs": major | ||
"@squide/react-router": major | ||
"@squide/firefly": major | ||
"@squide/core": major | ||
--- | ||
|
||
This release Migrates Squide from Webpack Module Federation to [Module Federation 2.0](https://module-federation.io/guide/start/quick-start.html). | ||
|
||
This release deprecates the following packages: | ||
|
||
- `@squide/webpack-module-federation`, use `@squide/module-federation` instead. | ||
- `@squide/firefly-configs`, use `@squide/firefly-webpack-configs` instead. | ||
|
||
And introduce a few changes to existing API: | ||
|
||
- The `FireflyRuntime` nows accept a `useMsw` option and expose a new `isMswEnabled` getter: | ||
|
||
```ts | ||
// bootstrap.tsx | ||
|
||
import { FireflyRuntime } from "@squide/firefly"; | ||
|
||
const runtime = new FireflyRuntime({ | ||
useMsw: true | ||
}); | ||
|
||
// Use the runtime to determine if MSW handlers should be registered. | ||
if (runtime.isMswEnabled) { | ||
// ... | ||
} | ||
``` | ||
|
||
- The `registerRemoteModules` function doesn't accept the remotes URL anymore. The remotes URL should be configured in the webpack configuration files. | ||
|
||
Previously: | ||
|
||
```ts | ||
// bootstrap.tsx | ||
|
||
import { registerRemoteModules, type RemoteDefinition } from "@squide/firefly"; | ||
|
||
const Remotes: RemoteDefinition = [ | ||
{ | ||
name: "remote1", | ||
url: "http://localhost:8081" | ||
} | ||
]; | ||
|
||
await registerRemoteModules(Remotes, runtime); | ||
``` | ||
|
||
```js | ||
// webpack.dev.js | ||
|
||
import { defineDevHostConfig } from "@squide/firefly-webpack-configs"; | ||
import { swcConfig } from "./swc.dev.js"; | ||
|
||
export default defineDevHostConfig(swcConfig, "host", 8080, { | ||
overlay: false | ||
}); | ||
``` | ||
|
||
Now: | ||
|
||
```ts | ||
// bootstrap.tsx | ||
|
||
import { registerRemoteModules, type RemoteDefinition } from "@squide/firefly"; | ||
|
||
const Remotes: RemoteDefinition = [ | ||
{ | ||
name: "remote1" | ||
} | ||
]; | ||
|
||
await registerRemoteModules(Remotes, runtime); | ||
``` | ||
|
||
```js | ||
// webpack.dev.js | ||
|
||
import { defineDevHostConfig } from "@squide/firefly-webpack-configs"; | ||
import { swcConfig } from "./swc.dev.js"; | ||
|
||
/** | ||
* @typedef {import("@squide/firefly-webpack-configs").RemoteDefinition}[] | ||
*/ | ||
export const Remotes = [ | ||
{ | ||
name: "remote1", | ||
url: "http://localhost:8081" | ||
} | ||
]; | ||
|
||
export default defineDevHostConfig(swcConfig, "host", 8080, Remotes, { | ||
overlay: false | ||
}); | ||
``` | ||
|
||
To migrate: | ||
|
||
1. Replace the `@squide/webpack-module-federation` dependency by `@squide/module-federation`. | ||
|
||
2. Replace the `@squide/firefly-configs` dependency by `@squide/firefly-webpack-configs`. | ||
|
||
3. Move the remotes URL from the `bootstrap.tsx` file to the `webpack.*.js` files. | ||
|
||
4. Integrate the new `useMsw` and `isMswEnabled` props. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.