Thank you for your interest in contributing to Module Federation! Before starting your contribution, please take a moment to read the following guidelines.
- Fork the Module Federation repository into your own GitHub account.
- Clone the repository to your local machine.
- Checkout a new branch from
main
orcanary
. - Set up the development environment. Refer to the "Setup Development Environment" section below for guidance.
- If you've fixed a bug or added code that should be tested, add some tests.
- Ensure all tests pass. See the "Testing" section below for more information.
- Run
nx format:write
andnx affected -t lint --parallel=7 --exclude='*,!tag:type:pkg'
to check and fix the code style. - If you've changed Node.js packages, run
npm run commit
for semantic versioning and commit. - Submit the Pull Request, ensuring all CI runs pass.
- Your Pull Request will be reviewed by the maintainers soon.
Note:
- Keep your PRs concise, addressing a single issue or feature.
- Include a detailed description in your PR and link to related issues.
We recommend using Node.js 18 LTS. Check your Node.js version with node -v
.
To install Node.js, use nvm or fnm:
# Install Node.js 18 LTS
nvm install 18 --lts
nvm alias default 18
nvm use 18
# Enable pnpm with corepack, only available on Node.js >= `v14.19.0`
corepack enable
Add nx to global
pnpm add nx@latest -g
First, install NX globally:
pnpm install
What this will do:
- Install all dependencies
- Create symlinks between packages in the monorepo
Testing is a crucial part of the development process in Module Federation. Here's how you can run tests:
To execute all test suites in the project, use:
npx nx run-many -t test --parallel=3
This command runs every test across all projects in the repository.
If you need to run tests for a specific project, use:
npx nx run-many -t test --parallel=3 --projects=PROJECT-NAME
Replace PROJECT-NAME
with the actual name of the project you want to test. The --parallel=3
flag allows simultaneous execution of up to 3 test suites, improving the overall testing speed.
To run tests only for the projects affected by recent changes, use:
npx nx affected -t test --parallel=3 --exclude='*,!tag:type:pkg'
This command ensures that only relevant tests are executed, saving time and resources.
Universe is using Changesets to manage the versioning and changelogs.
If you've changed some packages, you need add a new changeset for the changes. Please run changeset
command to select the changed packages and add the changeset info.
pnpm run changeset
Commit your changes to your forked repo, and create a pull request.
The format of PR titles follow Conventional Commits.
An example:
feat(plugin-swc): Add `xxx` config
^ ^ ^
| | |__ Subject
| |_______ Scope
|____________ Type
Module Federation uses GitHub Actions for automated versioning and publishing:
- Make sure your branch has added changeset files before releasing the test version
- Make sure that both "use workflow from" and "release branch" are split for the test version you want to release
- Use the "next" TAB to release the test version
- Use the release pull request to release an official version
- It will create a pull request that includes the changed version