dts
- Type:
boolean | PluginDtsOptions - Required: No
- Default value:
true - Usage scenario: used to control
Module Federationgeneration/consumption type behavior
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).
The PluginDtsOptions types are as follows:
generateTypes
- Type:
boolean | DtsRemoteOptions - Required: No
- Default value:
true - Usage scenario: used to control
Module Federationgeneration type behavior
The DtsRemoteOptions types are as follows:
When configuring generateTypes to true, the following configuration will be generated by default:
extractRemoteTypes
- Type:
boolean - Required: No
- Default value:
undefined - Usage scenario: When the content of the producer
exposeshas its ownremotesmodule that re-exports itself, thenextractRemoteTypes: truecan ensure that the consumer can normally obtain the module type of the producerexposes - Example: [Nested type re-export](../guide/basic/type-prompt#Nested type re-export)
Whether to extract the type of remotes.
extractThirdParty
- Type:
boolean - Required: No
- Default value:
undefined - Usage scenario: When the content of the producer
exposescontains a module containingantd, and the consumer does not haveantdinstalled, thenextractThirdParty: truecan ensure that the consumer can normally obtain the module of the producerexposestype - Example: [Third-party package type extraction](../guide/basic/type-prompt#Third-party package type extraction)
Whether to extract third-party package types.
generateAPITypes
- Type:
boolean - Required: No
- Default value:
undefined - Example: Federation Runtime API type prompt
Whether to generate the loadRemote type in Federation Runtime
compileInChildProcess
- Type:
boolean - Required: No
- Default value:
undefined
Whether generate types in child process
abortOnError
- Type:
boolean - Required: No
- Default value:
false
Whether to throw an error when a problem is encountered during type generation
tsConfigPath
- Type:
string - Required: No
- Default value:
path.join(process.cwd(),'./tsconfig.json')
priority: dts.generateTypes.tsConfigPath > dts.tsConfigPath tsconfig configuration file path
typesFolder
- Type:
string - Required: No
- Default value:
'@mf-types'
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
deleteTypesFolder
- Type:
boolean - Required: No
-Default:
true
Whether to delete the generated type folder
compilerInstance
- Type:
'tsc' | 'tsgo' | 'vue-tsc' | 'tspc' | string - Required: No
- Default value:
'tsc'
Instance of compiled type
deleteTsConfig
- Type:
boolean - Required: No
- Default value:
true
Whether to delete the temporary tsconfig configuration file.
consumeTypes
- Type:
boolean | DtsHostOptions - Required: No
- Default value:
true - Usage scenario: used to control
Module Federationconsumption (loading) type behavior
The DtsHostOptions types are as follows:
When configuring consumeTypes to true, the following configuration will be generated by default:
consumeAPITypes
- Type:
boolean - Required: No
- Default value:
true - Example: Federation Runtime API type prompt
Whether to generate the type of runtime loadRemote API
maxRetries
- Type:
number - Required: No
- Default value:
3
Maximum number of retries for failed loading
abortOnError
- Type:
boolean - Required: No
- Default value:
false
Whether to throw an error when a problem is encountered during type loading
typesFolder
- Type:
string - Required: No
- Default value:
'@mf-types'
Type storage directory after successful loading
deleteTypesFolder
- Type:
boolean - Required: No
- Default value:
true
Before loading type files, whether to delete the previously loaded typesFolder directory
remoteTypesFolder
- Type:
string - Required: No
- Default value:
'@mf-types'
typesFolder corresponding to remotes directory configuration
remoteTypeUrls
- Type:
(() => Promise<RemoteTypeUrls>) | RemoteTypeUrls - Required: No
- Default value:
undefined
Used for getting the address of the remote type file.
Application scenarios:
- Only the runtime API is used to load the producer, and no build plugin is used. The MF type file address is informed by creating a
module-federation.config.tsconfiguration file and setting this configuration.
- When remote is
remoteEntry.js, the type file address usually directly replaces the js file with the corresponding type file, such as@mf-types.zip, but the actual uploaded type file address is not this, so you can tell MF the real type file address by setting this configuration.
family
- Type:
4 | 6 - Required: No
- Default value: 4
Configure the IP version family that will be used for network operations.
typesOnBuild
- Type:
boolean - Required: No
- Default:
false
By default, Module Federation does not load type files in production ( process.env.NODE_ENV === 'production' ). To enable type loading in production builds, set typesOnBuild to true .
tsConfigPath
- Type:
string - Required: No
- Default value:
path.join(process.cwd(),'./tsconfig.json')
tsconfig configuration file path
cwd
- Type:
string - Required: No
- Default value:
undefined
The working directory to run the compiler
displayErrorInTerminal
- Type:
boolean - Required: No
- Default value:
true
Whether print error log in terminal