|
| 1 | +# dts |
| 2 | + |
| 3 | +- Type: `boolean | PluginDtsOptions` |
| 4 | +- Required: No |
| 5 | +- Default value: `true` |
| 6 | +- Usage scenario: used to control `Module Federation` generation/consumption type behavior |
| 7 | + |
| 8 | +After configuration, the producer will automatically generate a compressed type file `@mf-types.zip` (default name) during build, and the consumer will automatically pull the type file of `remotes` and decompress it to `@mf-types` (default name). |
| 9 | + |
| 10 | +The `PluginDtsOptions` types are as follows: |
| 11 | + |
| 12 | +```ts |
| 13 | +interface PluginDtsOptions { |
| 14 | + generateTypes?: boolean | DtsRemoteOptions; |
| 15 | + consumeTypes?: boolean | DtsHostOptions; |
| 16 | +} |
| 17 | +``` |
| 18 | + |
| 19 | +### generateTypes |
| 20 | + |
| 21 | +- Type: `boolean | DtsRemoteOptions` |
| 22 | +- Required: No |
| 23 | +- Default value: `true` |
| 24 | +- Usage scenario: used to control `Module Federation` generation type behavior |
| 25 | + |
| 26 | +The `DtsRemoteOptions` types are as follows: |
| 27 | + |
| 28 | +```ts |
| 29 | +interface DtsRemoteOptions { |
| 30 | + tsConfigPath?: string; |
| 31 | + typesFolder?: string; |
| 32 | + deleteTypesFolder?: boolean; |
| 33 | + additionalFilesToCompile?: string[]; |
| 34 | + compilerInstance?: 'tsc' | 'vue-tsc'; |
| 35 | + generateAPITypes?: boolean; |
| 36 | + extractThirdParty?: boolean; |
| 37 | + extractRemoteTypes?: boolean; |
| 38 | + abortOnError?: boolean; |
| 39 | +} |
| 40 | +``` |
| 41 | + |
| 42 | +When configuring `generateTypes` to `true`, the following configuration will be generated by default: |
| 43 | + |
| 44 | +```json |
| 45 | +{ |
| 46 | + "generateAPITypes": true, |
| 47 | + "abortOnError": false, |
| 48 | + "extractThirdParty": true, |
| 49 | + "extractRemoteTypes": true |
| 50 | +} |
| 51 | +``` |
| 52 | + |
| 53 | +#### extractRemoteTypes |
| 54 | + |
| 55 | +- Type: `boolean` |
| 56 | +- Required: No |
| 57 | +- Default value: `undefined` |
| 58 | +- Usage scenario: When the content of the producer `exposes` has its own `remotes` module that re-exports itself, then `extractRemoteTypes: true` can ensure that the consumer can normally obtain the module type of the producer `exposes` |
| 59 | +- Example: [Nested type re-export](../guide/basic/type-prompt#Nested type re-export) |
| 60 | + |
| 61 | +Whether to extract the type of `remotes`. |
| 62 | + |
| 63 | +#### extractThirdParty |
| 64 | + |
| 65 | +- Type: `boolean` |
| 66 | +- Required: No |
| 67 | +- Default value: `undefined` |
| 68 | +- Usage scenario: When the content of the producer `exposes` contains a module containing `antd`, and the consumer does not have `antd` installed, then `extractThirdParty: true` can ensure that the consumer can normally obtain the module of the producer `exposes` type |
| 69 | +- Example: [Third-party package type extraction](../guide/basic/type-prompt#Third-party package type extraction) |
| 70 | + |
| 71 | +Whether to extract third-party package types. |
| 72 | + |
| 73 | +#### generateAPITypes |
| 74 | + |
| 75 | +- Type: `boolean` |
| 76 | +- Required: No |
| 77 | +- Default value: `undefined` |
| 78 | +- Example: [Federation Runtime API type prompt](../guide/basic/type-prompt#federation-runtime-api-type-prompt) |
| 79 | + |
| 80 | +Whether to generate the `loadRemote` type in `Federation Runtime` |
| 81 | + |
| 82 | +#### abortOnError |
| 83 | + |
| 84 | +- Type: `boolean` |
| 85 | +- Required: No |
| 86 | +- Default value: `false` |
| 87 | + |
| 88 | +Whether to throw an error when a problem is encountered during type generation |
| 89 | + |
| 90 | +#### tsConfigPath |
| 91 | + |
| 92 | +- Type: `string` |
| 93 | +- Required: No |
| 94 | +- Default value: `path.join(process.cwd(),'./tsconfig.json')` |
| 95 | + |
| 96 | +tsconfig configuration file path |
| 97 | + |
| 98 | +#### typesFolder |
| 99 | + |
| 100 | +- Type: `string` |
| 101 | +- Required: No |
| 102 | +- Default value: `'@mf-types'` |
| 103 | + |
| 104 | +The name of the generated compression type file. For example, if typesFolder is set to `custom`, then the name of the generated compression type file is: `custom.zip` |
| 105 | + |
| 106 | +#### deleteTypesFolder |
| 107 | + |
| 108 | +- Type: `boolean` |
| 109 | +- Required: No |
| 110 | + -Default: `true` |
| 111 | + |
| 112 | +Whether to delete the generated type folder |
| 113 | + |
| 114 | +#### compilerInstance |
| 115 | + |
| 116 | +- Type: `'tsc' | 'vue-tsc'` |
| 117 | +- Required: No |
| 118 | +- Default value: `'tsc'` |
| 119 | + |
| 120 | +Example of compiled type |
| 121 | + |
| 122 | +### consumeTypes |
| 123 | + |
| 124 | +- Type: `boolean | DtsHostOptions` |
| 125 | +- Required: No |
| 126 | +- Default value: `true` |
| 127 | +- Usage scenario: used to control `Module Federation` consumption (loading) type behavior |
| 128 | + |
| 129 | +The `DtsHostOptions` types are as follows: |
| 130 | + |
| 131 | +```ts |
| 132 | +interface DtsHostOptions { |
| 133 | + typesFolder?: string; |
| 134 | + abortOnError?: boolean; |
| 135 | + remoteTypesFolder?: string; |
| 136 | + deleteTypesFolder?: boolean; |
| 137 | + maxRetries?: number; |
| 138 | + consumeAPITypes?: boolean; |
| 139 | +} |
| 140 | +``` |
| 141 | + |
| 142 | +When configuring `consumeTypes` to `true`, the following configuration will be generated by default: |
| 143 | + |
| 144 | +```json |
| 145 | +{ |
| 146 | + "abortOnError": false, |
| 147 | + "consumeAPITypes": true |
| 148 | +} |
| 149 | +``` |
| 150 | + |
| 151 | +#### consumeAPITypes |
| 152 | + |
| 153 | +- Type: `boolean` |
| 154 | +- Required: No |
| 155 | +- Default value: `true` |
| 156 | +- Example: [Federation Runtime API type prompt](../guide/basic/type-prompt#federation-runtime-api-type-prompt) |
| 157 | + |
| 158 | +Whether to generate the type of runtime `loadRemote` API |
| 159 | + |
| 160 | +#### maxRetries |
| 161 | + |
| 162 | +- Type: `number` |
| 163 | +- Required: No |
| 164 | +- Default value: `3` |
| 165 | + |
| 166 | +Maximum number of retries for failed loading |
| 167 | + |
| 168 | +#### abortOnError |
| 169 | + |
| 170 | +- Type: `boolean` |
| 171 | +- Required: No |
| 172 | +- Default value: `false` |
| 173 | + |
| 174 | +Whether to throw an error when a problem is encountered during type loading |
| 175 | + |
| 176 | +#### typesFolder |
| 177 | + |
| 178 | +- Type: `string` |
| 179 | +- Required: No |
| 180 | +- Default value: `'@mf-types'` |
| 181 | + |
| 182 | +Type storage directory after successful loading |
| 183 | + |
| 184 | +#### deleteTypesFolder |
| 185 | + |
| 186 | +- Type: `boolean` |
| 187 | +- Required: No |
| 188 | +- Default value: `true` |
| 189 | + |
| 190 | +Before loading type files, whether to delete the previously loaded `typesFolder` directory |
| 191 | + |
| 192 | +#### remoteTypesFolder |
| 193 | + |
| 194 | +- Type: `string` |
| 195 | +- Required: No |
| 196 | +- Default value: `'@mf-types'` |
| 197 | + |
| 198 | +`typesFolder` corresponding to `remotes` directory configuration |
0 commit comments