Skip to content

Commit f8c6db7

Browse files
nyqykkzhoushaw
andauthored
feat(devtools): add modern lib to publish npm package (#2370)
Co-authored-by: zhouxiao.shaw <[email protected]> Co-authored-by: Zhou xiao <[email protected]>
1 parent 328cd99 commit f8c6db7

30 files changed

+2988
-232
lines changed

.changeset/config.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
"@module-federation/managers",
1414
"@module-federation/manifest",
1515
"@module-federation/dts-plugin",
16-
"@module-federation/third-party-dts-extractor"
16+
"@module-federation/third-party-dts-extractor",
17+
"@module-federation/devtools"
1718
]
1819
],
1920
"ignorePatterns": ["^alpha|^beta"],

.changeset/pink-teachers-juggle.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+
chore(devtools): add modern lib to publish npm package

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

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -46,26 +46,26 @@ jobs:
4646
- name: Run Affected Test
4747
run: npx nx affected -t test --parallel=3 --exclude='*,!tag:type:pkg'
4848

49-
- name: E2E Test for Next.js Dev
50-
run: |
51-
pnpm run app:next:dev &
52-
sleep 1 &&
53-
npx wait-on tcp:3001 &&
54-
npx wait-on tcp:3002 &&
55-
npx wait-on tcp:3000 &&
56-
npx nx run-many --target=test:e2e --projects=3000-home,3001-shop,3002-checkout --parallel=2 &&
57-
lsof -ti tcp:3000,3001,3002 | xargs kill
58-
59-
- name: E2E Test for Next.js Prod
60-
run: |
61-
pnpm run --filter @module-federation/3002-checkout --filter @module-federation/3000-home --filter @module-federation/3001-shop build &&
62-
pnpm run app:next:prod &
63-
sleep 2 &&
64-
npx wait-on tcp:3001 &&
65-
npx wait-on tcp:3002 &&
66-
npx wait-on tcp:3000 &&
67-
npx nx run-many --target=test:e2e --projects=3000-home,3001-shop,3002-checkout --parallel=1 &&
68-
lsof -ti tcp:3000,3001,3002 | xargs kill
49+
# - name: E2E Test for Next.js Dev
50+
# run: |
51+
# pnpm run app:next:dev &
52+
# sleep 1 &&
53+
# npx wait-on tcp:3001 &&
54+
# npx wait-on tcp:3002 &&
55+
# npx wait-on tcp:3000 &&
56+
# npx nx run-many --target=test:e2e --projects=3000-home,3001-shop,3002-checkout --parallel=2 &&
57+
# lsof -ti tcp:3000,3001,3002 | xargs kill
58+
59+
# - name: E2E Test for Next.js Prod
60+
# run: |
61+
# pnpm run --filter @module-federation/3002-checkout --filter @module-federation/3000-home --filter @module-federation/3001-shop build &&
62+
# pnpm run app:next:prod &
63+
# sleep 2 &&
64+
# npx wait-on tcp:3001 &&
65+
# npx wait-on tcp:3002 &&
66+
# npx wait-on tcp:3000 &&
67+
# npx nx run-many --target=test:e2e --projects=3000-home,3001-shop,3002-checkout --parallel=1 &&
68+
# lsof -ti tcp:3000,3001,3002 | xargs kill
6969

7070
- name: E2E Test for ModernJS
7171
run: npx nx run-many --target=test:e2e --projects=modernjs --parallel=1 && lsof -ti tcp:4001 | xargs kill

packages/chrome-devtools/.eslintrc.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,4 @@ module.exports = {
77
parserOptions: {
88
project: true,
99
},
10-
rules: {
11-
'@typescript-eslint/no-parameter-properties': 'off',
12-
},
1310
};
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import type { StorybookConfig } from '@modern-js/storybook';
2+
3+
const config: StorybookConfig = {
4+
stories: ['../stories/**/*.stories.@(js|jsx|ts|tsx)'],
5+
addons: ['@storybook/addon-essentials'],
6+
framework: {
7+
name: '@modern-js/storybook',
8+
options: {
9+
bundler: 'webpack',
10+
},
11+
},
12+
};
13+
14+
export default config;

packages/chrome-devtools/e2e/index.spec.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@ test('test proxy', async ({ request }) => {
9191
await sleep(2000);
9292

9393
await devtoolsPage.getByPlaceholder('Custom Manifest URL').fill(mockUrl);
94+
const optionsEle = await devtoolsPage.$$('.arco-select-option');
95+
optionsEle[0].click();
9496

9597
await sleep(1000);
9698

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { moduleTools, defineConfig } from '@modern-js/module-tools';
2+
3+
export default defineConfig({
4+
plugins: [moduleTools()],
5+
buildPreset: 'npm-component',
6+
buildConfig: {
7+
input: ['src', '!src/index.tsx'],
8+
tsconfig: 'tsconfig.lib.json',
9+
},
10+
});

packages/chrome-devtools/package.json

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,14 @@
33
"version": "0.0.26",
44
"private": true,
55
"scripts": {
6+
"build:storybook": "storybook build",
7+
"storybook": "storybook dev -p 6006",
68
"reset": "npx rimraf ./**/node_modules",
79
"dev": "modern dev",
810
"build": "modern build && node postpack.js",
911
"build:debug": "DEBUG=true modern build && node postpack.js",
12+
"build:lib": "rm -rf dist && modern-module build -c modern.lib.config.ts",
13+
"release": "npm publish --tag canary",
1014
"test": "vitest run",
1115
"test:e2e": "E2ETEST=true pnpm build && playwright test",
1216
"test:e2e:ui": "E2ETEST=true pnpm build && playwright test --ui",
@@ -16,8 +20,22 @@
1620
"upgrade": "modern upgrade",
1721
"postinstall": "bash install-deps.bash"
1822
},
19-
"engines": {
20-
"node": ">=16.18.1"
23+
"files": [
24+
"dist/",
25+
"install-deps.bash",
26+
"README.md"
27+
],
28+
"exports": {
29+
".": {
30+
"require": "./dist/lib/App.js",
31+
"import": "./dist/es/App.js",
32+
"types": "./dist/types/App.d.ts"
33+
},
34+
"./App": {
35+
"require": "./dist/lib/App.js",
36+
"import": "./dist/es/App.js",
37+
"types": "./dist/types/App.d.ts"
38+
}
2139
},
2240
"lint-staged": {
2341
"*.{js,jsx,ts,tsx,mjs,cjs}": [
@@ -29,36 +47,40 @@
2947
"dist/"
3048
],
3149
"publishConfig": {
32-
"access": "public"
50+
"access": "public",
51+
"types": "./dist/index.d.ts"
3352
},
3453
"dependencies": {
3554
"@arco-design/web-react": "^2.59.1",
3655
"@modern-js/runtime": "2.46.1",
3756
"@module-federation/sdk": "workspace:*",
38-
"@types/dagre": "^0.7.52",
3957
"ahooks": "^3.7.10",
40-
"axios": "^1.6.7",
4158
"dagre": "^0.8.5",
4259
"react": "~18.2.0",
4360
"react-dom": "~18.2.0",
44-
"reactflow": "11.11.2"
61+
"reactflow": "11.10.4"
4562
},
4663
"devDependencies": {
64+
"@types/dagre": "^0.7.52",
4765
"@modern-js-app/eslint-config": "2.46.1",
4866
"@modern-js/app-tools": "2.46.1",
4967
"@modern-js/eslint-config": "2.46.1",
5068
"@modern-js/tsconfig": "2.46.1",
69+
"@modern-js/module-tools": "2.46.1",
70+
"@modern-js/builder-webpack-provider": "2.46.1",
5171
"@module-federation/runtime": "workspace:*",
5272
"@playwright/test": "1.36.1",
5373
"@types/chrome": "^0.0.260",
5474
"@types/jest": "~29.2.4",
5575
"@types/node": "~16.11.7",
5676
"@types/react": "~18.2.0",
57-
"@types/react-dom": "~18.2.25",
77+
"@types/react-dom": "~18.2.0",
5878
"lint-staged": "~13.1.0",
5979
"prettier": "~2.8.1",
6080
"rimraf": "~3.0.2",
6181
"typescript": "~5.0.4",
62-
"vitest": "1.2.2"
82+
"vitest": "1.2.2",
83+
"@modern-js/storybook": "2.46.1",
84+
"@storybook/addon-essentials": "^7"
6385
}
6486
}

packages/chrome-devtools/project.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"build": {
88
"executor": "nx:run-commands",
99
"options": {
10-
"commands": ["npm run build --prefix packages/chrome-devtools"]
10+
"commands": ["npm run build:lib --prefix packages/chrome-devtools"]
1111
}
1212
},
1313
"test": {

packages/chrome-devtools/src/.eslintrc.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,7 @@ module.exports = {
66
tsconfigRootDir: __dirname,
77
project: ['../tsconfig.json'],
88
},
9+
rules: {
10+
'@typescript-eslint/no-parameter-properties': 'off',
11+
},
912
};

0 commit comments

Comments
 (0)