background
The core part of micro-frontend and micro-component development is cross-group and cross-department collaborative development. This article mainly describes the workflow of ts development implemented by the entire EMP v2.
type generation
The generated declaration file has two parts
- MF schema type generation
- Provide base station users to use
- Provide security verification for shared code
- Generate corresponding types based on
expose
andname
- Library schema type generation
- Provides tips for using npm
Generate process
Build processes run independently through worker-theads, improving overall efficiency
- create
dts
a thread - Traverse the project resource directory
- instantiate the dts class
- read tsconfig.json
- Specify the file cache directory
- Instantiate ts.languageService according to configuration
- Compile ts file with dts object
dts emit
- transfer
languageService.getEmitOutput
genDCode
- transfer
- output file
moduleFederation.name
as named file库模式根据lib.name进行命名
- exit the
dts
thread
Synchronization process
The type synchronization of multiple base stations currently performs download synchronization based on the access of the corresponding directory deployment by default.
- The main project requests through the convention directory or the specified directory
- Download and save the
d.ts
file tosrc
, so that ts can support identifying types and make type detection take effect - Replace
remote
the custom name - Generate the d.ts file of the corresponding base station defined by the project
EVERYTHING
For base station synchronization, the functions of automatic synchronization and automatic synchronization of hot update will be placed in subsequent planning.
finally
If you have more opinions and ideas on the development of micro front-end, you can communicate with them in the comment area.