Skip to content

Commit 8632f69

Browse files
nyqykkzhoushaw
andauthored
feat(chrome-devtools): support devtools to debug online mf module (#2178)
Co-authored-by: zhouxiao.shaw <[email protected]> Co-authored-by: Zhou xiao <[email protected]>
1 parent c8c0ad2 commit 8632f69

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+5246
-69
lines changed

.changeset/pretty-olives-poke.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@module-federation/devtools': patch
3+
---
4+
5+
feat: Added chrome devtool

.github/workflows/build-and-test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ jobs:
5454
# run: pnpm run app:next:dev & echo "done" && sleep 20 && npx nx run-many --target=test:e2e --projects=3001-shop && lsof -ti tcp:3000,3001,3002 | xargs kill
5555

5656
- name: E2E Test for ModernJS
57-
run: npx nx run-many --target=test:e2e --projects=modernjs --parallel=1 && lsof -ti tcp:8080 | xargs kill
57+
run: npx nx run-many --target=test:e2e --projects=modernjs --parallel=1 && lsof -ti tcp:4001 | xargs kill
5858

5959
# - name: E2E Test for 3002-checkout
6060
# run: pnpm run app:next:dev & echo "done" && sleep 15 && npx nx run-many --target=test:e2e --projects=3002-checkout && lsof -ti tcp:3000,3001,3002 | xargs kill

.github/workflows/devtools.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Devtools
2+
3+
on:
4+
push:
5+
branches: ['main']
6+
pull_request:
7+
8+
env:
9+
PLAYWRIGHT_BROWSERS_PATH: 0 # Places binaries to node_modules/@playwright/test
10+
11+
jobs:
12+
main:
13+
runs-on: ubuntu-latest
14+
concurrency:
15+
group: ${{ github.head_ref || github.run_id }}
16+
cancel-in-progress: true
17+
steps:
18+
- name: Checkout Repository
19+
uses: actions/checkout@v3
20+
with:
21+
fetch-depth: 0
22+
23+
- name: Install Pnpm
24+
run: corepack enable
25+
26+
- name: Setup Node.js 18
27+
uses: actions/setup-node@v3
28+
with:
29+
node-version: '17'
30+
cache: 'pnpm'
31+
32+
- name: Set Nx SHA
33+
uses: nrwl/nx-set-shas@v3
34+
35+
- name: Install Dependencies
36+
run: pnpm install
37+
38+
- name: Run Affected Build
39+
run: npx nx affected -t build --parallel=10 --exclude='*,!tag:package'
40+
41+
- name: Configuration xvfb
42+
shell: bash
43+
run: sudo apt-get update && sudo apt-get install xvfb
44+
45+
- name: E2E Chrome Devtools
46+
run: |
47+
pnpm run app:manifest:dev & echo "done" && sleep 50 && npx nx e2e:devtools chrome-devtools && lsof -ti tcp:3008,3009,3010,3011,3012 | xargs kill

apps/modernjs/modern.config.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,21 @@ import {
55
} from '@module-federation/enhanced';
66
// https://modernjs.dev/en/configure/app/usage
77
export default defineConfig({
8+
dev: {
9+
port: 4001,
10+
},
811
runtime: {
912
router: true,
1013
},
14+
// source: {
15+
// enableAsyncEntry: true,
16+
// },
1117
plugins: [appTools()],
1218
tools: {
1319
webpack: (config, { webpack, appendPlugins }) => {
14-
config.output.publicPath = 'auto';
20+
if (config?.output) {
21+
config.output.publicPath = 'http://localhost:4001/';
22+
}
1523

1624
appendPlugins([
1725
new AsyncBoundaryPlugin({

apps/modernjs/project.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
"options": {
4444
"cypressConfig": "apps/modernjs/cypress.config.ts",
4545
"testingType": "e2e",
46-
"baseUrl": "http://localhost:8080",
46+
"baseUrl": "http://localhost:4001",
4747
"browser": "chrome"
4848
},
4949
"configurations": {

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
"lint": "nx run-many --target=lint",
2525
"test": "nx run-many --target=test",
2626
"build": "nx run-many --target=build --parallel=3 --exclude='*,!tag:package'",
27+
"build:pkg": "nx run-many --target=build --parallel=3 --exclude='react_ts_remote,react_ts_host'",
2728
"lint-fix": "nx format:write --uncommitted",
2829
"trigger-release": "node -e 'import(\"open\").then(open => open.default(\"https://github.com/module-federation/universe/actions/workflows/trigger-release.yml\"))'",
2930
"serve:next": "nx run-many --target=serve --all --parallel=3 -exclude='*,!tag:nextjs'",
@@ -147,6 +148,7 @@
147148
"@types/webpack-sources": "3.2.3",
148149
"@typescript-eslint/eslint-plugin": "6.21.0",
149150
"@typescript-eslint/parser": "6.21.0",
151+
"@types/chrome": "^0.0.260",
150152
"@vitest/coverage-istanbul": "1.2.2",
151153
"@vitest/coverage-v8": "1.2.2",
152154
"@vitest/ui": "1.2.2",
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
chrome >= 51
2+
edge >= 15
3+
firefox >= 54
4+
safari >= 10
5+
ios_saf >= 10
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
module.exports = {
2+
root: true,
3+
extends: ['@modern-js'],
4+
env: {
5+
webextensions: true,
6+
},
7+
parserOptions: {
8+
project: true,
9+
},
10+
rules: {
11+
'@typescript-eslint/no-parameter-properties': 'off',
12+
},
13+
};
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
.DS_Store
2+
3+
.pnp
4+
.pnp.js
5+
.env.local
6+
.env.*.local
7+
.history
8+
*.log*
9+
10+
node_modules/
11+
.yarn-integrity
12+
.pnpm-store/
13+
*.tsbuildinfo
14+
.eslintcache
15+
.changeset/pre.json
16+
17+
dist/
18+
coverage/
19+
release/
20+
output/
21+
output_resource/
22+
log/
23+
24+
.vscode/**/*
25+
!.vscode/settings.json
26+
!.vscode/extensions.json
27+
.idea/
28+
29+
**/*/typings/auto-generated
30+
31+
modern.config.local.*
32+
33+
test-results/

packages/chrome-devtools/.npmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
strict-peer-dependencies=false

0 commit comments

Comments
 (0)