Skip to content

Commit 685c607

Browse files
2heal1zhoushaw
andauthored
feat: support dynamic type hints (#2570)
Co-authored-by: Zhou xiao <[email protected]>
1 parent e8e0969 commit 685c607

Some content is hidden

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

46 files changed

+655
-120
lines changed

.changeset/gentle-melons-deliver.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
'@module-federation/third-party-dts-extractor': patch
3+
'@module-federation/dts-plugin': patch
4+
'@module-federation/runtime': patch
5+
'@module-federation/sdk': patch
6+
---
7+
8+
feat: support dynamic remote type hints

apps/runtime-demo/3006-runtime-remote/webpack.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ module.exports = composePlugins(
8282
// e.g. `config.plugins.push(new MyPlugin())`
8383
config.output = {
8484
...config.output,
85-
publicPath: 'http://localhost:3006/',
85+
publicPath: 'http://127.0.0.1:3006/',
8686
scriptType: 'text/javascript',
8787
};
8888
config.optimization = {

apps/runtime-demo/3007-runtime-remote/webpack.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ module.exports = composePlugins(
7272
// e.g. `config.plugins.push(new MyPlugin())`
7373
config.output = {
7474
...config.output,
75-
publicPath: 'http://localhost:3007/',
75+
publicPath: 'http://127.0.0.1:3007/',
7676
scriptType: 'text/javascript',
7777
};
7878
config.optimization = {

apps/website-new/docs/en/configure/dev.mdx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ The `PluginDevOptions` types are as follows:
1111
interface PluginDevOptions {
1212
disableLiveReload?: boolean;
1313
disableHotTypesReload?: boolean;
14+
disableDynamicRemoteTypeHints?: boolean;
1415
}
1516
```
1617

@@ -29,3 +30,11 @@ Whether to disable type hot reloading
2930
- Default value: `false`
3031

3132
Whether to disable `liveReload`, after setting `true`, any updates from the producer will not trigger the consumer's **page** `liveReload`
33+
34+
## disableDynamicRemoteTypeHints
35+
36+
- Type: `boolean`
37+
- Required: No
38+
- Default value: `false`
39+
40+
Whether to disable type hot reloading

apps/website-new/docs/zh/configure/dev.mdx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
interface PluginDevOptions {
1212
disableLiveReload?: boolean;
1313
disableHotTypesReload?: boolean;
14+
disableDynamicRemoteTypeHints?: boolean;
1415
}
1516
```
1617

@@ -29,3 +30,11 @@ interface PluginDevOptions {
2930
- 默认值:`false`
3031

3132
是否禁用 `liveReload`,设置 `true` 后,生产者的任何更新,都不会触发消费者的**页面** `liveReload`
33+
34+
## disableDynamicRemoteTypeHints
35+
36+
- 类型:`boolean`
37+
- 是否必填:否
38+
- 默认值:`false`
39+
40+
是否禁用动态模块类型提示,设置 `true` 后,消费者不会获取到动态模块的类型。

packages/dts-plugin/package.json

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@
2222
"import": "./dist/core.js",
2323
"require": "./dist/core.js"
2424
},
25+
"./dynamic-remote-type-hints-plugin": {
26+
"types": "./dist/dynamic-remote-type-hints-plugin.d.ts",
27+
"import": "./dist/esm/dynamic-remote-type-hints-plugin.js",
28+
"require": "./dist/dynamic-remote-type-hints-plugin.js"
29+
},
2530
"./*": "./*"
2631
},
2732
"typesVersions": {
@@ -31,6 +36,9 @@
3136
],
3237
"core": [
3338
"./dist/core.d.ts"
39+
],
40+
"dynamic-remote-type-hints-plugin": [
41+
"./dist/dynamic-remote-type-hints-plugin.d.ts"
3442
]
3543
}
3644
},
@@ -54,7 +62,8 @@
5462
"devDependencies": {
5563
"@types/ws": "8.5.10",
5664
"@types/koa": "2.11.2",
57-
"@types/node-schedule": "2.1.7"
65+
"@types/node-schedule": "2.1.7",
66+
"@module-federation/runtime": "workspace:*"
5867
},
5968
"peerDependencies": {
6069
"typescript": "^4.9.0 || ^5.0.0",

packages/dts-plugin/src/core/configurations/hostPlugin.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ const buildApiTypeUrl = (zipUrl?: string) => {
3333
return zipUrl.replace('.zip', '.d.ts');
3434
};
3535

36-
const retrieveRemoteInfo = (options: {
36+
export const retrieveRemoteInfo = (options: {
3737
hostOptions: Required<HostOptions>;
3838
remoteAlias: string;
3939
remote: string;

packages/dts-plugin/src/core/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export {
2323
UpdateMode,
2424
} from './constant';
2525

26-
export { DTSManagerOptions } from './interfaces/DTSManagerOptions';
27-
export { HostOptions } from './interfaces/HostOptions';
28-
export { RemoteOptions } from './interfaces/RemoteOptions';
26+
export type { DTSManagerOptions } from './interfaces/DTSManagerOptions';
27+
export type { HostOptions } from './interfaces/HostOptions';
28+
export type { RemoteOptions } from './interfaces/RemoteOptions';
2929
export * as rpc from './rpc/index';

packages/dts-plugin/src/core/lib/DTSManager.advance.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ describe('DTSManager advance usage', () => {
2121
'react-dom': { singleton: true, eager: true },
2222
},
2323
},
24-
tsConfigPath: join(__dirname, '../../..', './tsconfig.json'),
24+
tsConfigPath: join(__dirname, '../../..', './tsconfig.spec.json'),
2525
typesFolder: typesFolder,
2626
compiledTypesFolder: 'compiled-types',
2727
deleteTypesFolder: false,

packages/dts-plugin/src/core/lib/DTSManager.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ describe('DTSManager', () => {
2222
'react-dom': { singleton: true, eager: true },
2323
},
2424
},
25-
tsConfigPath: join(__dirname, '../../..', './tsconfig.json'),
25+
tsConfigPath: join(__dirname, '../../..', './tsconfig.spec.json'),
2626
typesFolder: typesFolder,
2727
compiledTypesFolder: 'compiled-types',
2828
deleteTypesFolder: false,

0 commit comments

Comments
 (0)