Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: Add support for MSW and Global data fetching #92

Merged
merged 51 commits into from
Oct 19, 2023
Merged
Show file tree
Hide file tree
Changes from 42 commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
26bcecb
Added a plugin for MSW
patricklafrance Oct 3, 2023
553f70d
Updated the sample to use React Router lazy
patricklafrance Oct 4, 2023
193c960
Too many things
patricklafrance Oct 6, 2023
07296d8
Too many changes
patricklafrance Oct 7, 2023
8f64934
Fixed the tests
patricklafrance Oct 9, 2023
abd9fc6
Added back authentication
patricklafrance Oct 10, 2023
04aeafb
Fixing disconnect button
patricklafrance Oct 10, 2023
3b73e84
Route visibility can now also be applied to nested routes
patricklafrance Oct 10, 2023
97574ed
Refactored the host app App.tsx file
patricklafrance Oct 11, 2023
6c6e40b
Improved console logs
patricklafrance Oct 11, 2023
e76f4a3
Minor fixes
patricklafrance Oct 11, 2023
069f4cd
Renamed useActiveRoute for useMatchingRoute
patricklafrance Oct 11, 2023
c191e8c
Remote routes were not working anymore
patricklafrance Oct 11, 2023
6c90e80
Replaced router loader by react query
patricklafrance Oct 12, 2023
660db78
Added a subscription service
patricklafrance Oct 12, 2023
567a7c8
Prefixed route and nav items custom props with $
patricklafrance Oct 12, 2023
bab3854
Updated sample dev & build script to include MSW
patricklafrance Oct 12, 2023
0514619
Added a telemetry service example
patricklafrance Oct 12, 2023
d4320fb
Updated the docs to use the new $ props
patricklafrance Oct 12, 2023
28cbee9
Updated the docs
patricklafrance Oct 12, 2023
b697735
Updated docs
patricklafrance Oct 12, 2023
aa9dc02
Split the samples into 2 distinct applications
patricklafrance Oct 13, 2023
fea5e79
Added tests for useAreModulesReady
patricklafrance Oct 13, 2023
237f677
Fixed local dev environment for the samples
patricklafrance Oct 14, 2023
afefc09
Fixing MSW for the production build
patricklafrance Oct 16, 2023
22b7530
Renamed "dev-local" to "dev-isolated"
patricklafrance Oct 16, 2023
4cd578f
Improved the sample pages
patricklafrance Oct 16, 2023
bf3beeb
Improve the sample apps
patricklafrance Oct 16, 2023
0f42a09
Renamed the hostname for basic sample
patricklafrance Oct 16, 2023
41c3904
Configuring the endpoint sample for Netlify
patricklafrance Oct 17, 2023
7f0df9a
Updated the docs with the new hosted samples urls
patricklafrance Oct 17, 2023
6773a5a
Some new docs
patricklafrance Oct 17, 2023
e3ee416
Updated dependencies
patricklafrance Oct 17, 2023
fde2ab8
More docs
patricklafrance Oct 17, 2023
9fe67fa
More docs
patricklafrance Oct 17, 2023
c57efff
Updated the getting started host guide
patricklafrance Oct 18, 2023
6820e78
Adapted a few guides
patricklafrance Oct 18, 2023
fa1a1a9
Adapted a few other guides
patricklafrance Oct 18, 2023
6fbad83
Fixed broken URLs
patricklafrance Oct 18, 2023
3f35858
Docs fixes
patricklafrance Oct 18, 2023
425a036
Fixed failing tests
patricklafrance Oct 18, 2023
05c88dd
Fix CI script
patricklafrance Oct 18, 2023
06972ea
Fixed LocalModuleRegistrationError name
patricklafrance Oct 18, 2023
2a9bb0d
Code review fixes
patricklafrance Oct 18, 2023
1191af9
Renamed named chunkIds transformer
patricklafrance Oct 19, 2023
daa25a4
Few improvements
patricklafrance Oct 19, 2023
d0c3f4e
Update docs/getting-started/learn-the-api.md
patricklafrance Oct 19, 2023
f0777e7
Fixing runtime messages
patricklafrance Oct 19, 2023
8c1826b
Replaced useAppRouter by AppRouter
patricklafrance Oct 19, 2023
6396796
FIxing build
patricklafrance Oct 19, 2023
df36c06
Rename useMatchingRoute to useRouteMatch
patricklafrance Oct 19, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ jobs:
- name: Build packages
run: pnpm build

- name: Build sample
run: pnpm build-sample
- name: Build samples
run: pnpm build-basic && pnpm build-endpoints

- name: Lint packages & sample
run: pnpm lint
Expand Down
128 changes: 90 additions & 38 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ The following documentation is only for the maintainers of this repository.
- [Installation](#installation)
- [Develop the shell packages](#develop-the-shell-packages)
- [Release the packages](#release-the-packages)
- [Deploy the sample application](#deploy-the-sample-application)
- [Deploy the sample applications](#deploy-the-sample-applications)
- [Available commands](#commands)
- [CI](#ci)
- [Add a new package to the monorepo](#add-a-new-package-to-the-monorepo)
Expand All @@ -22,7 +22,7 @@ The main difference to account for is that the `devDependencies` must now be ins

## Project overview

This project is split into two major sections, [packages/](packages/) and [sample/](sample/).
This project is split into two major sections, [packages/](packages/) and [samples/](samples/).

### Packages

Expand All @@ -32,33 +32,40 @@ Under [packages/](packages/) are the actual packages composing the federated app

[@squide/react-router](packages/react-router/) is a [React Router](https://reactrouter.com/en/main) implementation of the shell routing capabilities. This implementation is offered as a standalone package because the shell could eventually support alternative routing libraries like [TanStack router](https://tanstack.com/router/v1).

[@squide/webpack-module-federation](packages/webpack-module-federation/) is module federation implementation for [webpack](https://webpack.js.org/concepts/module-federation/). This implementation is offered as a standalone package because not all application configurations will require module federation and the shell could eventually support alternative module federation application like [Rspack](https://www.rspack.dev/).
[@squide/webpack-module-federation](packages/webpack-module-federation/) is a module federation implementation for [webpack](https://webpack.js.org/concepts/module-federation/). This implementation is offered as a standalone package because not all application will require module federation and the shell could eventually support alternative module federation application like [Rspack](https://www.rspack.dev/).

[@squide/msw](packages/msw/) is a package including helpers to configure [Mock Service Worker](https://mswjs.io/) for a federated application.

[@squide/fakes](packages/fakes/) is a collection of fake implementations to facilitate the development of federated modules in isolation.

### Sample
### Samples

Under [sample/](sample/) is a sample application to test the federation application shell functionalities while developing.
Under [samples/](samples/) are applications to test the Squide functionalities while developing.

In this sample application would find:
You'll find two samples:

- [An host application](sample/host/): http://locahost:8080
- [A static module](sample/static-module/)
- [A remote module](sample/remote-module/): http://localhost:8081
- `basic`: A sample application showcasing the basic features or Squide.
- `endpoints`: A more complexe sample application showcasing the different usecases related to data fetching and management.

## Installation

This project uses PNPM, therefore, you must [install PNPM](https://pnpm.io/installation):
This project uses PNPM, therefore, you must [install PNPM](https://pnpm.io/installation) first:

To install the project, open a terminal at the root of the workspace and execute the following command:
```bash
npm install -g pnpm
```

To install the Squide project, open a terminal at the root of the workspace and execute the following command:

```bash
pnpm install
```

### Setup Retype

[Retype](https://retype.com/) is the documentation platform that `workleap/web-configs` is using for the documentation. As this project is leveraging a few [Pro features](https://retype.com/pro/) of Retype, you must first setup your [Retype wallet](https://retype.com/guides/cli/#retype-wallet).
[Retype](https://retype.com/) is the documentation platform that Squide is using for its documentation. As this project is leveraging a few [Pro features](https://retype.com/pro/) of Retype.

Everything should work fine as-is but there are a few limitations to use Retype Pro features without a wallet with a licence. If you want to circumvent these limitations, you can optionally, setup your [Retype wallet](https://retype.com/guides/cli/#retype-wallet).

To do so, first make sure that you retrieve the Retype license from your Vault (or ask IT).

Expand All @@ -68,29 +75,37 @@ Then, open a terminal at the root of the workspace and execute the following com
npx retype wallet --add <your-license-key-here>
```

## Develop the shell packages
## Develop the packages

We recommend opening two [VSCode terminals](https://code.visualstudio.com/docs/terminal/basics#_managing-multiple-terminals) to develop the shell packages.
We recommend opening two [VSCode terminals](https://code.visualstudio.com/docs/terminal/basics#_managing-multiple-terminals) to develop the packages.

With the first terminal, execute the following script:

```bash
pnpm dev
```

With the second terminal, execute the following script:
With the second terminal, start one of the sample application with either the following script:

```bash
pnpm dev-basic
```

or

```bash
pnpm dev-sample
pnpm dev-endpoints
```

You can then open your favorite browser and navigate to `http://localhost:8080/` to get a live preview of your code. To test that the remote module is working correctly, navigate to `http://localhost:8081/remoteEntry.js`
You can then open your favorite browser and navigate to `http://localhost:8080/` to get a live preview of your code.

> To test that a remote module is working correctly, navigate to the remote module entry file. For a remote module hosted on the port `8081`, the URL should be `http://localhost:8081/remoteEntry.js`.

## Release the packages

When you are ready to release the packages, you must follow the following steps:
1. Run `pnpm changeset` and follow the prompt. For versioning, always follow the [SemVer standard](https://semver.org/).
2. Commit the newly generated file in your branch and submit a new Pull Request(PR). Changesets will automatically detect the changes and post a message in your pull request telling you that once the PR closes, the versions will be released.
2. Commit the newly generated file in your branch and submit a new Pull Request (PR). Changesets will automatically detect the changes and post a message in your pull request telling you that once the PR closes, the versions will be released.
3. Find someone to review your PR.
4. Merge the Pull request into `main`. A GitHub action will automatically trigger and update the version of the packages and publish them to [npm](https://www.npmjs.com/). A tag will also be created on GitHub tagging your PR merge commit.

Expand All @@ -100,7 +115,7 @@ When you are ready to release the packages, you must follow the following steps:

Make sure you're Git is clean (No pending changes).

#### npm
#### NPM

Make sure GitHub Action has **write access** to the selected npm packages.

Expand All @@ -118,21 +133,42 @@ By default, packages compilation output will be in their respective *dist* direc

If you got linting error, most of the time, they can be fixed automatically using `eslint . --fix`, if not, follow the report provided by `pnpm lint`.

## Deploy the sample application
## Deploy the sample applications

### The "basic" sample application

The sites for this sample application are hosted on [Netlify](https://www.netlify.com/):

- [host](https://squide-basic-host.netlify.app/)
- [remote-module](https://squide-basic-remote-module.netlify.app)
- [another-remote-module](https://squide-basic-another-remote-module.netlify.app)

To deploy the sample application, open a terminal at the root of the repository and execute the following script:

```bash
deploy-basic
```

A prompt with a few questions will appear and then the sits will automatically be deployed to production.

### The sample application with "endpoints"

The sites for this sample application are hosted on [Netlify](https://www.netlify.com/):

The sample application is hosted on [Netlify](https://www.netlify.com/). 2 sites are available, one for the host application (https://squide-host.netlify.app/) and one for the remote module application (https://squide-remote-module.netlify.app).
- [host](https://squide-endpoints-host.netlify.app/)
- [remote-module](https://squide-endpoints-remote-module.netlify.app)

To deploy both websites, open a terminal at the root of the repository and execute the following script:
To deploy the sample application, open a terminal at the root of the repository and execute the following script:

```bash
deploy-sample
deploy-endpoints
```

It will automatically deploy both sites to production.
A prompt with a few questions will appear and then the sites will automatically be deployed to production.

## Commands

From the project root, you have access to many commands the main ones are:
From the project root, you have access to many commands. The most important ones are:

### dev

Expand All @@ -142,17 +178,25 @@ Build the shell packages for development and start the watch processes.
pnpm dev
```

### dev-sample
### dev-basic

Build the sample application for development and start the dev servers.
Build the sample "basic" application for development and start the dev servers.

```bash
pnpm dev-sample
pnpm dev-basic
```

### dev-endpoints

Build the sample "application with "endpoints" for development and start the dev servers.

```bash
pnpm dev-endpoints
```

### dev-docs

Build the docs application for development and start the dev servers.
Build the [Retype](https://retype.com/) documentation for development and start the Retype dev server. If you are experiencing issue with the license, refer to the [setup Retype section](#setup-retype).

```bash
pnpm dev-docs
Expand All @@ -166,28 +210,36 @@ Build the packages for release.
pnpm build
```

### build-sample
### build-basic

Build the sample application for release.
Build the sample "basic" application for release.

```bash
pnpm build-sample
pnpm build-basic
```

### serve-sample
### build-endpoints

Build the sample application for deployment and start a local web server to serve the application.
Build the sample application with "endpoints" for release.

```bash
pnpm serve-sample
pnpm build-endpoints
```

### dev-docs
### serve-basic

Build the [Retype](https://retype.com/) documentation for development and start the Retype dev server. If you are experiencing issue with the license, refer to the [setup Retype section](#setup-retype).
Build the sample "basic" application for deployment and start a local web server to serve the application.

```bash
pnpm dev-docs
pnpm serve-basic
```

### serve-endpoints

Build the sample application with "endpoints" for deployment and start a local web server to serve the application.

```bash
pnpm serve-endpoints
```

### test
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@ To ask a question or propose an idea, feel free to start a new [discussion](http

View the [user's documentation](https://gsoft-inc.github.io/wl-squide/).

## Live sample
## Live samples

A sample application is hosted at https://squide-host.netlify.app.
- A [basic sample application](https://squide-basic-host.netlify.app) hosted on Netlify.
- A [sample application with endpoints](https://squide-endpoints-host.netlify.app) hosted on Netlify.

## 🤝 Contributing

Expand Down
Loading