Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
be8b176
chore: switch to pnpm and changeset
zhoushaw Dec 15, 2023
a3006ea
chore: delete unless code
zhoushaw Dec 15, 2023
29e4a20
chore: modify runtime version
zhoushaw Dec 15, 2023
3a0b1a3
chore: modify to pnpm deps
zhoushaw Dec 16, 2023
8910a8d
chore: fix remote demo
zhoushaw Dec 17, 2023
5dad78a
chore: fix pkg deps
Dec 17, 2023
7276c53
chore: modify deps
Dec 17, 2023
209f0b3
chore: fix react ts demo
Dec 18, 2023
7ef5ab9
chore: modify nextjs-mf package.json
Dec 18, 2023
aa34231
docs: prevent react refresh on internals
ScriptedAlchemy Dec 18, 2023
ccd6e74
chore: modify example to test node
Dec 18, 2023
f889971
chore: fix next react loader
Dec 18, 2023
85c973e
chore: delete unless tmp content
Dec 18, 2023
f7d0c14
chore: delete unless tmp content
Dec 18, 2023
3840d99
chore: fix doc serve
Dec 18, 2023
407b81c
fix: transpile paths for nextjs-mf in universe
ScriptedAlchemy Dec 18, 2023
a5823af
chore: fix reactRemoteUI example
Dec 18, 2023
73cdb34
chore: fix utils exports
Dec 18, 2023
93eaf36
chore: fix utils dist path
Dec 18, 2023
0be78a3
fix: output target paths and loader regex
ScriptedAlchemy Dec 18, 2023
26f2415
Merge remote-tracking branch 'origin/nextjs-test' into nextjs-test
ScriptedAlchemy Dec 18, 2023
d3f4c36
chore: merge fix nextjs demo
Dec 18, 2023
b65ab6b
chore: fix nextjs example error
Dec 18, 2023
915864c
chore: fix delegate error
Dec 18, 2023
f3f8131
chore: modify example private attribute
Dec 18, 2023
a9bdb81
chore: optimize serve example command
Dec 18, 2023
f4fd149
chore: optimize example
Dec 18, 2023
990232d
chore: optimize example
Dec 18, 2023
9e3c8f2
chore: update scripts
Dec 19, 2023
c073057
chore: modify changeset
Dec 19, 2023
9cdc10f
chore: modify release
Dec 19, 2023
885df31
chore: modify release test
Dec 19, 2023
7d3f3d9
chore: add changeset
Dec 19, 2023
617a62b
chore: modify workflow event name
Dec 19, 2023
0c1fa7c
chore: modify workflow event name
Dec 19, 2023
4e0ba67
chore: modify workflow to test
Dec 19, 2023
5068d0e
chore: modify workflow to test
Dec 19, 2023
026b077
chore: modify changeset command
Dec 19, 2023
4e42c14
chore: modify deps
Dec 19, 2023
c5a1440
chore: add private attribute
Dec 19, 2023
b9967a0
chore: modify deps
Dec 19, 2023
f262dcb
chore: optimize publish logic
Dec 19, 2023
1ed5875
chore: modify engines pnpm
Dec 19, 2023
c9e8433
chore: modify lock file
Dec 19, 2023
187ad80
chore: update lock file
Dec 19, 2023
83829b8
chore: add release pulll request
Dec 19, 2023
af0cafe
chore: modify build and test
Dec 19, 2023
35cb891
chore: fix type change
Dec 19, 2023
20a5261
chore: merge canary branch
Dec 20, 2023
f7fd181
chore: fix build and test action
Dec 20, 2023
bd7fb63
chore: delete unless file
Dec 20, 2023
9b741c5
chore: modify contiributing
Dec 20, 2023
928bca6
doc: update CONTRIBUTING.md
zhoushaw Dec 20, 2023
af4d67e
chore: fix unit test
Dec 20, 2023
e6eb94c
chore: fix unit test
Dec 20, 2023
8274864
chore: add uncommitted
Dec 20, 2023
16a9678
chore: delete fail test
Dec 20, 2023
3eb9f55
chore: delete fail test
Dec 20, 2023
9076bfc
chore: delete fail test
Dec 20, 2023
e164210
chore: fix e2e cache error
Dec 20, 2023
b37cb53
chore: update workflow
Dec 20, 2023
878e1d0
chore: add record
Dec 20, 2023
1dcea2b
chore: update cypress test
Dec 20, 2023
709db21
chore: fix e2e test
Dec 20, 2023
b469190
chore: optimize record update
Dec 20, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .changeset/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Changesets

Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works
with multi-package repos, or single-package repos to help you version and publish your code. You can
find the full documentation for it [in our repository](https://github.com/changesets/changesets)

We have a quick list of common questions to get you started engaging with this project in
[our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md)
19 changes: 19 additions & 0 deletions .changeset/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"$schema": "https://unpkg.com/@changesets/config@3.0.0/schema.json",
"changelog": "@changesets/cli/changelog",
"commit": false,
"fixed": [
[
"@module-federation/runtime",
"@module-federation/enhanced",
"@module-federation/webpack-bundler-runtime",
"@module-federation/sdk"
]
],
"ignorePatterns": ["^alpha|^beta"],
"linked": [],
"access": "restricted",
"baseBranch": "canary",
"updateInternalDependencies": "patch",
"ignore": []
}
5 changes: 5 additions & 0 deletions .changeset/nice-days-learn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@module-federation/runtime': patch
---

fix: add runtime api
10 changes: 10 additions & 0 deletions .github/pr-labeler.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
'change: feat':
- '/^(feat|types|style)/'
'change: fix':
- '/^fix/'
'change: perf':
- '/^perf/'
'change: breaking':
- '/^breaking change/'
'change: docs':
- '/^docs/'
15 changes: 12 additions & 3 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,21 @@ jobs:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Install Pnpm
run: corepack enable
- name: Setup Node.js 18
uses: actions/setup-node@v3
with:
node-version: '18'
cache: 'pnpm'
- name: Install cypress
run: npx cypress install
- uses: nrwl/nx-set-shas@v3
- run: npm ci
- run: pnpm install
- run: npx nx format:check
- run: npx nx affected -t build --parallel=10 --exclude='*,!tag:package'
- run: npx nx affected -t lint --parallel=7 --exclude='*,!tag:package'
- run: npx nx affected -t test --parallel=3 --exclude='*,!tag:package'
- run: npx nx affected -t build --parallel=10 --exclude='*,!tag:package'
- run: npx nx run-many --target=serve --projects=3000-home,3001-shop,3002-checkout --parallel=3 & echo "done"
- run: sleep 3 && npx nx run-many --target=test:e2e --projects=3000-home,3001-shop,3002-checkout --parallel=1
- run: sleep 6 && npx nx run-many --target=test:e2e --projects=3000-home,3001-shop,3002-checkout --parallel=1
- run: lsof -ti tcp:3000,3001,3002 | xargs kill
20 changes: 20 additions & 0 deletions .github/workflows/pr-label.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: PR Labeler

on:
pull_request_target:
types:
- opened
- edited

jobs:
change-labeling:
name: Labeling for changes
runs-on: ubuntu-latest
steps:
- uses: github/issue-labeler@v3.2
with:
repo-token: '${{ secrets.GITHUB_TOKEN }}'
configuration-path: .github/pr-labeler.yml
enable-versioned-regex: 0
include-title: 1
sync-labels: 1
52 changes: 52 additions & 0 deletions .github/workflows/release-pull-request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Release Pull Request

on:
workflow_dispatch:
inputs:
version:
type: choice
description: 'Release Type (next, beta, alpha, latest)'
required: true
default: 'latest'
options:
- next
- beta
- alpha
- latest

jobs:
release:
name: Create Release Pull Request
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@master
with:
# This makes Actions fetch only one branch to release
fetch-depth: 10

- name: Install Pnpm
run: corepack enable

- name: Setup Node.js 18
uses: actions/setup-node@v3
with:
node-version: '18'
cache: 'pnpm'

- name: Install Dependencies
run: pnpm install --ignore-scripts

- name: Create Release Pull Request
uses: web-infra-dev/actions@v2
with:
# this expects you to have a script called release which does a build for your packages and calls changeset publish
version: ${{ github.event.inputs.version || 'latest' }}
versionNumber: 'auto'
type: 'pull request'
tools: 'changeset'
env:
GITHUB_TOKEN: ${{ secrets.REPO_SCOPED_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
REPOSITORY: ${{ github.repository }}
REF: ${{ github.ref }}
105 changes: 105 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
name: Release
on:
workflow_dispatch:
inputs:
version:
type: choice
description: 'Release Version (next, beta, alpha, latest)'
required: true
default: 'next'
options:
- next
- beta
- alpha
- latest
branch:
description: 'Release Branch (confirm release branch)'
required: true
default: 'canary'
issue_comment:
types: [created]

permissions:
id-token: write

jobs:
issue_comment:
name: Release with comment
if: github.event.issue.pull_request && contains(github.event.comment.body, '!canary')
runs-on: ubuntu-latest

steps:
- name: Checkout Repo
uses: actions/checkout@v3
with:
fetch-depth: 1
ref: refs/pull/${{ github.event.issue.number }}/head

- name: Install Pnpm
run: corepack enable

- name: Setup Node.js 18
uses: actions/setup-node@v3
with:
node-version: '18'
cache: 'pnpm'

- name: Install deps
run: pnpm install

- name: Build and test Packages
run: npx nx affected -t pre-release --parallel=3 --exclude='*,!tag:package' --base=origin/canary --head=${{ github.ref }}

- name: Release
uses: web-infra-dev/actions@v2
with:
version: 'next'
type: 'release'
branch: ''
tools: 'changeset'
env:
GITHUB_TOKEN: ${{ secrets.REPO_SCOPED_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
REPOSITORY: ${{ github.repository }}
PULL_REQUEST_NUMBER: ${{ github.event.issue.number }}
COMMENT: ${{ toJson(github.event.comment) }}

release:
name: Release
if: ${{ github.event_name == 'workflow_dispatch' || github.event_name == 'push' }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 25

- name: Install Pnpm
run: corepack enable

- name: Setup Node.js 18
uses: actions/setup-node@v3
with:
node-version: '18'
cache: 'pnpm'

- name: Install deps
run: pnpm install

- name: Build and test Packages
run: |
git fetch origin canary
npx nx affected -t pre-release --parallel=3 --exclude='*,!tag:package' --base=origin/canary --head=${{ github.ref }}

- name: Release
uses: web-infra-dev/actions@v2
with:
version: ${{ github.event.inputs.version || 'next' }}
branch: ${{ github.event.inputs.branch }}
type: 'release'
tools: 'changeset'
env:
GITHUB_TOKEN: ${{ secrets.REPO_SCOPED_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
REPOSITORY: ${{ github.repository }}
REF: ${{ github.ref }}
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,7 @@ Thumbs.db
.next
.netlify
migrations.json

# build contnt
packages/**/dist
apps/**/dist
82 changes: 46 additions & 36 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,28 @@ nvm use 18

### Install Dependencies

First, install NX globally:
```sh
# Enable pnpm with corepack, only available on Node.js >= `v14.19.0`
corepack enable
```

Add nx to global

```bash
npm install --global nx@latest
pnpm add nx@latest -g
```

Then, install Node.js dependencies:
First, install NX globally:

```bash
npm install
```sh
pnpm install
```

What this will do:

- Install all dependencies
- Create symlinks between packages in the monorepo


## Testing

Expand Down Expand Up @@ -84,49 +94,49 @@ npx nx affected -t test --parallel=3 --exclude='*,!tag:package'
This command ensures that only relevant tests are executed, saving time and resources.


## Release
## Submitting Changes

Module Federation uses GitHub Actions for automated versioning and publishing:
### Add a Changeset

## Version Release
Universe is using [Changesets](https://github.com/changesets/changesets) to manage the versioning and changelogs.

Releasing a version in Module Federation is now more efficient with specific commands and an automated CI process, utilizing the `@goestav/nx-semantic-release:semantic-release` for semantic versioning:
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.

- To manually release a version:
- Run: `nx run PROJECT-NAME:release`
- For additional configuration options, refer to the [nx-semantic-release documentation](https://github.com/goestav/nx-semantic-release).
- Executing this command will:
- Tag your commit with the version.
- Generate a changelog.
- Increment the project version.
- Update versions of dependent projects.
```sh
pnpm run changeset
```

### Automated Releases in CI
![image](https://github.com/module-federation/universe/assets/27547179/15505abf-8b0b-450f-b2d0-ffdc52e710a4)

Releases are automated in CI, based on the branch they are merged into:

- `main`: Stable channel.
- `next`: Release candidate channel.
- `canary`: Canary channel.
### Committing your Changes

To trigger releases manually:
Commit your changes to your forked repo, and [create a pull request](https://help.github.com/articles/creating-a-pull-request/).

1. Go to the [Release Workflow](https://github.com/module-federation/universe/actions/workflows/trigger-release.yml) on GitHub.
2. Select the target branch (`canary`, `main`, `next`).
3. Choose the project from the dropdown menu.
4. Trigger the release.
5. Its suggested to trigger releases in order of consumption
### Format of PR titles

This ensures a consistent and automated release cycle across different channels, in line with modern CI/CD practices.
The format of PR titles follow Conventional Commits.

### Creating new packages/projects
An example:

To create a new package/project you can use any Nx generator you like/need, just make sure to add the `package` tag to the project and include the `release` target in the `package.json` file.
```
feat(plugin-swc): Add `xxx` config
^ ^ ^
| | |__ Subject
| |_______ Scope
|____________ Type
```

The nx-semantic-release plugin does NOT know when the package was created, so we need to manually create the first tag for the package, also keep in mind that the first version of the package should be `1.0.0` and not `0.0.0`, so to create the first tag for the package you can run:

```sh
git tag -a <PROJECT_NAME>-<VERSION>
```
## Release

Module Federation uses GitHub Actions for automated versioning and publishing:

## Action release

* next: The timestamp version will be created when you release with the next version, which is suitable for testing on your own
* beta|alpha: Suitable for releasing test versions
* latest: Suitable for releasing stable versions in the trunk branch

![image](https://github.com/module-federation/universe/assets/27547179/18580135-3326-4bff-9ba1-0570f40f9e2a)

Note that this format is important for the nx-semantic-release plugin understand the version of the package, you can check the used format in this project on the `tagFormat` option in the `nxrelease.config.js` file.
1 change: 1 addition & 0 deletions apps/3000-home/cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { nxE2EPreset } from '@nx/cypress/plugins/cypress-preset';
import { defineConfig } from 'cypress';

export default defineConfig({
projectId: 'sa6wfn',
e2e: nxE2EPreset(__filename, { cypressDir: 'cypress' }),
defaultCommandTimeout: 20000,
});
Loading