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
mainorcanary. - 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
pnpm exec prettier --write .andpnpm exec turbo run lintto check and fix code style. - If you've changed Node.js packages, run
npm run commitfor 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 20 LTS. Check your Node.js version with node -v.
To install Node.js, use nvm or fnm:
# Install Node.js 20 LTS
nvm install 20 --lts
nvm alias default 20
nvm use 20# Enable pnpm with corepack, only available on Node.js >= `v14.19.0`
corepack enablepnpm installWhat 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:
pnpm exec turbo run testThis command runs every test across all projects in the repository.
If you need to run tests for a specific project, use:
pnpm --filter PROJECT-NAME run testReplace PROJECT-NAME with the actual package name (for example @module-federation/runtime-core).
To run tests only for the projects affected by recent changes, use:
pnpm run ci:local --only=build-and-testThis command ensures that only relevant tests are executed, saving time and resources.
The enhanced package uses Vitest with a custom runner that compiles webpack config cases and then executes their bundles in an isolated VM context.
- Run all enhanced tests
pnpm --filter @module-federation/enhanced run test- Run a single enhanced case (by directory name)
# Example: only run the container/0-container-full case
npx vitest -c packages/enhanced/vitest.config.ts -t "0-container-full should compile"
# Or target a specific test file and group
npx vitest -c packages/enhanced/vitest.config.ts packages/enhanced/test/ConfigTestCases.basictest.vitest.ts -t "0-container-full should compile"
npx vitest -c packages/enhanced/vitest.config.ts packages/enhanced/test/ConfigTestCases.embedruntime.vitest.ts -t "0-container-full should compile"- Notes
- Filters match the top-level test names created by the runner (e.g.,
<case-name> should compile). - Case-internal exported tests (the
it(...)inside a case’sindex.js) are aggregated and executed within that top-level test. Use the-tfilter on the top-level name to run only that case.
- Filters match the top-level test names created by the runner (e.g.,
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 changesetCommit 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
Repository maintainers can publish a new version of changed packages to npm.
- Checkout a new release branch, for example
release-v0.19.0. - Run
pnpm changeset versionin the package directory to update the version of each package. - Create a pull request, the title should be
release v0.19.1. - Run the release action to publish packages to npm.
- Select
latestas the release version. - Wait reviewers to approve.
- Merge the release pull request to
main. - Generate the release notes via GitHub, see Automatically generated release notes
- Make sure your branch has added changeset files before releasing the preview version.
- Run the release action to publish packages to npm.
- Select
nextas the release version. - Wait reviewers to approve.
- Use the release pull request to release an official version
- It will create a pull request that includes the changed version




